[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <A874F61F95741C4A9BA573A70FE3998F641790DF@DQHE02.ent.ti.com>
Date: Thu, 18 Oct 2012 23:03:38 +0000
From: "Kim, Milo" <Milo.Kim@...com>
To: Lars-Peter Clausen <lars@...afoo.de>
CC: "cbou@...l.ru" <cbou@...l.ru>,
Anton Vorontsov <anton.vorontsov@...aro.org>,
Jonathan Cameron <jic23@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 3/3] lp8788-charger: fix wrong ADC conversion
> -----Original Message-----
> From: Lars-Peter Clausen [mailto:lars@...afoo.de]
> Sent: Thursday, October 18, 2012 8:21 PM
> To: Kim, Milo
> Cc: cbou@...l.ru; Anton Vorontsov; Jonathan Cameron; linux-
> kernel@...r.kernel.org
> Subject: Re: [PATCH 3/3] lp8788-charger: fix wrong ADC conversion
> >
> > + ret = iio_read_channel_raw(channel, &raw);
> > + if (ret != IIO_VAL_INT)
> > + return -EINVAL;
> > +
> > ret = iio_read_channel_scale(channel, &scaleint, &scalepart);
> > if (ret != IIO_VAL_INT_PLUS_MICRO)
> > return -EINVAL;
> >
> > /* unit: mV */
> > - *result = (scaleint + scalepart * 1000000) / 1000;
> > + tmp = raw * scaleint + div_u64(raw * scalepart, 1000000L);
> > + *result = (unsigned int)tmp;
>
>
> We now have a function in the IIO core which does the sampling +
> conversion
> in one step: iio_read_channel_processed. This basically allows you to
> reduce
> this function to
>
> return iio_read_channel_processed(channel, result);
I was hesitating it before sending this patch. :)
Currently, LP8788 ADC driver has no iio channel info for PROCESSED.
Thus, I'll add it in the LP8788 ADC driver first.
Then I'll send the patch for lp8788-charger again.
Thanks for your comment!
Best Regards,
Milo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists