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 07:06:43PM +0300, Andy Shevchenko wrote:
> On Wed, Aug 11, 2021 at 11:15 AM Lars-Peter Clausen <lars@xxxxxxxxxx> wrote:
> > On 8/10/21 2:49 PM, Andy Shevchenko 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*()?
> > The data is encoded a sign-magnitude. sign_extend() works for two's
> > complement numbers.
> 
> Good catch!
> I'm wondering if it's a good idea to have a sign_magnitude_to_int()
> helper or so?
>
So, What should I do now?

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