Re: [PATCH v2 2/2] iio: potentiometer: Add driver support for AD5110

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 11, 2021 at 8:46 AM Mugilraj Dhavachelvan
<dmugil2000@xxxxxxxxx> wrote:
> On Tue, Aug 10, 2021 at 03:49:52PM +0300, Andy Shevchenko wrote:
> > On Mon, Aug 9, 2021 at 10:59 AM Mugilraj Dhavachelvan
> > <dmugil2000@xxxxxxxxx> wrote:

...

> > > +       data->tol = data->cfg->kohms * (val & GENMASK(6, 0)) * 10 / 8;
> > > +       if (!(val & BIT(7)))
> > > +               data->tol *= -1;
> >
> > Shouldn't you simple use corresponding sign_extend*()?
> >
> I'm not able see any sign_extend for 16 bit. Is there any other way?

So, then add it in bitops.h the same way it's done for s32 and s64.

...

> > > +       if (!data->cfg)
> > > +               data->cfg = &ad5110_cfg[i2c_match_id(ad5110_id, client)->driver_data];
> >
> > Not sure this is not a dead code since you are using ->probe_new().
> >
> Even I'm suspecting that and also removing id_table. But I'm not sure of
> it so just left as it is.

I²C ID table is good to have without direct use, but ->probe_new() is
called if and only if there is a compatible string or ACPI ID match.
In such case data->cfg may be NULL if and only if the corresponding
table missed it, but this will be a bug anyway, so the above code will
rather hide the bug. Hence, please remove it.


-- 
With Best Regards,
Andy Shevchenko




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux