Skip to contentSkip to conversation

iio: adc: ad7380: fix sparse warnings

PATCH Superseded David Lechner 2 participants 5 messages Jan 29, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

David Lechner

author reviewer
#0 lore raw

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]/

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
author reviewer
#1 lore raw

PATCH 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
index 80712aaa9548..44b8b18ab213 100644
@@ -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
maintainer
#2 lore raw

Re: [PATCH 1/2] iio: adc: ad7380: make ad7380_regmap_config static

Quoted 10 lines · On Mon, 29 Jan 2024 11:41:49 -0600 David Lechner <[email protected]> wrote:

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?

I saw the report of this one and squished it in the original patch.

The second one I decide was a false positive so could wait a bit longer. Still nice to get rid of that warning though.

Quoted 17 lines
---
 drivers/iio/adc/ad7380.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7380.c +1 -1
index 80712aaa9548..44b8b18ab213 100644
@@ -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,
author reviewer
#3 lore raw

PATCH 2/2 iio: adc: ad7380: don't use bool in FIELD_PREP

In reply to David Lechner

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 & !y
---
 drivers/iio/adc/ad7380.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ad7380.c +2 -1
index 44b8b18ab213..a4aa0db47720 100644
@@ -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
author reviewer
#4 lore raw

Re: [PATCH 2/2] iio: adc: ad7380: don't use bool in FIELD_PREP

Quoted 20 lines · David Lechner

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 & !y
---
 drivers/iio/adc/ad7380.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ad7380.c +0 -0
index 44b8b18ab213..a4aa0db47720 100644

drivers/iio/adc/ad7380.c static int ad7380_init(struct ad7380_state *st) · line 354

Quoted 6 lines
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));

Somehow managed to introduce a typo between testing and sending. :-(

Will send a v2 with the fix.

Quoted 6 lines
drivers/iio/adc/ad7380.c +0 -1
        if (ret < 0)
                return ret;
 
--

2.43.0