iio: adc: ad7380: fix sparse warnings
Subsystems (3)
David Lechner
reviewerv2 cover iio: adc: ad7380: fix sparse warnings
This fixes the sparse warnings reported in [1].
[1] https://lore.kernel.org/oe-kbuild-all/[email protected]/
v2 changes:
* fix typo in "iio: adc: ad7380: don't use bool in FIELD_PREP"
David Lechner (2):
iio: adc: ad7380: make ad7380_regmap_config static
iio: adc: ad7380: don't use bool in FIELD_PREP
drivers/iio/adc/ad7380.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
David Lechner
reviewerPATCH v2 1/2 iio: adc: ad7380: make ad7380_regmap_config static
ad7380_regmap_config is not used outside of ad7380.c, so make it static.
Fixes sparse warning:
drivers/iio/adc/ad7380.c:205:28: sparse: sparse: symbol 'ad7380_regmap_config' was not declared. Should it be static?
--- drivers/iio/adc/ad7380.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7380.c +1 -1
@@ -202,7 +202,7 @@ static int ad7380_regmap_reg_read(void *context, unsigned int reg,return 0 ; } -const struct regmap_config ad7380_regmap_config = { +static const struct regmap_config ad7380_regmap_config = { .reg_bits =3 , .val_bits =12 , .reg_read = ad7380_regmap_reg_read,
Signature · 1 line
2.43.0
David Lechner
reviewerPATCH v2 2/2 iio: adc: ad7380: don't use bool in FIELD_PREP
In reply to David LechnerAlthough this technically works, it is better to avoid using bool as a bit value.
Fixes sparse warning:
drivers/iio/adc/ad7380.c:353:34: sparse: sparse: dubious: x & !y
---
v2 changes:
* use correct terinary operator syntax (had typo of : instead of ?)
drivers/iio/adc/ad7380.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ad7380.c +2 -1
@@ -350,7 +350,8 @@ static int ad7380_init(struct ad7380_state *st)/* select internal or external reference voltage */ ret =regmap_update_bits (st->regmap,AD7380_REG_ADDR_CONFIG1 ,AD7380_CONFIG1_REFSEL , -FIELD_PREP (AD7380_CONFIG1_REFSEL , !!st->vref)); +FIELD_PREP (AD7380_CONFIG1_REFSEL , + st->vref ?1 :0 ));if (ret <0 )return ret;
Signature · 1 line
2.43.0
Re: [PATCH v2 2/2] iio: adc: ad7380: don't use bool in FIELD_PREP
Quoted 10 lines · On Mon, 29 Jan 2024 13:56:08 -0600 David Lechner <[email protected]> wrote:
Although this technically works, it is better to avoid using bool as a bit value.
Fixes sparse warning:
drivers/iio/adc/ad7380.c:353:34: sparse: sparse: dubious: x & !yReported-by kernel test robot <[email protected]>Signed-off-by David Lechner <[email protected]>
Applied.
Quoted 22 lines
---
v2 changes:
* use correct terinary operator syntax (had typo of : instead of ?)drivers/iio/adc/ad7380.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iio/adc/ad7380.c +2
-1@@ -350,7 +350,8 @@ static int ad7380_init(struct ad7380_state *st)/* select internal or external reference voltage */ ret =regmap_update_bits (st->regmap,AD7380_REG_ADDR_CONFIG1 ,AD7380_CONFIG1_REFSEL , -FIELD_PREP (AD7380_CONFIG1_REFSEL , !!st->vref)); +FIELD_PREP (AD7380_CONFIG1_REFSEL , + st->vref ?1 :0 ));if (ret <0 )return ret;