linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] power/supply: ingenic-battery: Don't change scale if there's only one
@ 2019-07-23  2:45 Paul Cercueil
  2019-09-02 18:57 ` Sebastian Reichel
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Cercueil @ 2019-07-23  2:45 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: od, Artur Rojek, linux-pm, linux-kernel, Paul Cercueil, stable

The ADC in the JZ4740 can work either in high-precision mode with a 2.5V
range, or in low-precision mode with a 7.5V range. The code in place in
this driver will select the proper scale according to the maximum
voltage of the battery.

The JZ4770 however only has one mode, with a 6.6V range. If only one
scale is available, there's no need to change it (and nothing to change
it to), and trying to do so will fail with -EINVAL.

Fixes commit fb24ccfbe1e0 ("power: supply: add Ingenic JZ47xx battery
driver.")

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Cc: stable@vger.kernel.org
---
 drivers/power/supply/ingenic-battery.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/power/supply/ingenic-battery.c b/drivers/power/supply/ingenic-battery.c
index 35816d4b3012..5a53057b4f64 100644
--- a/drivers/power/supply/ingenic-battery.c
+++ b/drivers/power/supply/ingenic-battery.c
@@ -80,6 +80,10 @@ static int ingenic_battery_set_scale(struct ingenic_battery *bat)
 	if (ret != IIO_AVAIL_LIST || scale_type != IIO_VAL_FRACTIONAL_LOG2)
 		return -EINVAL;
 
+	/* Only one (fractional) entry - nothing to change */
+	if (scale_len == 2)
+		return 0;
+
 	max_mV = bat->info.voltage_max_design_uv / 1000;
 
 	for (i = 0; i < scale_len; i += 2) {
-- 
2.21.0.593.g511ec345e18


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] power/supply: ingenic-battery: Don't change scale if there's only one
  2019-07-23  2:45 [PATCH] power/supply: ingenic-battery: Don't change scale if there's only one Paul Cercueil
@ 2019-09-02 18:57 ` Sebastian Reichel
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2019-09-02 18:57 UTC (permalink / raw)
  To: Paul Cercueil, Artur Rojek; +Cc: od, linux-pm, linux-kernel, stable

[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]

Hi,

On Mon, Jul 22, 2019 at 10:45:54PM -0400, Paul Cercueil wrote:
> The ADC in the JZ4740 can work either in high-precision mode with a 2.5V
> range, or in low-precision mode with a 7.5V range. The code in place in
> this driver will select the proper scale according to the maximum
> voltage of the battery.
> 
> The JZ4770 however only has one mode, with a 6.6V range. If only one
> scale is available, there's no need to change it (and nothing to change
> it to), and trying to do so will fail with -EINVAL.
> 
> Fixes commit fb24ccfbe1e0 ("power: supply: add Ingenic JZ47xx battery
> driver.")

There is a standard format for this. It should be

Fixes: fb24ccfbe1e0 ("power: supply: add Ingenic JZ47xx battery driver.")

> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> Cc: stable@vger.kernel.org

Also it would be nice to have an Acked-by from Artur.

-- Sebastian

>  drivers/power/supply/ingenic-battery.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/power/supply/ingenic-battery.c b/drivers/power/supply/ingenic-battery.c
> index 35816d4b3012..5a53057b4f64 100644
> --- a/drivers/power/supply/ingenic-battery.c
> +++ b/drivers/power/supply/ingenic-battery.c
> @@ -80,6 +80,10 @@ static int ingenic_battery_set_scale(struct ingenic_battery *bat)
>  	if (ret != IIO_AVAIL_LIST || scale_type != IIO_VAL_FRACTIONAL_LOG2)
>  		return -EINVAL;
>  
> +	/* Only one (fractional) entry - nothing to change */
> +	if (scale_len == 2)
> +		return 0;
> +
>  	max_mV = bat->info.voltage_max_design_uv / 1000;
>  
>  	for (i = 0; i < scale_len; i += 2) {
> -- 
> 2.21.0.593.g511ec345e18
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-02 18:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-23  2:45 [PATCH] power/supply: ingenic-battery: Don't change scale if there's only one Paul Cercueil
2019-09-02 18:57 ` 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).