* [PATCH v2 1/3] iio: addac: ad74413r: use ngpio size when iterating over mask
@ 2022-01-10 22:05 Cosmin Tanislav
2022-01-10 22:05 ` [PATCH v2 2/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit Cosmin Tanislav
2022-01-10 22:05 ` [PATCH v2 3/3] iio: addac: ad74413r: correct comparator gpio getters mask usage Cosmin Tanislav
0 siblings, 2 replies; 5+ messages in thread
From: Cosmin Tanislav @ 2022-01-10 22:05 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>
---
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 [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit
2022-01-10 22:05 [PATCH v2 1/3] iio: addac: ad74413r: use ngpio size when iterating over mask Cosmin Tanislav
@ 2022-01-10 22:05 ` Cosmin Tanislav
2022-01-10 22:05 ` [PATCH v2 3/3] iio: addac: ad74413r: correct comparator gpio getters mask usage Cosmin Tanislav
1 sibling, 0 replies; 5+ messages in thread
From: Cosmin Tanislav @ 2022-01-10 22:05 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>
---
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))
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 3/3] iio: addac: ad74413r: correct comparator gpio getters mask usage
2022-01-10 22:05 [PATCH v2 1/3] iio: addac: ad74413r: use ngpio size when iterating over mask Cosmin Tanislav
2022-01-10 22:05 ` [PATCH v2 2/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit Cosmin Tanislav
@ 2022-01-10 22:05 ` Cosmin Tanislav
[not found] ` <CAHp75VezW0DTvjLb6wOOf+skCv5-bDV38ozNaCq1wX+Oekarfw@mail.gmail.com>
[not found] ` <CAHp75VckhARFUX3F0F7MLiHzpdqgKiVpDxoYNZVwSsB7ZK2=hQ@mail.gmail.com>
1 sibling, 2 replies; 5+ messages in thread
From: Cosmin Tanislav @ 2022-01-10 22:05 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
---
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;
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 3/3] iio: addac: ad74413r: correct comparator gpio getters mask usage
[not found] ` <CAHp75VezW0DTvjLb6wOOf+skCv5-bDV38ozNaCq1wX+Oekarfw@mail.gmail.com>
@ 2022-01-11 7:26 ` Cosmin Tanislav
0 siblings, 0 replies; 5+ messages in thread
From: Cosmin Tanislav @ 2022-01-11 7:26 UTC (permalink / raw)
To: Andy Shevchenko
Cc: cosmin.tanislav, Lars-Peter Clausen, Michael Hennerich,
Rob Herring, linux-iio, devicetree, linux-kernel, Linus Walleij,
Bartosz Golaszewski, linux-gpio
On 1/11/22 01:12, Andy Shevchenko wrote:
>
>
> On Tuesday, January 11, 2022, Cosmin Tanislav <demonsingur@gmail.com
> <mailto: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.
>
> Fixes: fea251b6a5db ("iio: addac: add AD74413R driver")
>
>
>
> Ss i told you this should go _before_ patch 2.
Sorry, I missed your comment on this.
>
> Signed-off-by: Cosmin Tanislav <cosmin.tanislav@analog.com
> <mailto:cosmin.tanislav@analog.com>>
> ---
> 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;
> --
> 2.34.1
>
>
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 3/3] iio: addac: ad74413r: correct comparator gpio getters mask usage
[not found] ` <CAHp75VckhARFUX3F0F7MLiHzpdqgKiVpDxoYNZVwSsB7ZK2=hQ@mail.gmail.com>
@ 2022-01-11 7:29 ` Cosmin Tanislav
0 siblings, 0 replies; 5+ messages in thread
From: Cosmin Tanislav @ 2022-01-11 7:29 UTC (permalink / raw)
To: Andy Shevchenko
Cc: cosmin.tanislav, Lars-Peter Clausen, Michael Hennerich,
Rob Herring, linux-iio, devicetree, linux-kernel, Linus Walleij,
Bartosz Golaszewski, linux-gpio
On 1/11/22 01:14, Andy Shevchenko wrote:
>
>
> On Tuesday, January 11, 2022, Cosmin Tanislav <demonsingur@gmail.com
> <mailto: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.
>
> Fixes: fea251b6a5db ("iio: addac: add AD74413R driver")
> Signed-off-by: Cosmin Tanislav <cosmin.tanislav@analog.com
> <mailto:cosmin.tanislav@analog.com>>
> ---
> 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];
>
> -
>
>
> This blank line should be kept. Isn’t checkpatch complaining about?
Nope, doesn't seem to, even with the --strict option.
>
> - 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] 5+ messages in thread
end of thread, other threads:[~2022-01-11 7:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 22:05 [PATCH v2 1/3] iio: addac: ad74413r: use ngpio size when iterating over mask Cosmin Tanislav
2022-01-10 22:05 ` [PATCH v2 2/3] iio: addac: ad74413r: for_each_set_bit_from -> for_each_set_bit Cosmin Tanislav
2022-01-10 22:05 ` [PATCH v2 3/3] iio: addac: ad74413r: correct comparator gpio getters mask usage Cosmin Tanislav
[not found] ` <CAHp75VezW0DTvjLb6wOOf+skCv5-bDV38ozNaCq1wX+Oekarfw@mail.gmail.com>
2022-01-11 7:26 ` Cosmin Tanislav
[not found] ` <CAHp75VckhARFUX3F0F7MLiHzpdqgKiVpDxoYNZVwSsB7ZK2=hQ@mail.gmail.com>
2022-01-11 7:29 ` Cosmin Tanislav
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®