From patchwork Mon Jun 1 23:09:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 6525011 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 416EAC0020 for ; Mon, 1 Jun 2015 23:12:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C45F20465 for ; Mon, 1 Jun 2015 23:12:31 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2BE9120389 for ; Mon, 1 Jun 2015 23:12:30 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1707B260436; Tue, 2 Jun 2015 01:12:29 +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 9A8BE264F0D; Tue, 2 Jun 2015 01:11:03 +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 06253264F0D; Tue, 2 Jun 2015 01:11:02 +0200 (CEST) Received: from mail.mleia.com (li271-223.members.linode.com [178.79.152.223]) by alsa0.perex.cz (Postfix) with ESMTP id 597FB260436 for ; Tue, 2 Jun 2015 01:09:46 +0200 (CEST) Received: from mail.mleia.com (localhost [127.0.0.1]) by mail.mleia.com (Postfix) with ESMTP id 113E19AE65; Tue, 2 Jun 2015 00:12:17 +0100 (BST) From: Vladimir Zapolskiy To: Mark Brown , Liam Girdwood , Linus Walleij , Alexandre Courbot Date: Tue, 2 Jun 2015 02:09:15 +0300 Message-Id: <1433200158-6890-4-git-send-email-vz@mleia.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433200031-6748-1-git-send-email-vz@mleia.com> References: <1433200031-6748-1-git-send-email-vz@mleia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-49551924 X-CRM114-CacheID: sfid-20150602_001217_095230_3D7681FB X-CRM114-Status: GOOD ( 13.28 ) Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen , Axel Lin , Takashi Iwai , patches@opensource.wolfsonmicro.com, linux-gpio@vger.kernel.org, Charles Keepax Subject: [alsa-devel] [PATCH 4/7] ASoC: wm8903: simplify gpiolib callbacks 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 The change cleans up gpiolib callbacks, and the main intention is to remove bitwise operations on GPIO level value as a preceding change to switch gpiolib callbacks to utilize bool type to represent GPIO level. No functional change. Signed-off-by: Vladimir Zapolskiy Cc: Charles Keepax Cc: Lars-Peter Clausen Cc: Axel Lin Cc: patches@opensource.wolfsonmicro.com Acked-by: Charles Keepax --- sound/soc/codecs/wm8903.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index 93f1ce0..efac26b 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -1783,18 +1783,13 @@ static int wm8903_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { struct wm8903_priv *wm8903 = gpio_to_wm8903(chip); unsigned int mask, val; - int ret; mask = WM8903_GPn_FN_MASK | WM8903_GPn_DIR_MASK; val = (WM8903_GPn_FN_GPIO_INPUT << WM8903_GPn_FN_SHIFT) | WM8903_GPn_DIR; - ret = regmap_update_bits(wm8903->regmap, - WM8903_GPIO_CONTROL_1 + offset, mask, val); - if (ret < 0) - return ret; - - return 0; + return regmap_update_bits(wm8903->regmap, + WM8903_GPIO_CONTROL_1 + offset, mask, val); } static int wm8903_gpio_get(struct gpio_chip *chip, unsigned offset) @@ -1812,27 +1807,26 @@ static int wm8903_gpio_direction_out(struct gpio_chip *chip, { struct wm8903_priv *wm8903 = gpio_to_wm8903(chip); unsigned int mask, val; - int ret; mask = WM8903_GPn_FN_MASK | WM8903_GPn_DIR_MASK | WM8903_GPn_LVL_MASK; - val = (WM8903_GPn_FN_GPIO_OUTPUT << WM8903_GPn_FN_SHIFT) | - (value << WM8903_GPn_LVL_SHIFT); + val = WM8903_GPn_FN_GPIO_OUTPUT << WM8903_GPn_FN_SHIFT; + if (value) + val |= 0x1 << WM8903_GPn_LVL_SHIFT; - ret = regmap_update_bits(wm8903->regmap, - WM8903_GPIO_CONTROL_1 + offset, mask, val); - if (ret < 0) - return ret; - - return 0; + return regmap_update_bits(wm8903->regmap, + WM8903_GPIO_CONTROL_1 + offset, mask, val); } static void wm8903_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct wm8903_priv *wm8903 = gpio_to_wm8903(chip); + unsigned int val = 0; + + if (value) + val = 0x1 << WM8903_GPn_LVL_SHIFT; regmap_update_bits(wm8903->regmap, WM8903_GPIO_CONTROL_1 + offset, - WM8903_GPn_LVL_MASK, - !!value << WM8903_GPn_LVL_SHIFT); + WM8903_GPn_LVL_MASK, val); } static struct gpio_chip wm8903_template_chip = {