lkml.org 
[lkml]   [2020]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/5] iio: adc: mp2629: Add support for mp2629 ADC driver
On Thu, Mar 12, 2020 at 06:26:47PM +0100, Saravanan Sekar wrote:
> Add support for 8-bit resolution ADC readings for input power
> supply and battery charging measurement. Provides voltage, current
> readings to mp2629 power supply driver.

...

> + struct mp2629_info *info = adc_info->info;
> + unsigned int rval;
> + int ret;
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + ret = mp2629_get_value(info->regmap, chan->address, &rval);
> + if (ret < 0)
> + return ret;
> +
> + if (chan->address == MP2629_INPUT_VOLT)
> + rval &= 0x7f;
> + *val = rval;
> + return IIO_VAL_INT;
> +
> + case IIO_CHAN_INFO_SCALE:
> + switch (chan->channel) {
> + case MP2629_BATT_VOLT:
> + case MP2629_SYSTEM_VOLT:
> + *val = 20;
> + return IIO_VAL_INT;
> +
> + case MP2629_INPUT_VOLT:
> + *val = 60;
> + return IIO_VAL_INT;
> +
> + case MP2629_BATT_CURRENT:
> + *val = 175;
> + *val2 = 10;
> + return IIO_VAL_FRACTIONAL;
> +
> + case MP2629_INPUT_CURRENT:
> + *val = 133;
> + *val2 = 10;
> + return IIO_VAL_FRACTIONAL;
> + }
> + break;
> +
> + default:

> + ret = -EINVAL;
> + break;

return -EINVAL;

> + }
> +

> + return ret;

return 0;
?

What is default case for wrong channel in INFO_SCALE?

> +}

...

> +static const struct of_device_id mp2629_adc_of_match[] = {
> + { .compatible = "mps,mp2629_adc"},

> + {},

No comma needed.

> +};

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2020-03-12 18:54    [W:0.056 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site