From: Sebastian Reichel <sre@kernel.org> To: Linus Walleij <linus.walleij@linaro.org> Cc: Lee Jones <lee.jones@linaro.org>, Jonathan Cameron <jic23@kernel.org>, linux-iio@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>, Mboumba Cedric Madianga <cedric.madianga@gmail.com>, linux-pm@vger.kernel.org, linux-hwmon@vger.kernel.org Subject: Re: [PATCH 1/7] power: supply: ab8500_btemp: convert to IIO ADC Date: Thu, 12 Jan 2017 04:02:40 +0100 [thread overview] Message-ID: <20170112030240.5vzyut7vqbtqnnvf@earth> (raw) In-Reply-To: <20170110234745.29691-2-linus.walleij@linaro.org> [-- Attachment #1: Type: text/plain, Size: 4404 bytes --] Hi, On Wed, Jan 11, 2017 at 12:47:39AM +0100, Linus Walleij wrote: > This switches the AB8500 battery temperature driver to using > the standard IIO ADC channel lookup and conversion routines. > > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-By: Sebastian Reichel <sre@kernel.org> -- Sebastian > drivers/power/supply/ab8500_btemp.c | 41 ++++++++++++++++++++++++++----------- > 1 file changed, 29 insertions(+), 12 deletions(-) > > diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c > index 6ffdc18f2599..61161db5cffa 100644 > --- a/drivers/power/supply/ab8500_btemp.c > +++ b/drivers/power/supply/ab8500_btemp.c > @@ -26,7 +26,7 @@ > #include <linux/mfd/abx500.h> > #include <linux/mfd/abx500/ab8500.h> > #include <linux/mfd/abx500/ab8500-bm.h> > -#include <linux/mfd/abx500/ab8500-gpadc.h> > +#include <linux/iio/consumer.h> > > #define VTVOUT_V 1800 > > @@ -79,7 +79,8 @@ struct ab8500_btemp_ranges { > * @bat_temp: Dispatched battery temperature in degree Celcius > * @prev_bat_temp Last measured battery temperature in degree Celcius > * @parent: Pointer to the struct ab8500 > - * @gpadc: Pointer to the struct gpadc > + * @adc_btemp_ball: ADC channel for the battery ball temperature > + * @adc_bat_ctrl: ADC channel for the battery control > * @fg: Pointer to the struct fg > * @bm: Platform specific battery management information > * @btemp_psy: Structure for BTEMP specific battery properties > @@ -96,7 +97,8 @@ struct ab8500_btemp { > int bat_temp; > int prev_bat_temp; > struct ab8500 *parent; > - struct ab8500_gpadc *gpadc; > + struct iio_channel *btemp_ball; > + struct iio_channel *bat_ctrl; > struct ab8500_fg *fg; > struct abx500_bm_data *bm; > struct power_supply *btemp_psy; > @@ -180,13 +182,13 @@ static int ab8500_btemp_batctrl_volt_to_res(struct ab8500_btemp *di, > */ > static int ab8500_btemp_read_batctrl_voltage(struct ab8500_btemp *di) > { > - int vbtemp; > + int vbtemp, ret; > static int prev; > > - vbtemp = ab8500_gpadc_convert(di->gpadc, BAT_CTRL); > - if (vbtemp < 0) { > + ret = iio_read_channel_processed(di->bat_ctrl, &vbtemp); > + if (ret < 0) { > dev_err(di->dev, > - "%s gpadc conversion failed, using previous value", > + "%s ADC conversion failed, using previous value", > __func__); > return prev; > } > @@ -501,7 +503,7 @@ static int ab8500_btemp_res_to_temp(struct ab8500_btemp *di, > */ > static int ab8500_btemp_measure_temp(struct ab8500_btemp *di) > { > - int temp; > + int temp, ret; > static int prev; > int rbat, rntc, vntc; > u8 id; > @@ -526,10 +528,10 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di) > di->bm->bat_type[id].r_to_t_tbl, > di->bm->bat_type[id].n_temp_tbl_elements, rbat); > } else { > - vntc = ab8500_gpadc_convert(di->gpadc, BTEMP_BALL); > - if (vntc < 0) { > + ret = iio_read_channel_processed(di->btemp_ball, &vntc); > + if (ret < 0) { > dev_err(di->dev, > - "%s gpadc conversion failed," > + "%s ADC conversion failed," > " using previous value\n", __func__); > return prev; > } > @@ -1085,7 +1087,22 @@ static int ab8500_btemp_probe(struct platform_device *pdev) > /* get parent data */ > di->dev = &pdev->dev; > di->parent = dev_get_drvdata(pdev->dev.parent); > - di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); > + > + /* Get ADC channels */ > + di->btemp_ball = devm_iio_channel_get(&pdev->dev, "btemp_ball"); > + if (IS_ERR(di->btemp_ball)) { > + if (PTR_ERR(di->btemp_ball) == -ENODEV) > + return -EPROBE_DEFER; > + dev_err(&pdev->dev, "failed to get BTEMP BALL ADC channel\n"); > + return PTR_ERR(di->btemp_ball); > + } > + di->bat_ctrl = devm_iio_channel_get(&pdev->dev, "bat_ctrl"); > + if (IS_ERR(di->bat_ctrl)) { > + if (PTR_ERR(di->bat_ctrl) == -ENODEV) > + return -EPROBE_DEFER; > + dev_err(&pdev->dev, "failed to get BAT CTRL ADC channel\n"); > + return PTR_ERR(di->bat_ctrl); > + } > > di->initialized = false; > > -- > 2.9.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Sebastian Reichel <sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> To: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Cc: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>, Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>, linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>, Mboumba Cedric Madianga <cedric.madianga-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>, linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-hwmon-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Subject: Re: [PATCH 1/7] power: supply: ab8500_btemp: convert to IIO ADC Date: Thu, 12 Jan 2017 04:02:40 +0100 [thread overview] Message-ID: <20170112030240.5vzyut7vqbtqnnvf@earth> (raw) In-Reply-To: <20170110234745.29691-2-linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> [-- Attachment #1: Type: text/plain, Size: 4486 bytes --] Hi, On Wed, Jan 11, 2017 at 12:47:39AM +0100, Linus Walleij wrote: > This switches the AB8500 battery temperature driver to using > the standard IIO ADC channel lookup and conversion routines. > > Signed-off-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Acked-By: Sebastian Reichel <sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> -- Sebastian > drivers/power/supply/ab8500_btemp.c | 41 ++++++++++++++++++++++++++----------- > 1 file changed, 29 insertions(+), 12 deletions(-) > > diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c > index 6ffdc18f2599..61161db5cffa 100644 > --- a/drivers/power/supply/ab8500_btemp.c > +++ b/drivers/power/supply/ab8500_btemp.c > @@ -26,7 +26,7 @@ > #include <linux/mfd/abx500.h> > #include <linux/mfd/abx500/ab8500.h> > #include <linux/mfd/abx500/ab8500-bm.h> > -#include <linux/mfd/abx500/ab8500-gpadc.h> > +#include <linux/iio/consumer.h> > > #define VTVOUT_V 1800 > > @@ -79,7 +79,8 @@ struct ab8500_btemp_ranges { > * @bat_temp: Dispatched battery temperature in degree Celcius > * @prev_bat_temp Last measured battery temperature in degree Celcius > * @parent: Pointer to the struct ab8500 > - * @gpadc: Pointer to the struct gpadc > + * @adc_btemp_ball: ADC channel for the battery ball temperature > + * @adc_bat_ctrl: ADC channel for the battery control > * @fg: Pointer to the struct fg > * @bm: Platform specific battery management information > * @btemp_psy: Structure for BTEMP specific battery properties > @@ -96,7 +97,8 @@ struct ab8500_btemp { > int bat_temp; > int prev_bat_temp; > struct ab8500 *parent; > - struct ab8500_gpadc *gpadc; > + struct iio_channel *btemp_ball; > + struct iio_channel *bat_ctrl; > struct ab8500_fg *fg; > struct abx500_bm_data *bm; > struct power_supply *btemp_psy; > @@ -180,13 +182,13 @@ static int ab8500_btemp_batctrl_volt_to_res(struct ab8500_btemp *di, > */ > static int ab8500_btemp_read_batctrl_voltage(struct ab8500_btemp *di) > { > - int vbtemp; > + int vbtemp, ret; > static int prev; > > - vbtemp = ab8500_gpadc_convert(di->gpadc, BAT_CTRL); > - if (vbtemp < 0) { > + ret = iio_read_channel_processed(di->bat_ctrl, &vbtemp); > + if (ret < 0) { > dev_err(di->dev, > - "%s gpadc conversion failed, using previous value", > + "%s ADC conversion failed, using previous value", > __func__); > return prev; > } > @@ -501,7 +503,7 @@ static int ab8500_btemp_res_to_temp(struct ab8500_btemp *di, > */ > static int ab8500_btemp_measure_temp(struct ab8500_btemp *di) > { > - int temp; > + int temp, ret; > static int prev; > int rbat, rntc, vntc; > u8 id; > @@ -526,10 +528,10 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di) > di->bm->bat_type[id].r_to_t_tbl, > di->bm->bat_type[id].n_temp_tbl_elements, rbat); > } else { > - vntc = ab8500_gpadc_convert(di->gpadc, BTEMP_BALL); > - if (vntc < 0) { > + ret = iio_read_channel_processed(di->btemp_ball, &vntc); > + if (ret < 0) { > dev_err(di->dev, > - "%s gpadc conversion failed," > + "%s ADC conversion failed," > " using previous value\n", __func__); > return prev; > } > @@ -1085,7 +1087,22 @@ static int ab8500_btemp_probe(struct platform_device *pdev) > /* get parent data */ > di->dev = &pdev->dev; > di->parent = dev_get_drvdata(pdev->dev.parent); > - di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); > + > + /* Get ADC channels */ > + di->btemp_ball = devm_iio_channel_get(&pdev->dev, "btemp_ball"); > + if (IS_ERR(di->btemp_ball)) { > + if (PTR_ERR(di->btemp_ball) == -ENODEV) > + return -EPROBE_DEFER; > + dev_err(&pdev->dev, "failed to get BTEMP BALL ADC channel\n"); > + return PTR_ERR(di->btemp_ball); > + } > + di->bat_ctrl = devm_iio_channel_get(&pdev->dev, "bat_ctrl"); > + if (IS_ERR(di->bat_ctrl)) { > + if (PTR_ERR(di->bat_ctrl) == -ENODEV) > + return -EPROBE_DEFER; > + dev_err(&pdev->dev, "failed to get BAT CTRL ADC channel\n"); > + return PTR_ERR(di->bat_ctrl); > + } > > di->initialized = false; > > -- > 2.9.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-01-12 3:03 UTC|newest] Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-01-10 23:47 [PATCH 0/7] mfd/iio: move the AB8500 GPADC driver to IIO Linus Walleij 2017-01-10 23:47 ` Linus Walleij 2017-01-10 23:47 ` [PATCH 1/7] power: supply: ab8500_btemp: convert to IIO ADC Linus Walleij 2017-01-10 23:47 ` Linus Walleij 2017-01-12 3:02 ` Sebastian Reichel [this message] 2017-01-12 3:02 ` Sebastian Reichel 2017-01-12 6:13 ` kbuild test robot 2017-01-12 6:13 ` kbuild test robot 2017-01-14 14:54 ` Jonathan Cameron 2017-01-14 14:54 ` Jonathan Cameron 2017-01-10 23:47 ` [PATCH 2/7] power: supply: ab8500_charger: " Linus Walleij 2017-01-12 3:03 ` Sebastian Reichel 2017-01-14 14:56 ` Jonathan Cameron 2017-01-10 23:47 ` [PATCH 3/7] power: supply: ab8500_fg: " Linus Walleij 2017-01-12 3:03 ` Sebastian Reichel 2017-01-14 14:58 ` Jonathan Cameron 2017-01-10 23:47 ` [PATCH 4/7] hwmon: ab8500: " Linus Walleij 2017-01-12 1:40 ` Guenter Roeck 2017-01-12 1:40 ` Guenter Roeck 2017-01-14 15:00 ` Jonathan Cameron 2017-01-14 15:00 ` Jonathan Cameron 2017-01-10 23:47 ` [PATCH 5/7] mfd: ab8500: augment DT bindings Linus Walleij 2017-01-10 23:47 ` Linus Walleij 2017-01-13 14:55 ` Lee Jones 2017-01-10 23:47 ` [PATCH 6/7] mfd/iio: move the AB8500 GPADC to IIO Linus Walleij 2017-01-13 14:56 ` Lee Jones 2017-01-13 14:56 ` Lee Jones 2017-01-14 15:57 ` Jonathan Cameron 2017-01-10 23:47 ` [PATCH 7/7] ARM: dts: ux500: declare GPADC IIO ADC channels Linus Walleij 2017-01-12 3:04 ` [PATCH 0/7] mfd/iio: move the AB8500 GPADC driver to IIO Sebastian Reichel 2017-01-14 14:48 ` Jonathan Cameron
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20170112030240.5vzyut7vqbtqnnvf@earth \ --to=sre@kernel.org \ --cc=cedric.madianga@gmail.com \ --cc=jic23@kernel.org \ --cc=lee.jones@linaro.org \ --cc=linus.walleij@linaro.org \ --cc=linux-hwmon@vger.kernel.org \ --cc=linux-iio@vger.kernel.org \ --cc=linux-pm@vger.kernel.org \ --cc=linux@roeck-us.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.