From patchwork Mon Jun 1 23:09:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 6524991 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 5B5A7C0020 for ; Mon, 1 Jun 2015 23:10:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F83B20495 for ; Mon, 1 Jun 2015 23:10:22 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id AD7E520465 for ; Mon, 1 Jun 2015 23:10:20 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8D4B0260532; Tue, 2 Jun 2015 01:10:19 +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 7D7B6260478; Tue, 2 Jun 2015 01:09:40 +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 C7EBA260429; Tue, 2 Jun 2015 01:09:38 +0200 (CEST) Received: from mail.mleia.com (li271-223.members.linode.com [178.79.152.223]) by alsa0.perex.cz (Postfix) with ESMTP id 591A5260425 for ; Tue, 2 Jun 2015 01:09:29 +0200 (CEST) Received: from mail.mleia.com (localhost [127.0.0.1]) by mail.mleia.com (Postfix) with ESMTP id 20E019AE5B; Tue, 2 Jun 2015 00:12:15 +0100 (BST) From: Vladimir Zapolskiy To: Mark Brown , Liam Girdwood , Linus Walleij , Alexandre Courbot Date: Tue, 2 Jun 2015 02:09:13 +0300 Message-Id: <1433200158-6890-2-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_001215_157514_6B43EEF2 X-CRM114-Status: GOOD ( 10.28 ) Cc: Oder Chiou , alsa-devel@alsa-project.org, Takashi Iwai , linux-gpio@vger.kernel.org, Bard Liao Subject: [alsa-devel] [PATCH 2/7] ASoC: rt5677: clean up 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 main intention of the change is to remove bitwise operations on GPIO level value as a preceding change before updating gpiolib callbacks to utilize bool type representing a GPIO level. Usage of generic over GPIO[1-5] macros allows to remove calculations with magic numbers. No functional change. Signed-off-by: Vladimir Zapolskiy Cc: Bard Liao Cc: Oder Chiou --- sound/soc/codecs/rt5677.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 31d969a..28908f5a 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -4507,16 +4507,23 @@ static inline struct rt5677_priv *gpio_to_rt5677(struct gpio_chip *chip) static void rt5677_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct rt5677_priv *rt5677 = gpio_to_rt5677(chip); + unsigned int val = 0; switch (offset) { case RT5677_GPIO1 ... RT5677_GPIO5: + if (value) + val = RT5677_GPIO_OUT_HI(offset); + regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2, - 0x1 << (offset * 3 + 1), !!value << (offset * 3 + 1)); + RT5677_GPIO_OUT_MASK(offset), val); break; case RT5677_GPIO6: + if (value) + val = RT5677_GPIO6_OUT_HI; + regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3, - RT5677_GPIO6_OUT_MASK, !!value << RT5677_GPIO6_OUT_SFT); + RT5677_GPIO6_OUT_MASK, val); break; default: @@ -4528,18 +4535,27 @@ static int rt5677_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { struct rt5677_priv *rt5677 = gpio_to_rt5677(chip); + unsigned int val; switch (offset) { case RT5677_GPIO1 ... RT5677_GPIO5: + val = RT5677_GPIO_DIR_OUT(offset); + + if (value) + val |= RT5677_GPIO_OUT_HI(offset); + regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2, - 0x3 << (offset * 3 + 1), - (0x2 | !!value) << (offset * 3 + 1)); + RT5677_GPIO_DIR_OUT_MASK(offset), val); break; case RT5677_GPIO6: + val = RT5677_GPIO6_DIR_OUT; + + if (value) + val |= RT5677_GPIO6_OUT_HI; + regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3, - RT5677_GPIO6_DIR_MASK | RT5677_GPIO6_OUT_MASK, - RT5677_GPIO6_DIR_OUT | !!value << RT5677_GPIO6_OUT_SFT); + RT5677_GPIO6_DIR_MASK | RT5677_GPIO6_OUT_MASK, val); break; default: @@ -4568,12 +4584,12 @@ static int rt5677_gpio_direction_in(struct gpio_chip *chip, unsigned offset) switch (offset) { case RT5677_GPIO1 ... RT5677_GPIO5: regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL2, - 0x1 << (offset * 3 + 2), 0x0); + RT5677_GPIO_DIR_MASK(offset), 0x0); break; case RT5677_GPIO6: regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL3, - RT5677_GPIO6_DIR_MASK, RT5677_GPIO6_DIR_IN); + RT5677_GPIO6_DIR_MASK, RT5677_GPIO6_DIR_IN); break; default: