* [PATCH 0/2] Change axp20x power drivers to use iio scaled
@ 2024-10-23 18:47 Chris Morgan
2024-10-23 18:47 ` [PATCH 1/2] power: supply: axp20x_usb_power: Use scaled iio_read_channel Chris Morgan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Chris Morgan @ 2024-10-23 18:47 UTC (permalink / raw)
To: linux-pm; +Cc: wens, sre, Chris Morgan
From: Chris Morgan <macromorgan@hotmail.com>
Simplify the axp20x_battery and axp20x_usb_power to use
iio_read_channel_processed_scale() instead of reading the channel and
then applying the scaling factor in an additional step.
Chris Morgan (2):
power: supply: axp20x_usb_power: Use scaled iio_read_channel
power: supply: axp20x_battery: Use scaled iio_read_channel
drivers/power/supply/axp20x_battery.c | 33 +++++++++++++------------
drivers/power/supply/axp20x_usb_power.c | 33 +++++++++++--------------
2 files changed, 32 insertions(+), 34 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] power: supply: axp20x_usb_power: Use scaled iio_read_channel
2024-10-23 18:47 [PATCH 0/2] Change axp20x power drivers to use iio scaled Chris Morgan
@ 2024-10-23 18:47 ` Chris Morgan
2024-10-23 18:48 ` [PATCH 2/2] power: supply: axp20x_battery: " Chris Morgan
2024-11-11 22:13 ` [PATCH 0/2] Change axp20x power drivers to use iio scaled Sebastian Reichel
2 siblings, 0 replies; 4+ messages in thread
From: Chris Morgan @ 2024-10-23 18:47 UTC (permalink / raw)
To: linux-pm; +Cc: wens, sre, Chris Morgan
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_usb_power.c | 33 +++++++++++--------------
1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c
index 2766352ab737..9722912268fe 100644
--- a/drivers/power/supply/axp20x_usb_power.c
+++ b/drivers/power/supply/axp20x_usb_power.c
@@ -220,16 +220,15 @@ static int axp20x_usb_power_get_property(struct power_supply *psy,
return 0;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
if (IS_ENABLED(CONFIG_AXP20X_ADC)) {
- ret = iio_read_channel_processed(power->vbus_v,
- &val->intval);
- if (ret)
- return ret;
-
/*
* IIO framework gives mV but Power Supply framework
* gives uV.
*/
- val->intval *= 1000;
+ ret = iio_read_channel_processed_scale(power->vbus_v,
+ &val->intval, 1000);
+ if (ret)
+ return ret;
+
return 0;
}
@@ -253,16 +252,15 @@ static int axp20x_usb_power_get_property(struct power_supply *psy,
return 0;
case POWER_SUPPLY_PROP_CURRENT_NOW:
if (IS_ENABLED(CONFIG_AXP20X_ADC)) {
- ret = iio_read_channel_processed(power->vbus_i,
- &val->intval);
- if (ret)
- return ret;
-
/*
* IIO framework gives mA but Power Supply framework
* gives uA.
*/
- val->intval *= 1000;
+ ret = iio_read_channel_processed_scale(power->vbus_i,
+ &val->intval, 1000);
+ if (ret)
+ return ret;
+
return 0;
}
@@ -374,16 +372,15 @@ static int axp717_usb_power_get_property(struct power_supply *psy,
break;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
if (IS_ENABLED(CONFIG_AXP20X_ADC)) {
- ret = iio_read_channel_processed(power->vbus_v,
- &val->intval);
- if (ret)
- return ret;
-
/*
* IIO framework gives mV but Power Supply framework
* gives uV.
*/
- val->intval *= 1000;
+ ret = iio_read_channel_processed_scale(power->vbus_v,
+ &val->intval, 1000);
+ if (ret)
+ return ret;
+
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] power: supply: axp20x_battery: Use scaled iio_read_channel
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
2024-11-11 22:13 ` [PATCH 0/2] Change axp20x power drivers to use iio scaled Sebastian Reichel
2 siblings, 0 replies; 4+ messages in thread
From: Chris Morgan @ 2024-10-23 18:48 UTC (permalink / raw)
To: linux-pm; +Cc: wens, sre, Chris Morgan
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Change axp20x power drivers to use iio scaled
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 ` [PATCH 2/2] power: supply: axp20x_battery: " Chris Morgan
@ 2024-11-11 22:13 ` Sebastian Reichel
2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2024-11-11 22:13 UTC (permalink / raw)
To: linux-pm, Chris Morgan; +Cc: wens, sre, Chris Morgan
On Wed, 23 Oct 2024 13:47:58 -0500, Chris Morgan wrote:
> From: Chris Morgan <macromorgan@hotmail.com>
>
> Simplify the axp20x_battery and axp20x_usb_power to use
> iio_read_channel_processed_scale() instead of reading the channel and
> then applying the scaling factor in an additional step.
>
> Chris Morgan (2):
> power: supply: axp20x_usb_power: Use scaled iio_read_channel
> power: supply: axp20x_battery: Use scaled iio_read_channel
>
> [...]
Applied, thanks!
[1/2] power: supply: axp20x_usb_power: Use scaled iio_read_channel
commit: 9fdd97d63fe2be2ab890240cce0a5790e0ef9877
[2/2] power: supply: axp20x_battery: Use scaled iio_read_channel
commit: 1d3db2d99fbaa5020543bd1dc4f365faeffae4ed
Best regards,
--
Sebastian Reichel <sebastian.reichel@collabora.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-11 22:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/2] power: supply: axp20x_battery: " Chris Morgan
2024-11-11 22:13 ` [PATCH 0/2] Change axp20x power drivers to use iio scaled Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).