All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/3] iio: addac: ad74413r: use ngpio size when iterating over mask
@ 2022-01-11  7:47 Cosmin Tanislav
  2022-01-11  7:47 ` [PATCH v3 2/3] iio: addac: ad74413r: correct comparator gpio getters mask usage Cosmin Tanislav
  2022-01-11  7:47 ` [PATCH v3 3/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit Cosmin Tanislav
  0 siblings, 2 replies; 8+ messages in thread
From: Cosmin Tanislav @ 2022-01-11  7:47 UTC (permalink / raw)
  To: andy.shevchenko
  Cc: cosmin.tanislav, demonsingur, Lars-Peter Clausen,
	Michael Hennerich, Rob Herring, linux-iio, devicetree,
	linux-kernel, Linus Walleij, Bartosz Golaszewski, linux-gpio

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 <cosmin.tanislav@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
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))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 2/3] iio: addac: ad74413r: correct comparator gpio getters mask usage
  2022-01-11  7:47 [PATCH v3 1/3] iio: addac: ad74413r: use ngpio size when iterating over mask Cosmin Tanislav
@ 2022-01-11  7:47 ` Cosmin Tanislav
  2022-01-11  9:21   ` Andy Shevchenko
  2022-01-11  7:47 ` [PATCH v3 3/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit Cosmin Tanislav
  1 sibling, 1 reply; 8+ messages in thread
From: Cosmin Tanislav @ 2022-01-11  7:47 UTC (permalink / raw)
  To: andy.shevchenko
  Cc: cosmin.tanislav, demonsingur, Lars-Peter Clausen,
	Michael Hennerich, Rob Herring, linux-iio, devicetree,
	linux-kernel, Linus Walleij, Bartosz Golaszewski, linux-gpio

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 <cosmin.tanislav@analog.com>
---
V1 -> V2
 * add Fixes tag
 * use __assign_bit
 * remove bitmap_zero

V2 -> V3
 * add back line between real_offset declaration and __assign_bit call
 * move before patch 2
---
 drivers/iio/addac/ad74413r.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c
index 6ea3cd933d05..b13cd5407df3 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;
 }
@@ -337,8 +336,7 @@ static int ad74413r_gpio_get_multiple(struct gpio_chip *chip,
 	for_each_set_bit_from(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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 3/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit
  2022-01-11  7:47 [PATCH v3 1/3] iio: addac: ad74413r: use ngpio size when iterating over mask Cosmin Tanislav
  2022-01-11  7:47 ` [PATCH v3 2/3] iio: addac: ad74413r: correct comparator gpio getters mask usage Cosmin Tanislav
@ 2022-01-11  7:47 ` Cosmin Tanislav
  2022-01-11  9:22   ` Andy Shevchenko
  1 sibling, 1 reply; 8+ messages in thread
From: Cosmin Tanislav @ 2022-01-11  7:47 UTC (permalink / raw)
  To: andy.shevchenko
  Cc: cosmin.tanislav, demonsingur, Lars-Peter Clausen,
	Michael Hennerich, Rob Herring, linux-iio, devicetree,
	linux-kernel, Linus Walleij, Bartosz Golaszewski, linux-gpio

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 <cosmin.tanislav@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
V2 -> V3
 * move after patch 3
---
 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 b13cd5407df3..cf58ee19f912 100644
--- a/drivers/iio/addac/ad74413r.c
+++ b/drivers/iio/addac/ad74413r.c
@@ -284,10 +284,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,
@@ -325,7 +325,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;
 
@@ -333,7 +333,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];
 
 		__assign_bit(offset, bits, val & BIT(real_offset));
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/3] iio: addac: ad74413r: correct comparator gpio getters mask usage
  2022-01-11  7:47 ` [PATCH v3 2/3] iio: addac: ad74413r: correct comparator gpio getters mask usage Cosmin Tanislav
@ 2022-01-11  9:21   ` Andy Shevchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2022-01-11  9:21 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: cosmin.tanislav, Lars-Peter Clausen, Michael Hennerich,
	Rob Herring, linux-iio, devicetree, Linux Kernel Mailing List,
	Linus Walleij, Bartosz Golaszewski, open list:GPIO SUBSYSTEM

On Tue, Jan 11, 2022 at 9:47 AM Cosmin Tanislav <demonsingur@gmail.com> wrote:
>
> 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.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Fixes: fea251b6a5db ("iio: addac: add AD74413R driver")
> Signed-off-by: Cosmin Tanislav <cosmin.tanislav@analog.com>
> ---
> V1 -> V2
>  * add Fixes tag
>  * use __assign_bit
>  * remove bitmap_zero
>
> V2 -> V3
>  * add back line between real_offset declaration and __assign_bit call
>  * move before patch 2
> ---
>  drivers/iio/addac/ad74413r.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c
> index 6ea3cd933d05..b13cd5407df3 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;
>  }
> @@ -337,8 +336,7 @@ static int ad74413r_gpio_get_multiple(struct gpio_chip *chip,
>         for_each_set_bit_from(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;
> --
> 2.34.1
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 3/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit
  2022-01-11  7:47 ` [PATCH v3 3/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit Cosmin Tanislav
@ 2022-01-11  9:22   ` Andy Shevchenko
  2022-01-15 18:59     ` Jonathan Cameron
  0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2022-01-11  9:22 UTC (permalink / raw)
  To: Cosmin Tanislav
  Cc: cosmin.tanislav, Lars-Peter Clausen, Michael Hennerich,
	Rob Herring, linux-iio, devicetree, Linux Kernel Mailing List,
	Linus Walleij, Bartosz Golaszewski, open list:GPIO SUBSYSTEM

On Tue, Jan 11, 2022 at 9:47 AM Cosmin Tanislav <demonsingur@gmail.com> wrote:
>
> 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.

We refer to the function() like this.
But no need to resend, I hope Jonathan may amend this when applying.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 3/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit
  2022-01-11  9:22   ` Andy Shevchenko
@ 2022-01-15 18:59     ` Jonathan Cameron
  2022-01-30 14:25       ` Jonathan Cameron
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Cameron @ 2022-01-15 18:59 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Cosmin Tanislav, cosmin.tanislav, Lars-Peter Clausen,
	Michael Hennerich, Rob Herring, linux-iio, devicetree,
	Linux Kernel Mailing List, Linus Walleij, Bartosz Golaszewski,
	open list:GPIO SUBSYSTEM

On Tue, 11 Jan 2022 11:22:23 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Tue, Jan 11, 2022 at 9:47 AM Cosmin Tanislav <demonsingur@gmail.com> wrote:
> >
> > 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.  
> 
> We refer to the function() like this.
> But no need to resend, I hope Jonathan may amend this when applying.
> 

I'll need to wait for rc1 to have the relevant code in my fixes-togreg
branch to pick these up.

They look fine to me and hopefully I'll remember to cleanup the above ;)

Thanks,

Jonathan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 3/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit
  2022-01-15 18:59     ` Jonathan Cameron
@ 2022-01-30 14:25       ` Jonathan Cameron
  2022-06-04 15:25         ` Jonathan Cameron
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Cameron @ 2022-01-30 14:25 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Cosmin Tanislav, cosmin.tanislav, Lars-Peter Clausen,
	Michael Hennerich, Rob Herring, linux-iio, devicetree,
	Linux Kernel Mailing List, Linus Walleij, Bartosz Golaszewski,
	open list:GPIO SUBSYSTEM

On Sat, 15 Jan 2022 18:59:48 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Tue, 11 Jan 2022 11:22:23 +0200
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> 
> > On Tue, Jan 11, 2022 at 9:47 AM Cosmin Tanislav <demonsingur@gmail.com> wrote:  
> > >
> > > 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.    
> > 
> > We refer to the function() like this.
> > But no need to resend, I hope Jonathan may amend this when applying.
> >   
> 
> I'll need to wait for rc1 to have the relevant code in my fixes-togreg
> branch to pick these up.
> 
> They look fine to me and hopefully I'll remember to cleanup the above ;)
> 
First 2 applied to the fixes-togreg branch of iio.git.

This 3rd one isn't a fix so will have to wait for those to end up in
my togreg branch.  Give me a shout if I seem to have lost this once that
is true.

Thanks,

Jonathan

> Thanks,
> 
> Jonathan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 3/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit
  2022-01-30 14:25       ` Jonathan Cameron
@ 2022-06-04 15:25         ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2022-06-04 15:25 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Cosmin Tanislav, cosmin.tanislav, Lars-Peter Clausen,
	Michael Hennerich, Rob Herring, linux-iio, devicetree,
	Linux Kernel Mailing List, Linus Walleij, Bartosz Golaszewski,
	open list:GPIO SUBSYSTEM

On Sun, 30 Jan 2022 14:25:58 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Sat, 15 Jan 2022 18:59:48 +0000
> Jonathan Cameron <jic23@kernel.org> wrote:
> 
> > On Tue, 11 Jan 2022 11:22:23 +0200
> > Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> >   
> > > On Tue, Jan 11, 2022 at 9:47 AM Cosmin Tanislav <demonsingur@gmail.com> wrote:    
> > > >
> > > > 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.      
> > > 
> > > We refer to the function() like this.
> > > But no need to resend, I hope Jonathan may amend this when applying.
> > >     
> > 
> > I'll need to wait for rc1 to have the relevant code in my fixes-togreg
> > branch to pick these up.
> > 
> > They look fine to me and hopefully I'll remember to cleanup the above ;)
> >   
> First 2 applied to the fixes-togreg branch of iio.git.
> 
> This 3rd one isn't a fix so will have to wait for those to end up in
> my togreg branch.  Give me a shout if I seem to have lost this once that
> is true.

Oops.  Even with patchwork I occasionally lose patches as too many things
stick there for a long time for complex reasons.

Anyhow, now applied to the togreg branch of iio.git

Sorry for the delay

Jonathan

> 
> Thanks,
> 
> Jonathan
> 
> > Thanks,
> > 
> > Jonathan  
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-06-04 15:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11  7:47 [PATCH v3 1/3] iio: addac: ad74413r: use ngpio size when iterating over mask Cosmin Tanislav
2022-01-11  7:47 ` [PATCH v3 2/3] iio: addac: ad74413r: correct comparator gpio getters mask usage Cosmin Tanislav
2022-01-11  9:21   ` Andy Shevchenko
2022-01-11  7:47 ` [PATCH v3 3/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit Cosmin Tanislav
2022-01-11  9:22   ` Andy Shevchenko
2022-01-15 18:59     ` Jonathan Cameron
2022-01-30 14:25       ` Jonathan Cameron
2022-06-04 15:25         ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.