Re: [PATCH 04/12] iio: adc: max9611: Fix misuse of GENMASK macro

From: Joe Perches
Date: Sun Jul 14 2019 - 08:19:39 EST


On Sun, 2019-07-14 at 12:54 +0100, Jonathan Cameron wrote:
> On Tue, 9 Jul 2019 22:04:17 -0700
> Joe Perches <joe@xxxxxxxxxxx> wrote:
>
> > Arguments are supposed to be ordered high then low.
> >
> > Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
>
> Applied to the fixes-togreg branch of iio.git and marked for
> stable etc.

This mask is used in an init function called from a probe.

I don't have this hardware but it looks as if it could
never have worked so I doubt the driver and the hardware
have ever been tested.

Does anyone have this device in actual use?


regval = ret & MAX9611_TEMP_MASK;

if ((regval > MAX9611_TEMP_MAX_POS &&
regval < MAX9611_TEMP_MIN_NEG) ||
regval > MAX9611_TEMP_MAX_NEG) {
dev_err(max9611->dev,
"Invalid value received from ADC 0x%4x: aborting\n",
regval);
return -EIO;
}


> Thanks,
>
> Jonathan
>
> > ---
> > drivers/iio/adc/max9611.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
> > index 917223d5ff5b..0e3c6529fc4c 100644
> > --- a/drivers/iio/adc/max9611.c
> > +++ b/drivers/iio/adc/max9611.c
> > @@ -83,7 +83,7 @@
> > #define MAX9611_TEMP_MAX_POS 0x7f80
> > #define MAX9611_TEMP_MAX_NEG 0xff80
> > #define MAX9611_TEMP_MIN_NEG 0xd980
> > -#define MAX9611_TEMP_MASK GENMASK(7, 15)
> > +#define MAX9611_TEMP_MASK GENMASK(15, 7)
> > #define MAX9611_TEMP_SHIFT 0x07
> > #define MAX9611_TEMP_RAW(_r) ((_r) >> MAX9611_TEMP_SHIFT)
> > #define MAX9611_TEMP_SCALE_NUM 1000000