From patchwork Tue Sep 27 19:48:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9352735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5D58F60757 for ; Tue, 27 Sep 2016 19:49:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41F732851D for ; Tue, 27 Sep 2016 19:49:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3664528885; Tue, 27 Sep 2016 19:49:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BE212851D for ; Tue, 27 Sep 2016 19:48:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754129AbcI0Ts5 (ORCPT ); Tue, 27 Sep 2016 15:48:57 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36505 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753345AbcI0Ts4 (ORCPT ); Tue, 27 Sep 2016 15:48:56 -0400 Received: by mail-wm0-f68.google.com with SMTP id b184so2710115wma.3 for ; Tue, 27 Sep 2016 12:48:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=pIC82X3n1JIvbj0O8TexvvexC26dNpGqpsi2L+mEUc0=; b=ltlkyZmdlQFQIHKPe/MYsyQCV6aFM4zMgTaE6/8kVpEqWcGCDqUjXDeojB9QSXjTZd cIIdpjxSPIfgAnFY8vi5WgFCV+1yT9g0slaGdwO9Hm0YDklDzNOxkFZ0O8FQuO+Bg9gX UlIGbue6r2va3iPClkpj1FjE0LFV8n3RqtjTdOMAnrG7qVjWmTXCwIRdwWG4/+ajS+j1 FFYpSpKuGs5TauYYuEikywduG0+VlAtUFkzJXrhKe/QavASb40nYQElwyrmkbF2cVkDv TiZvP0kxeh0EVfuM2H8ysv3Hdxqvn4Q3s8gZBrvowjgZUcCFP/hkpdpWMz8iAy9SQXao uxTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=pIC82X3n1JIvbj0O8TexvvexC26dNpGqpsi2L+mEUc0=; b=jbgRTwci9+Q7MXL8QSghN15IYupQBigf8DxdQ4iVWHufjEXqe/D5hKG4YczzUlzbnJ +ZeYVB9pfRhUe64NX0jQdARb1KRcm3ly4fmUtuHCQOxJCcWCpR4TBAWeOiAXuhJam+o3 drdTKM8vzH7fUYJdxrdYLNGBLRJUv6Wo/i2pPEJIvolmjcdBCHlcoF/s9MJ0lyXsxtW8 621VAWQZEJb4W7vBTYiNoRIlJZUqrRS8pOFs8oTjLmr2jWfiufjy5nrHvXdHDS9uTQI5 htkdUORZwHpbdsodycqOjKaFFXPXooT+BpXF6FonlA/8bFu5HihMJQ/9rrMWaIqI0UjA xEmQ== X-Gm-Message-State: AA6/9Rn1UuKiCnJSKip3t6Zd9jzfB6N2q/lz2XGtElqNF+Ox5fJEaYhp448rOiYxDdIfNA== X-Received: by 10.28.153.11 with SMTP id b11mr4431913wme.94.1475005734671; Tue, 27 Sep 2016 12:48:54 -0700 (PDT) Received: from ?IPv6:2003:62:5f1b:3000:e14b:7dc0:ee2c:df57? (p200300625F1B3000E14B7DC0EE2CDF57.dip0.t-ipconnect.de. [2003:62:5f1b:3000:e14b:7dc0:ee2c:df57]) by smtp.googlemail.com with ESMTPSA id 142sm4755538wmh.12.2016.09.27.12.48.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Sep 2016 12:48:54 -0700 (PDT) To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org From: Heiner Kallweit Subject: [PATCH] rc: ir-raw: change type of available_protocols to atomic64_t Message-ID: <368a90c9-a1ff-3f2d-609e-c255c486e406@gmail.com> Date: Tue, 27 Sep 2016 21:48:47 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Changing available_protocols to atomic64_t allows to get rid of the mutex protecting access to the variable. This helps to simplify the code. Signed-off-by: Heiner Kallweit --- drivers/media/rc/rc-ir-raw.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c index 205ecc6..1c42a9f 100644 --- a/drivers/media/rc/rc-ir-raw.c +++ b/drivers/media/rc/rc-ir-raw.c @@ -26,8 +26,7 @@ static LIST_HEAD(ir_raw_client_list); /* Used to handle IR raw handler extensions */ static DEFINE_MUTEX(ir_raw_handler_lock); static LIST_HEAD(ir_raw_handler_list); -static DEFINE_MUTEX(available_protocols_lock); -static u64 available_protocols; +static atomic64_t available_protocols = ATOMIC64_INIT(0); static int ir_raw_event_thread(void *data) { @@ -234,11 +233,7 @@ EXPORT_SYMBOL_GPL(ir_raw_event_handle); u64 ir_raw_get_allowed_protocols(void) { - u64 protocols; - mutex_lock(&available_protocols_lock); - protocols = available_protocols; - mutex_unlock(&available_protocols_lock); - return protocols; + return atomic64_read(&available_protocols); } static int change_protocol(struct rc_dev *dev, u64 *rc_type) @@ -331,9 +326,7 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler) if (ir_raw_handler->raw_register) list_for_each_entry(raw, &ir_raw_client_list, list) ir_raw_handler->raw_register(raw->dev); - mutex_lock(&available_protocols_lock); - available_protocols |= ir_raw_handler->protocols; - mutex_unlock(&available_protocols_lock); + atomic64_or(ir_raw_handler->protocols, &available_protocols); mutex_unlock(&ir_raw_handler_lock); return 0; @@ -352,9 +345,7 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler) if (ir_raw_handler->raw_unregister) ir_raw_handler->raw_unregister(raw->dev); } - mutex_lock(&available_protocols_lock); - available_protocols &= ~protocols; - mutex_unlock(&available_protocols_lock); + atomic64_andnot(protocols, &available_protocols); mutex_unlock(&ir_raw_handler_lock); } EXPORT_SYMBOL(ir_raw_handler_unregister);