> -----Original Message-----
> From: Lars-Peter Clausen [mailto:l...@metafoo.de]
> Sent: Thursday, October 18, 2012 8:21 PM
> To: Kim, Milo
> Cc: c...@mail.ru; Anton Vorontsov; Jonathan Cameron; linux-
> ker...@vger.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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to