diff mbox series

[v3,4/6] iio: adc: mp2629: restrict input voltage mask for mp2629

Message ID 20220615145357.2370044-5-sravanhome@gmail.com
State Superseded
Headers show
Series Add support for mp2733 battery charger | expand

Commit Message

Saravanan Sekar June 15, 2022, 2:53 p.m. UTC
Add support for mp2733 which is updated version of mp2629
with a higher range of input voltage.

Signed-off-by: Saravanan Sekar <sravanhome@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/iio/adc/mp2629_adc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jonathan Cameron June 18, 2022, 4:19 p.m. UTC | #1
On Wed, 15 Jun 2022 16:53:55 +0200
Saravanan Sekar <sravanhome@gmail.com> wrote:

> Add support for mp2733 which is updated version of mp2629
> with a higher range of input voltage.
> 
> Signed-off-by: Saravanan Sekar <sravanhome@gmail.com>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

I'm assuming Lee will pick this up via mfd. Shout if you want
to do something else.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/mp2629_adc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c
> index e7fbfe92e884..28d048eefce3 100644
> --- a/drivers/iio/adc/mp2629_adc.c
> +++ b/drivers/iio/adc/mp2629_adc.c
> @@ -64,6 +64,7 @@ static int mp2629_read_raw(struct iio_dev *indio_dev,
>  			int *val, int *val2, long mask)
>  {
>  	struct mp2629_adc *info = iio_priv(indio_dev);
> +	struct mp2629_data *ddata = dev_get_drvdata(info->dev);
>  	unsigned int rval;
>  	int ret;
>  
> @@ -73,8 +74,10 @@ static int mp2629_read_raw(struct iio_dev *indio_dev,
>  		if (ret)
>  			return ret;
>  
> -		if (chan->channel == MP2629_INPUT_VOLT)
> +		if (chan->channel == MP2629_INPUT_VOLT &&
> +		    ddata->chip_id == CHIP_ID_MP2629)
>  			rval &= GENMASK(6, 0);
> +
>  		*val = rval;
>  		return IIO_VAL_INT;
>
diff mbox series

Patch

diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c
index e7fbfe92e884..28d048eefce3 100644
--- a/drivers/iio/adc/mp2629_adc.c
+++ b/drivers/iio/adc/mp2629_adc.c
@@ -64,6 +64,7 @@  static int mp2629_read_raw(struct iio_dev *indio_dev,
 			int *val, int *val2, long mask)
 {
 	struct mp2629_adc *info = iio_priv(indio_dev);
+	struct mp2629_data *ddata = dev_get_drvdata(info->dev);
 	unsigned int rval;
 	int ret;
 
@@ -73,8 +74,10 @@  static int mp2629_read_raw(struct iio_dev *indio_dev,
 		if (ret)
 			return ret;
 
-		if (chan->channel == MP2629_INPUT_VOLT)
+		if (chan->channel == MP2629_INPUT_VOLT &&
+		    ddata->chip_id == CHIP_ID_MP2629)
 			rval &= GENMASK(6, 0);
+
 		*val = rval;
 		return IIO_VAL_INT;