diff mbox series

[v2,2/2] iio: adc: ad7380: don't use bool in FIELD_PREP

Message ID 20240129195611.701611-3-dlechner@baylibre.com (mailing list archive)
State Accepted
Headers show
Series iio: adc: ad7380: fix sparse warnings | expand

Commit Message

David Lechner Jan. 29, 2024, 7:56 p.m. UTC
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 <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202401280629.5kknB57C-lkp@intel.com/
Signed-off-by: David Lechner <dlechner@baylibre.com>
---

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(-)

Comments

Jonathan Cameron Feb. 4, 2024, 2:46 p.m. UTC | #1
On Mon, 29 Jan 2024 13:56:08 -0600
David Lechner <dlechner@baylibre.com> 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 <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202401280629.5kknB57C-lkp@intel.com/
> Signed-off-by: David Lechner <dlechner@baylibre.com>
Applied.
> ---
> 
> 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(-)
> 
> diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
> index 44b8b18ab213..abd746aef868 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;
>
diff mbox series

Patch

diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
index 44b8b18ab213..abd746aef868 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;