From patchwork Thu Jan 6 06:22:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 530405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89A2DC433FE for ; Thu, 6 Jan 2022 06:23:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234767AbiAFGX0 (ORCPT ); Thu, 6 Jan 2022 01:23:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbiAFGX0 (ORCPT ); Thu, 6 Jan 2022 01:23:26 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8345C061245; Wed, 5 Jan 2022 22:23:25 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id bm14so5613872edb.5; Wed, 05 Jan 2022 22:23:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rIHuyJokQwYohJ2Ygvw5vXpDRn88ZneGaWCmSAP+ubg=; b=PrnF0YxbrqUNvqjeK2ecnKKMHIbVfRj6CErKpbQoSBy8TE/2m+33H8kHlCN5DP8EDH /Ic9cAZlLrUkw+xNOpu1ygoQ5MTDf1Tq7xue/Im5qHTTns6+qvvHuNUBG5UNOQ4dcQTu XXA+2xiPU0B6qtlA4JiBE2b1NUokswxLQwQt6A+ncIQW4hSI39eONnPTHPSiD8/bEH8F QFMnubHtE7AMHWtN9TDu6kfmU0Lkn8xcwPRvyuRR0WdpNf9mVVnOVB1n4o1gtl70Eh6Q t348gt63rMy48FH5iMUz4OlYUl0ZKdahj6PqUNwcerusGoI/THt2EjAUwyKo5RLn8V+I 9l4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rIHuyJokQwYohJ2Ygvw5vXpDRn88ZneGaWCmSAP+ubg=; b=XGrs2Ub5eQhJzDr+SeHfeccl6YAhFyHUwa/emhjZg/NzMb97/kXO03KW6kCWj7PKky M9rMKeBIFgcVlpKjNSV+o1iBdnIsU1nRPE0PiQ/Koy06yE26zssjwbu9tEcxHmK+VwZw o51nA7rMDSLLdirpA0CmptahifP2qCKjQY8UZfwjwVTT2UFjxx4ioLz4v6BpOdLOER+7 sHRRgoqCuWDSIT7Oq4yge/FgTKa110Gs2Q7BFi2lr19PCdmcXWkLlo2HeuHN4sUXYUOT q9B1G14Obz1SbpNe+BfBOq8QL/jDNwyD77WZwjCQbeBV7u1D7RBfxNmJcm2bKYaJkjCp Cl3g== X-Gm-Message-State: AOAM530tfTHNYrQ0rXUjq4b2Ec5VWyAVg4LE9Fi0D3PGkjgc4I/nrhn7 rUYsLb7+yFuwtilHjZ91/To= X-Google-Smtp-Source: ABdhPJwD2LFOdWwcZFDyDSj1xnLH0vWeFp4KTvkaZKT9mRPwosqH4XZc4QqrzlngFwrCKMoBsADbVA== X-Received: by 2002:aa7:de82:: with SMTP id j2mr37236972edv.389.1641450204597; Wed, 05 Jan 2022 22:23:24 -0800 (PST) Received: from demon-pc.localdomain ([2a02:2f0e:f707:7c00:2820:56a6:a8aa:5135]) by smtp.gmail.com with ESMTPSA id qb30sm242697ejc.119.2022.01.05.22.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 22:23:24 -0800 (PST) From: Cosmin Tanislav X-Google-Original-From: Cosmin Tanislav Cc: cosmin.tanislav@analog.com, demonsingur@gmail.com, Lars-Peter Clausen , Michael Hennerich , Rob Herring , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Subject: [PATCH 1/3] iio: addac: ad74413r: use ngpio size when iterating over mask Date: Thu, 6 Jan 2022 08:22:53 +0200 Message-Id: <20220106062255.3208817-1-cosmin.tanislav@analog.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org ngpio is the actual number of GPIOs handled by the GPIO chip, as opposed to the max number of GPIOs. Signed-off-by: Cosmin Tanislav --- drivers/iio/addac/ad74413r.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index 5271073bb74e..6ea3cd933d05 100644 --- a/drivers/iio/addac/ad74413r.c +++ b/drivers/iio/addac/ad74413r.c @@ -288,7 +288,7 @@ static void ad74413r_gpio_set_multiple(struct gpio_chip *chip, unsigned int offset = 0; int ret; - for_each_set_bit_from(offset, mask, AD74413R_CHANNEL_MAX) { + for_each_set_bit_from(offset, mask, chip->ngpio) { unsigned int real_offset = st->gpo_gpio_offsets[offset]; ret = ad74413r_set_gpo_config(st, real_offset, @@ -334,7 +334,7 @@ static int ad74413r_gpio_get_multiple(struct gpio_chip *chip, if (ret) return ret; - for_each_set_bit_from(offset, mask, AD74413R_CHANNEL_MAX) { + for_each_set_bit_from(offset, mask, chip->ngpio) { unsigned int real_offset = st->comp_gpio_offsets[offset]; if (val & BIT(real_offset)) From patchwork Thu Jan 6 06:22:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 530571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 085DAC43217 for ; Thu, 6 Jan 2022 06:23:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234815AbiAFGX2 (ORCPT ); Thu, 6 Jan 2022 01:23:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234809AbiAFGX2 (ORCPT ); Thu, 6 Jan 2022 01:23:28 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD427C061245; Wed, 5 Jan 2022 22:23:27 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id 30so3989570edv.3; Wed, 05 Jan 2022 22:23:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rKVOUbvydfCeHi5tJwijuuUgLBGIuDEY3IU/RY2wubM=; b=RrfZs/uM4TkREL/5OUI56ce4isc0HTw1n2RoKM/HlrQZfP971fN9YzmoJxa2TdHOwR T7dS9xalsyNoIi+w0PSgo7OuY15FHeYZzfXy2G+R0NWyp9dcUYcaVRwaFkegfe7EleJ+ CCev63fDvSz1UcHTYJFcjagFnF5XJ7ky5f7iG0Wc9ZUk6c/PnaNMqfXvOiO4b6A2zWik wEWHIcROx0RdEWRa9/yk2EXNyvo4aYn88HUWFkZ8YxXymls800vSkqPm28Oj1x5aAVC0 3YDQc3k27SNhwp9oPB2NRTZndcb5xVZ6xBQiXs4U0V4ojClUIKFcfDoQDxyQWyrBYsEo Z4CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rKVOUbvydfCeHi5tJwijuuUgLBGIuDEY3IU/RY2wubM=; b=yqYUSBWfYVWtrZ/CJttbUu9GUgje+fr+wdGIiSSc29/8HsRj07Hz3JZOGG76tSl6qx reCdac5N61vKmJ/vEEzWo/Zv50eUJlqKHV8kdiXPq1aPBODBOxaYBdBp7UxpaEVoDPBm IzquUXWxcr82uOQrlORpccyTrgUhQC3DqgM97Onei3jnJWPEnmaryIxcmIwc1aUQ1NVZ QgltCg9/ee6q79idhH+ah4wE4w94hCH1H9X+wg9IxIsJdlN0gTTvkUb6AQTMQAajw3ye aEZWJ/JQuYv+5dsBsqH9riOmm5QZcbFmXhPvr7/UL7ECn2kNwHbadbdQGP0TZFHkyO3f INLw== X-Gm-Message-State: AOAM532XlU+4aO9p9++ZPl34dLZxqbVoKOD3cxyUtZo6mmThypcoJ/8H t8n6fm1XOvNcvXWJpm+Fxto= X-Google-Smtp-Source: ABdhPJwd+6v20JTBtZQvuzTPWbFhe92tw/PTDXfplGlhp25/AXS+PleslelnJuNZ7jV6awFDcXJPWw== X-Received: by 2002:a50:d691:: with SMTP id r17mr23953653edi.317.1641450206431; Wed, 05 Jan 2022 22:23:26 -0800 (PST) Received: from demon-pc.localdomain ([2a02:2f0e:f707:7c00:2820:56a6:a8aa:5135]) by smtp.gmail.com with ESMTPSA id qb30sm242697ejc.119.2022.01.05.22.23.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 22:23:26 -0800 (PST) From: Cosmin Tanislav X-Google-Original-From: Cosmin Tanislav Cc: cosmin.tanislav@analog.com, demonsingur@gmail.com, Lars-Peter Clausen , Michael Hennerich , Rob Herring , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Subject: [PATCH 2/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit Date: Thu, 6 Jan 2022 08:22:54 +0200 Message-Id: <20220106062255.3208817-2-cosmin.tanislav@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220106062255.3208817-1-cosmin.tanislav@analog.com> References: <20220106062255.3208817-1-cosmin.tanislav@analog.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The starting bit is always zero, it doesn't make much sense to use for_each_set_bit_from. Replace it with for_each_set_bit which doesn't start from a particular bit. Signed-off-by: Cosmin Tanislav --- drivers/iio/addac/ad74413r.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index 6ea3cd933d05..3d089c0b6f7a 100644 --- a/drivers/iio/addac/ad74413r.c +++ b/drivers/iio/addac/ad74413r.c @@ -285,10 +285,10 @@ static void ad74413r_gpio_set_multiple(struct gpio_chip *chip, struct ad74413r_state *st = gpiochip_get_data(chip); unsigned long real_mask = 0; unsigned long real_bits = 0; - unsigned int offset = 0; + unsigned int offset; int ret; - for_each_set_bit_from(offset, mask, chip->ngpio) { + for_each_set_bit(offset, mask, chip->ngpio) { unsigned int real_offset = st->gpo_gpio_offsets[offset]; ret = ad74413r_set_gpo_config(st, real_offset, @@ -326,7 +326,7 @@ static int ad74413r_gpio_get_multiple(struct gpio_chip *chip, unsigned long *bits) { struct ad74413r_state *st = gpiochip_get_data(chip); - unsigned int offset = 0; + unsigned int offset; unsigned int val; int ret; @@ -334,7 +334,7 @@ static int ad74413r_gpio_get_multiple(struct gpio_chip *chip, if (ret) return ret; - for_each_set_bit_from(offset, mask, chip->ngpio) { + for_each_set_bit(offset, mask, chip->ngpio) { unsigned int real_offset = st->comp_gpio_offsets[offset]; if (val & BIT(real_offset)) From patchwork Thu Jan 6 06:22:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 530404 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF49DC433EF for ; Thu, 6 Jan 2022 06:23:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234809AbiAFGXa (ORCPT ); Thu, 6 Jan 2022 01:23:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234837AbiAFGX3 (ORCPT ); Thu, 6 Jan 2022 01:23:29 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D3E5C0611FD; Wed, 5 Jan 2022 22:23:29 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id j6so5489940edw.12; Wed, 05 Jan 2022 22:23:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+LT2llpcDDeuGqkPr2EdkkzFcdUblB6WvE7dQ51tddw=; b=aFUMATVGgffrfLTKkfbRmvz4Wzd2KJjMWqI6hrY9ZruxltQ/303uX7lkscq2J3rESi dFa8ZnKu54d+pgLYYdK2sIxjK2Cxbb709WPzRo/zJd1FF6UbqhsMzytLvGItA20f0dJg UHfiTcqV3TPBcshEc1l6Ey7kykv9xmbpZDaNEanQLQVsbblVV/5m3xU72EAFWndqVplv YIIfBKH+jhwZ/IIm3cE7BSpPzCysD1s6dD6hLLgkZosDbYfT6qfBQpCTTKhK9Y+aO2HF IZ5Z1xgiGMnzj+1V2IjwXwk016R+z1eaUqvYCvW9Nzrp0RHP9+U0p1GYMKeUZXl1T06e uSQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+LT2llpcDDeuGqkPr2EdkkzFcdUblB6WvE7dQ51tddw=; b=Zdub0GTMGtfg1U1ooIVSUZashCHoVBXynP2OM6BqnxuaOvThWiqXQEtDwYqpzy/fTx Jc3kcuMf9EZYhtMr+25jcXt/uw+LdGwlVQKO7xrVdLatEZ41k0FMkLyEzoxvHxdZi/96 LcVJToYt2pgINXl3kOEjQANc37la8Tc1QObPidCzPo0p6/abavg7iyiMolVJG8kerz9w wHPFJtHGuDFgCSvuQl1l42rw2Ay9nDgUVra7BJIKd/FgvHpxBm2xXXlVDIwunObxeEiW 7i6Myx3gMcnaq3k+lEFkw3O8eSA9o5AG6TryPItHYscVYLqoaq3YmIfiqGDqikMsJwFQ fZ6A== X-Gm-Message-State: AOAM5302i8jQdNWA00G9Y7g/rlMWNxJfjRvvwWihUkM4M2wFXboYPAos ors/q8mjYQ5Kla7UG+kzLlU= X-Google-Smtp-Source: ABdhPJzbUr8u3mFt6u8YVmtB/BfPX/6S9Ad53fSeTqu654hBcyra90WEa86k+K+y9qKai01k0+7InQ== X-Received: by 2002:a17:907:8a07:: with SMTP id sc7mr48742617ejc.738.1641450208033; Wed, 05 Jan 2022 22:23:28 -0800 (PST) Received: from demon-pc.localdomain ([2a02:2f0e:f707:7c00:2820:56a6:a8aa:5135]) by smtp.gmail.com with ESMTPSA id qb30sm242697ejc.119.2022.01.05.22.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 22:23:27 -0800 (PST) From: Cosmin Tanislav X-Google-Original-From: Cosmin Tanislav Cc: cosmin.tanislav@analog.com, demonsingur@gmail.com, Lars-Peter Clausen , Michael Hennerich , Rob Herring , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Subject: [PATCH 3/3] iio: addac: ad74413r: correct comparator gpio getters mask usage Date: Thu, 6 Jan 2022 08:22:55 +0200 Message-Id: <20220106062255.3208817-3-cosmin.tanislav@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220106062255.3208817-1-cosmin.tanislav@analog.com> References: <20220106062255.3208817-1-cosmin.tanislav@analog.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The value of the GPIOs is currently altered using offsets rather than masks. Make use the BIT macro to turn the offsets into masks. Signed-off-by: Cosmin Tanislav --- drivers/iio/addac/ad74413r.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index 3d089c0b6f7a..a69dee667441 100644 --- a/drivers/iio/addac/ad74413r.c +++ b/drivers/iio/addac/ad74413r.c @@ -134,7 +134,6 @@ struct ad74413r_state { #define AD74413R_CH_EN_MASK(x) BIT(x) #define AD74413R_REG_DIN_COMP_OUT 0x25 -#define AD74413R_DIN_COMP_OUT_SHIFT_X(x) x #define AD74413R_REG_ADC_RESULT_X(x) (0x26 + (x)) #define AD74413R_ADC_RESULT_MAX GENMASK(15, 0) @@ -316,7 +315,7 @@ static int ad74413r_gpio_get(struct gpio_chip *chip, unsigned int offset) if (ret) return ret; - status &= AD74413R_DIN_COMP_OUT_SHIFT_X(real_offset); + status &= BIT(real_offset); return status ? 1 : 0; } @@ -334,11 +333,13 @@ static int ad74413r_gpio_get_multiple(struct gpio_chip *chip, if (ret) return ret; + bitmap_zero(bits, chip->ngpio); + for_each_set_bit(offset, mask, chip->ngpio) { unsigned int real_offset = st->comp_gpio_offsets[offset]; if (val & BIT(real_offset)) - *bits |= offset; + *bits |= BIT(offset); } return ret;