From: Chris Morgan <macroalpha82@gmail.com>
To: linux-pm@vger.kernel.org
Cc: wens@csie.org, sre@kernel.org, Chris Morgan <macromorgan@hotmail.com>
Subject: [PATCH 2/2] power: supply: axp20x_battery: Use scaled iio_read_channel
Date: Wed, 23 Oct 2024 13:48:00 -0500 [thread overview]
Message-ID: <20241023184800.109376-3-macroalpha82@gmail.com> (raw)
In-Reply-To: <20241023184800.109376-1-macroalpha82@gmail.com>
From: Chris Morgan <macromorgan@hotmail.com>
Change iio_read_channel_processed to iio_read_channel_processed_scale
where appropriate.
Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
---
drivers/power/supply/axp20x_battery.c | 33 ++++++++++++++-------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
index f71cc90fea12..fa27195f074e 100644
--- a/drivers/power/supply/axp20x_battery.c
+++ b/drivers/power/supply/axp20x_battery.c
@@ -354,17 +354,18 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
if (ret)
return ret;
+ /* IIO framework gives mA but Power Supply framework gives uA */
if (reg & AXP20X_PWR_STATUS_BAT_CHARGING) {
- ret = iio_read_channel_processed(axp20x_batt->batt_chrg_i, &val->intval);
+ ret = iio_read_channel_processed_scale(axp20x_batt->batt_chrg_i,
+ &val->intval, 1000);
} else {
- ret = iio_read_channel_processed(axp20x_batt->batt_dischrg_i, &val1);
+ ret = iio_read_channel_processed_scale(axp20x_batt->batt_dischrg_i,
+ &val1, 1000);
val->intval = -val1;
}
if (ret)
return ret;
- /* IIO framework gives mA but Power Supply framework gives uA */
- val->intval *= 1000;
break;
case POWER_SUPPLY_PROP_CAPACITY:
@@ -406,13 +407,12 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
break;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
- ret = iio_read_channel_processed(axp20x_batt->batt_v,
- &val->intval);
+ /* IIO framework gives mV but Power Supply framework gives uV */
+ ret = iio_read_channel_processed_scale(axp20x_batt->batt_v,
+ &val->intval, 1000);
if (ret)
return ret;
- /* IIO framework gives mV but Power Supply framework gives uV */
- val->intval *= 1000;
break;
default:
@@ -519,13 +519,15 @@ static int axp717_battery_get_prop(struct power_supply *psy,
* The offset of this value is currently unknown and is
* not documented in the datasheet. Based on
* observation it's assumed to be somewhere around
- * 450ma. I will leave the value raw for now.
+ * 450ma. I will leave the value raw for now. Note that
+ * IIO framework gives mA but Power Supply framework
+ * gives uA.
*/
- ret = iio_read_channel_processed(axp20x_batt->batt_chrg_i, &val->intval);
+ ret = iio_read_channel_processed_scale(axp20x_batt->batt_chrg_i,
+ &val->intval, 1000);
if (ret)
return ret;
- /* IIO framework gives mA but Power Supply framework gives uA */
- val->intval *= 1000;
+
return 0;
case POWER_SUPPLY_PROP_CAPACITY:
@@ -564,13 +566,12 @@ static int axp717_battery_get_prop(struct power_supply *psy,
return 0;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
- ret = iio_read_channel_processed(axp20x_batt->batt_v,
- &val->intval);
+ /* IIO framework gives mV but Power Supply framework gives uV */
+ ret = iio_read_channel_processed_scale(axp20x_batt->batt_v,
+ &val->intval, 1000);
if (ret)
return ret;
- /* IIO framework gives mV but Power Supply framework gives uV */
- val->intval *= 1000;
return 0;
case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT:
--
2.43.0
next prev parent reply other threads:[~2024-10-23 18:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-23 18:47 [PATCH 0/2] Change axp20x power drivers to use iio scaled Chris Morgan
2024-10-23 18:47 ` [PATCH 1/2] power: supply: axp20x_usb_power: Use scaled iio_read_channel Chris Morgan
2024-10-23 18:48 ` Chris Morgan [this message]
2024-11-11 22:13 ` [PATCH 0/2] Change axp20x power drivers to use iio scaled Sebastian Reichel
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=20241023184800.109376-3-macroalpha82@gmail.com \
--to=macroalpha82@gmail.com \
--cc=linux-pm@vger.kernel.org \
--cc=macromorgan@hotmail.com \
--cc=sre@kernel.org \
--cc=wens@csie.org \
/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: link
Be 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.