From patchwork Mon Jan 10 22:05:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12709184 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 BF9A2C4332F for ; Mon, 10 Jan 2022 22:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345216AbiAJWF1 (ORCPT ); Mon, 10 Jan 2022 17:05:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345138AbiAJWFZ (ORCPT ); Mon, 10 Jan 2022 17:05:25 -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 2C9EDC06173F; Mon, 10 Jan 2022 14:05:25 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id a18so58335795edj.7; Mon, 10 Jan 2022 14:05: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=2KNDSTMgmpn78jXPNcdZdc248EGwYEv2Gjal4+4tRhw=; b=RiFStyDM5Pp8ZqOKMAsRLRlEn/FLc4LxH7nUjUHXMSug5CXO0SseBSimR7JTeQ0oP3 GDm+dKtb4/F3GXYBMmW+yix9J6zPp+ICpKg3cskyUYWepIkbn9oQuYE8R+/B+dKyOZw8 QRXY4w0rB/6ZBwUh8u0H8iJv8AXw79QBVBMn45Zd17bfWpzlonPizIdbIIyFXO4x37cM BQKAKT1xC5dxxzP1EUMW7prgFJ3TUJupyJJMYmQzjwGdLYPZfXHLxr2Z5kRxHDw2za5M ZwIiAE0Xc4BtoQGQGkD55K9195F+V99LDjjZeiAEG33Ultcx6aEXvLgc8QKL9l/Wc+B3 92rg== 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=2KNDSTMgmpn78jXPNcdZdc248EGwYEv2Gjal4+4tRhw=; b=CEzftobPDNUQj6TSkAbRhlNrStnt5e1+lRi8QoRiJp/MgYU1hthwTQzLCaUZG0wAVc gK+kqJ8sCsAsIIqn8LLBISJdUEmLSuTWwtGPO2pfYuCJiE8QRB5NCqwsjiyclnfheUdx qR7JMt42o9zc/ywV6fVKauBIhbd+Wpmj4nMY9HL2XFUw32DSc32k1FD1f/jlZjYaAMoL TDbT1vh5jT7sq2+EmoZrX6I/icCr5+m/qbSE/J305sbAjWkSlo5Sh0K3O2RRJ6clbNJF u2MTzDsnP5hVKEFaCV2VCGhtPB9tRHXVBjnxlo04TrznTxpGrORHJDZSt+tva+OmVIBp Sknw== X-Gm-Message-State: AOAM5314rBeRZMQH47Dt4NcjPb2AiKztuEWy+WzWaYLLwNBkagjQoYN4 hlpkMJKCZ7CUQwVspErhFyo= X-Google-Smtp-Source: ABdhPJwFaNr3YbubWwEFcP1bli+hmQ0u9SBToTufY4zEEmBjEMZPwN1nzD7musj0eO+J568M/l0j5A== X-Received: by 2002:a17:906:69d2:: with SMTP id g18mr1363345ejs.197.1641852323764; Mon, 10 Jan 2022 14:05:23 -0800 (PST) Received: from demon-pc.localdomain ([79.119.107.253]) by smtp.gmail.com with ESMTPSA id q21sm2842672ejn.107.2022.01.10.14.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jan 2022 14:05:23 -0800 (PST) From: Cosmin Tanislav X-Google-Original-From: Cosmin Tanislav To: andy.shevchenko@gmail.com 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 v2 1/3] iio: addac: ad74413r: use ngpio size when iterating over mask Date: Tue, 11 Jan 2022 00:05:07 +0200 Message-Id: <20220110220509.3527402-1-cosmin.tanislav@analog.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org ngpio is the actual number of GPIOs handled by the GPIO chip, as opposed to the max number of GPIOs. Fixes: fea251b6a5db ("iio: addac: add AD74413R driver") Signed-off-by: Cosmin Tanislav --- V1 -> V2 * add Fixes tag --- 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 Mon Jan 10 22:05:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12709185 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 A943BC433F5 for ; Mon, 10 Jan 2022 22:05:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240803AbiAJWF3 (ORCPT ); Mon, 10 Jan 2022 17:05:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345224AbiAJWF2 (ORCPT ); Mon, 10 Jan 2022 17:05:28 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57469C06173F; Mon, 10 Jan 2022 14:05:28 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id u21so36810822edd.5; Mon, 10 Jan 2022 14:05:28 -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=SeeQIQpkWM/ess+X62WkIw0TES/RhtM1mfTCs2z3Ddsu0xLqdO4RA65vAjNGW1h2xE oYC+10H3bP9blkHgTd7f/FgcOmmqT1WuagUaSzE8Clm+IWIazILugNDdN0pryMjNepqy kruWd1uueFZKdlbHcTC1s2ppwq4idTPttGUFqfTVkJjUjUSVd2YQjM7dpCtFT5+QFatL Cb/Xsu9Vn2cYsodJWZELQycIwx4zgq6qdl3/wpKdjsG87C46u6YacwUPPkS9J7Sc2i1C kJbrSZLg7DCXpEpizL6zVmZNZCHrbjcBGzW2/JhKFqGpX4HHtZwHCyRTNfkMSwx6NebO JDkw== 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=LejPjQDkkNF1dP92a6tMEXpY29blLxGtV6EsgW0/ew7/19jKDrXOzFrTbMoRpDLIgG thmauzarcAhvLTm6iUX1DXV9AHPc4YeeYvjb8m72Ua/OOgh5DQO/bj7eKxGlHAiqlTnf kOuti4DRATmFcT2wGP0sIc2ixw/vnyXkSTsGI8QhntxysE+T0U5B3Gy62WUyJDFXUa4i 9tjhUKVgW/ApDOJ4WbBQ9VbUN94oouFPshvDmKQQGh5l32aFY6RwTIskssA3C3vZhN5N qdpDKwoUhFKVDesUdjqHhY5+jpw6WyPLy15FAwYQbkqwLdTOoVbAI3wKLot9ThUxYwn9 GUZQ== X-Gm-Message-State: AOAM532YW4jOAUuNWFgjB0n6vHp9dXD5PFlU7rCSeVJgnqUVgVsDIxZJ jhWMG+GV1rMqYrdU2ESmdQFezHrA0WBQjg== X-Google-Smtp-Source: ABdhPJy1wVf+72rwfYqpxWlszjQV5IoEh/vncFDqxg/OHqFm+ToWBJBvYjIe1mKw3ueOlIRiuH1LLg== X-Received: by 2002:a50:eacb:: with SMTP id u11mr1641622edp.290.1641852327043; Mon, 10 Jan 2022 14:05:27 -0800 (PST) Received: from demon-pc.localdomain ([79.119.107.253]) by smtp.gmail.com with ESMTPSA id q21sm2842672ejn.107.2022.01.10.14.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jan 2022 14:05:26 -0800 (PST) From: Cosmin Tanislav X-Google-Original-From: Cosmin Tanislav To: andy.shevchenko@gmail.com 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 v2 2/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit Date: Tue, 11 Jan 2022 00:05:08 +0200 Message-Id: <20220110220509.3527402-2-cosmin.tanislav@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220110220509.3527402-1-cosmin.tanislav@analog.com> References: <20220110220509.3527402-1-cosmin.tanislav@analog.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 Mon Jan 10 22:05:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12709186 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 C8DE2C43219 for ; Mon, 10 Jan 2022 22:05:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345138AbiAJWFc (ORCPT ); Mon, 10 Jan 2022 17:05:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345233AbiAJWFa (ORCPT ); Mon, 10 Jan 2022 17:05:30 -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 C819FC061748; Mon, 10 Jan 2022 14:05:29 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id o6so59438646edc.4; Mon, 10 Jan 2022 14:05: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=7qTgRogzHIjz3RKxh1ZqDUQUFjrtnjfdm+rxB2VFGYs=; b=jJ9d1QXcjM+7clYoRP5Td1uYItfEqQb4ShBVPtPj6HuvwR00zICme3sSDdgxCbadEe Bjc42QV3Gl80hYuV0KGzdPsbYuM7o7ZbXJHJzx1uhBwZcw87sy7BmgxdXzRJF9p7TZYP ugvkeJvVSu1mdlM+kl813dxorQfucU4sCybsn+h123M+q665Vlg+S3fqMRM31WCIhajO YMYP+6Wpv1g2W7oPSdCYxM6GPIdG0D8UUrXYzewpvhPmLjgV05nIhX55gHJL0vm3/w3Z j4MikSKqB7XJiLoUwWhaiKpXRDRA94EO1fquWXpOjD8JLYZElIwouZ3sFMqmkYLvV67M pOJA== 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=7qTgRogzHIjz3RKxh1ZqDUQUFjrtnjfdm+rxB2VFGYs=; b=yH/65bBYphjh1Sr/U0ZGTPKQSHTqS4VLVzAaiHRLirW0ukNBoiwZ7EIbTQKRSyztTC bE+DScv1Zu96xSWqamfjF11WIn0LlK+WiWCc2PtLCUBirneRe7hFcWfnIO79KcdCGs9o ypZRUen8uolnWwET73bX6liKTub1aIcfwjZeX36QPGtD1D3l6vrViWBON/D/L6y+XLkg VOrfC5YeUK82+VUDeaVFcE/T1EnkKVrRq+0mExsBdVPqm32FNwAmigM3QxEefbulrbxc WXr0Ut3xHztdeyuXNmXlJ5br/57Lx6qCCV1rtoQ7p+AoX0Xa5sPOB/IKE7xMICzv2Bf+ QqLg== X-Gm-Message-State: AOAM533MOuxxGLF6fgoKtffxfmSpM4GZgE4UW8HjFcaMeBt/D9rnrn97 lSybpf591C1nPT39wufIJZB4ddftg6MZBg== X-Google-Smtp-Source: ABdhPJyKxkpzHy/amPKgIYRSwC/0jEiQlHDkAMQtXuLZJ1l0MTo+6gbVaqNZI0TVTR12hi7xgVsbNg== X-Received: by 2002:aa7:d383:: with SMTP id x3mr1609957edq.392.1641852328423; Mon, 10 Jan 2022 14:05:28 -0800 (PST) Received: from demon-pc.localdomain ([79.119.107.253]) by smtp.gmail.com with ESMTPSA id q21sm2842672ejn.107.2022.01.10.14.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jan 2022 14:05:28 -0800 (PST) From: Cosmin Tanislav X-Google-Original-From: Cosmin Tanislav To: andy.shevchenko@gmail.com 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 v2 3/3] iio: addac: ad74413r: correct comparator gpio getters mask usage Date: Tue, 11 Jan 2022 00:05:09 +0200 Message-Id: <20220110220509.3527402-3-cosmin.tanislav@analog.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220110220509.3527402-1-cosmin.tanislav@analog.com> References: <20220110220509.3527402-1-cosmin.tanislav@analog.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The value of the GPIOs is currently altered using offsets rather than masks. Make use of __assign_bit and the BIT macro to turn the offsets into masks. Fixes: fea251b6a5db ("iio: addac: add AD74413R driver") Signed-off-by: Cosmin Tanislav --- V1 -> V2 * add Fixes tag * use __assign_bit * remove bitmap_zero --- drivers/iio/addac/ad74413r.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index 3d089c0b6f7a..8a8d60e592a8 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; } @@ -336,9 +335,7 @@ static int ad74413r_gpio_get_multiple(struct gpio_chip *chip, for_each_set_bit(offset, mask, chip->ngpio) { unsigned int real_offset = st->comp_gpio_offsets[offset]; - - if (val & BIT(real_offset)) - *bits |= offset; + __assign_bit(offset, bits, val & BIT(real_offset)); } return ret;