From patchwork Fri Oct 17 08:50:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 5095871 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 75A829F38C for ; Fri, 17 Oct 2014 08:51:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7066201F5 for ; Fri, 17 Oct 2014 08:51:25 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id AF345201B9 for ; Fri, 17 Oct 2014 08:51:24 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9CC742651ED; Fri, 17 Oct 2014 10:51:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 97EDF2625CF; Fri, 17 Oct 2014 10:50:25 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D5F5626511F; Fri, 17 Oct 2014 10:50:23 +0200 (CEST) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 9AAAC2625CF for ; Fri, 17 Oct 2014 10:50:13 +0200 (CEST) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1DEE4AC8E for ; Fri, 17 Oct 2014 08:50:13 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Fri, 17 Oct 2014 10:50:05 +0200 Message-Id: <1413535807-21017-2-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1413535807-21017-1-git-send-email-tiwai@suse.de> References: <1413535807-21017-1-git-send-email-tiwai@suse.de> Subject: [alsa-devel] [PATCH v2 1/3] ALSA: seq: Use atomic ops for autoload refcount X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP ... just to robustify for races. Signed-off-by: Takashi Iwai --- sound/core/seq/seq_device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c index 91a786a783e1..775ea9390110 100644 --- a/sound/core/seq/seq_device.c +++ b/sound/core/seq/seq_device.c @@ -127,15 +127,15 @@ static void snd_seq_device_info(struct snd_info_entry *entry, #ifdef CONFIG_MODULES /* avoid auto-loading during module_init() */ -static int snd_seq_in_init; +static atomic_t snd_seq_in_init = ATOMIC_INIT(0); void snd_seq_autoload_lock(void) { - snd_seq_in_init++; + atomic_inc(&snd_seq_in_init); } void snd_seq_autoload_unlock(void) { - snd_seq_in_init--; + atomic_dec(&snd_seq_in_init); } #endif @@ -147,7 +147,7 @@ void snd_seq_device_load_drivers(void) /* Calling request_module during module_init() * may cause blocking. */ - if (snd_seq_in_init) + if (atomic_read(&snd_seq_in_init)) return; mutex_lock(&ops_mutex);