Skip to contentSkip to conversation

iio: adc: ad7380: fix sparse warnings

PATCH Applied David Lechner 2 participants 4 messages Jan 29, 2024 – Feb 4, 2024

Subsystems (3)
lore
Share & tools
lore

David Lechner

author reviewer
#0 lore raw

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

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

PATCH v2 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

---

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
index 44b8b18ab213..abd746aef868 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
maintainer Applied
#3 lore raw

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 & !y

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
index 44b8b18ab213..abd746aef868 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;