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(-)
--
2.43.0
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
Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: David Lechner <[email protected]>
---
drivers/iio/adc/ad7380.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
index 44b8b18ab213..a4aa0db47720 100644
--- a/drivers/iio/adc/ad7380.c
+++ b/drivers/iio/adc/ad7380.c
@@ -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;
--
2.43.0
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?
Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: David Lechner <[email protected]>
---
drivers/iio/adc/ad7380.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
index 80712aaa9548..44b8b18ab213 100644
--- a/drivers/iio/adc/ad7380.c
+++ b/drivers/iio/adc/ad7380.c
@@ -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,
--
2.43.0
On Mon, Jan 29, 2024 at 11:43 AM 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
>
> Reported-by: kernel test robot <[email protected]>
> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> Signed-off-by: David Lechner <[email protected]>
> ---
> drivers/iio/adc/ad7380.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
> index 44b8b18ab213..a4aa0db47720 100644
> --- a/drivers/iio/adc/ad7380.c
> +++ b/drivers/iio/adc/ad7380.c
> @@ -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.
> if (ret < 0)
> return ret;
>
> --
> 2.43.0
>
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?
>
> Reported-by: kernel test robot <[email protected]>
> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> Signed-off-by: David Lechner <[email protected]>
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.
> ---
> drivers/iio/adc/ad7380.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
> index 80712aaa9548..44b8b18ab213 100644
> --- a/drivers/iio/adc/ad7380.c
> +++ b/drivers/iio/adc/ad7380.c
> @@ -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,