Thread (14 messages) 14 messages, 5 authors, 2021-08-14

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

From: Andy Shevchenko <hidden>
Date: 2021-08-11 07:04:28
Also in: linux-devicetree, lkml

On Wed, Aug 11, 2021 at 8:46 AM Mugilraj Dhavachelvan
[off-list ref] wrote:
On Tue, Aug 10, 2021 at 03:49:52PM +0300, Andy Shevchenko wrote:
quoted
On Mon, Aug 9, 2021 at 10:59 AM Mugilraj Dhavachelvan
[off-list ref] wrote:
...
quoted
quoted
+       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.

...
quoted
quoted
+       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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help