linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] power: supply: lego_ev3_battery improvements
@ 2018-07-20 20:19 David Lechner
  2018-07-20 20:19 ` [PATCH 1/2] power: supply: lego_ev3_battery: Don't ignore iio_read_channel_processed() return value David Lechner
  2018-07-20 20:19 ` [PATCH 2/2] power: supply: lego_ev3_battery: fix Vce offset David Lechner
  0 siblings, 2 replies; 5+ messages in thread
From: David Lechner @ 2018-07-20 20:19 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: David Lechner, linux-pm, linux-kernel

This series improves error handling and accuracy of the LEGO MINDSTORMS EV3
battery driver.

David Lechner (2):
  power: supply: lego_ev3_battery: Don't ignore
    iio_read_channel_processed() return value
  power: supply: lego_ev3_battery: fix Vce offset

 drivers/power/supply/lego_ev3_battery.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

-- 
2.17.1


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

* [PATCH 1/2] power: supply: lego_ev3_battery: Don't ignore iio_read_channel_processed() return value
  2018-07-20 20:19 [PATCH 0/2] power: supply: lego_ev3_battery improvements David Lechner
@ 2018-07-20 20:19 ` David Lechner
  2018-07-22 22:02   ` Sebastian Reichel
  2018-07-20 20:19 ` [PATCH 2/2] power: supply: lego_ev3_battery: fix Vce offset David Lechner
  1 sibling, 1 reply; 5+ messages in thread
From: David Lechner @ 2018-07-20 20:19 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: David Lechner, linux-pm, linux-kernel

This changes the LEGO MINDSTORMS EV3 power supply driver to return an
error if iio_read_channel_processed() fails.

Signed-off-by: David Lechner <david@lechnology.com>
---
 drivers/power/supply/lego_ev3_battery.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/lego_ev3_battery.c b/drivers/power/supply/lego_ev3_battery.c
index 7b993d669f7f..6e3b3e384172 100644
--- a/drivers/power/supply/lego_ev3_battery.c
+++ b/drivers/power/supply/lego_ev3_battery.c
@@ -39,7 +39,7 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,
 					 union power_supply_propval *val)
 {
 	struct lego_ev3_battery *batt = power_supply_get_drvdata(psy);
-	int val2;
+	int ret, val2;
 
 	switch (psp) {
 	case POWER_SUPPLY_PROP_TECHNOLOGY:
@@ -47,11 +47,18 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,
 		break;
 	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
 		/* battery voltage is iio channel * 2 + Vce of transistor */
-		iio_read_channel_processed(batt->iio_v, &val->intval);
+		ret = iio_read_channel_processed(batt->iio_v, &val->intval);
+		if (ret)
+			return ret;
+
 		val->intval *= 2000;
 		val->intval += 200000;
+
 		/* plus adjust for shunt resistor drop */
-		iio_read_channel_processed(batt->iio_i, &val2);
+		ret = iio_read_channel_processed(batt->iio_i, &val2);
+		if (ret)
+			return ret;
+
 		val2 *= 1000;
 		val2 /= 15;
 		val->intval += val2;
@@ -64,7 +71,10 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,
 		break;
 	case POWER_SUPPLY_PROP_CURRENT_NOW:
 		/* battery current is iio channel / 15 / 0.05 ohms */
-		iio_read_channel_processed(batt->iio_i, &val->intval);
+		ret = iio_read_channel_processed(batt->iio_i, &val->intval);
+		if (ret)
+			return ret;
+
 		val->intval *= 20000;
 		val->intval /= 15;
 		break;
-- 
2.17.1


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

* [PATCH 2/2] power: supply: lego_ev3_battery: fix Vce offset
  2018-07-20 20:19 [PATCH 0/2] power: supply: lego_ev3_battery improvements David Lechner
  2018-07-20 20:19 ` [PATCH 1/2] power: supply: lego_ev3_battery: Don't ignore iio_read_channel_processed() return value David Lechner
@ 2018-07-20 20:19 ` David Lechner
  2018-07-22 22:02   ` Sebastian Reichel
  1 sibling, 1 reply; 5+ messages in thread
From: David Lechner @ 2018-07-20 20:19 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: David Lechner, linux-pm, linux-kernel

This fixes the value that accounts for the Vce of a transistor in the
LEGO MINDSTORMS EV3 power supply driver. The old value (200mV) was the
max value from the data sheet. After testing, the actual value has been
found to be 50mV. By using 50mV we get a more accurate voltage
indication.

Signed-off-by: David Lechner <david@lechnology.com>
---
 drivers/power/supply/lego_ev3_battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/lego_ev3_battery.c b/drivers/power/supply/lego_ev3_battery.c
index 6e3b3e384172..1ae3710909b7 100644
--- a/drivers/power/supply/lego_ev3_battery.c
+++ b/drivers/power/supply/lego_ev3_battery.c
@@ -52,7 +52,7 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,
 			return ret;
 
 		val->intval *= 2000;
-		val->intval += 200000;
+		val->intval += 50000;
 
 		/* plus adjust for shunt resistor drop */
 		ret = iio_read_channel_processed(batt->iio_i, &val2);
-- 
2.17.1


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

* Re: [PATCH 1/2] power: supply: lego_ev3_battery: Don't ignore iio_read_channel_processed() return value
  2018-07-20 20:19 ` [PATCH 1/2] power: supply: lego_ev3_battery: Don't ignore iio_read_channel_processed() return value David Lechner
@ 2018-07-22 22:02   ` Sebastian Reichel
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2018-07-22 22:02 UTC (permalink / raw)
  To: David Lechner; +Cc: linux-pm, linux-kernel

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

Hi,

On Fri, Jul 20, 2018 at 03:19:43PM -0500, David Lechner wrote:
> This changes the LEGO MINDSTORMS EV3 power supply driver to return an
> error if iio_read_channel_processed() fails.
> 
> Signed-off-by: David Lechner <david@lechnology.com>
> ---

Thanks, queued to power-supply's for-next branch.

-- Sebastian

>  drivers/power/supply/lego_ev3_battery.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/power/supply/lego_ev3_battery.c b/drivers/power/supply/lego_ev3_battery.c
> index 7b993d669f7f..6e3b3e384172 100644
> --- a/drivers/power/supply/lego_ev3_battery.c
> +++ b/drivers/power/supply/lego_ev3_battery.c
> @@ -39,7 +39,7 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,
>  					 union power_supply_propval *val)
>  {
>  	struct lego_ev3_battery *batt = power_supply_get_drvdata(psy);
> -	int val2;
> +	int ret, val2;
>  
>  	switch (psp) {
>  	case POWER_SUPPLY_PROP_TECHNOLOGY:
> @@ -47,11 +47,18 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,
>  		break;
>  	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
>  		/* battery voltage is iio channel * 2 + Vce of transistor */
> -		iio_read_channel_processed(batt->iio_v, &val->intval);
> +		ret = iio_read_channel_processed(batt->iio_v, &val->intval);
> +		if (ret)
> +			return ret;
> +
>  		val->intval *= 2000;
>  		val->intval += 200000;
> +
>  		/* plus adjust for shunt resistor drop */
> -		iio_read_channel_processed(batt->iio_i, &val2);
> +		ret = iio_read_channel_processed(batt->iio_i, &val2);
> +		if (ret)
> +			return ret;
> +
>  		val2 *= 1000;
>  		val2 /= 15;
>  		val->intval += val2;
> @@ -64,7 +71,10 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,
>  		break;
>  	case POWER_SUPPLY_PROP_CURRENT_NOW:
>  		/* battery current is iio channel / 15 / 0.05 ohms */
> -		iio_read_channel_processed(batt->iio_i, &val->intval);
> +		ret = iio_read_channel_processed(batt->iio_i, &val->intval);
> +		if (ret)
> +			return ret;
> +
>  		val->intval *= 20000;
>  		val->intval /= 15;
>  		break;
> -- 
> 2.17.1
> 

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

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

* Re: [PATCH 2/2] power: supply: lego_ev3_battery: fix Vce offset
  2018-07-20 20:19 ` [PATCH 2/2] power: supply: lego_ev3_battery: fix Vce offset David Lechner
@ 2018-07-22 22:02   ` Sebastian Reichel
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2018-07-22 22:02 UTC (permalink / raw)
  To: David Lechner; +Cc: linux-pm, linux-kernel

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

Hi,

On Fri, Jul 20, 2018 at 03:19:44PM -0500, David Lechner wrote:
> This fixes the value that accounts for the Vce of a transistor in the
> LEGO MINDSTORMS EV3 power supply driver. The old value (200mV) was the
> max value from the data sheet. After testing, the actual value has been
> found to be 50mV. By using 50mV we get a more accurate voltage
> indication.
> 
> Signed-off-by: David Lechner <david@lechnology.com>
> ---

Thanks, queued to power-supply's for-next branch.

-- Sebastian

>  drivers/power/supply/lego_ev3_battery.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/lego_ev3_battery.c b/drivers/power/supply/lego_ev3_battery.c
> index 6e3b3e384172..1ae3710909b7 100644
> --- a/drivers/power/supply/lego_ev3_battery.c
> +++ b/drivers/power/supply/lego_ev3_battery.c
> @@ -52,7 +52,7 @@ static int lego_ev3_battery_get_property(struct power_supply *psy,
>  			return ret;
>  
>  		val->intval *= 2000;
> -		val->intval += 200000;
> +		val->intval += 50000;
>  
>  		/* plus adjust for shunt resistor drop */
>  		ret = iio_read_channel_processed(batt->iio_i, &val2);
> -- 
> 2.17.1
> 

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

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

end of thread, other threads:[~2018-07-22 22:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-20 20:19 [PATCH 0/2] power: supply: lego_ev3_battery improvements David Lechner
2018-07-20 20:19 ` [PATCH 1/2] power: supply: lego_ev3_battery: Don't ignore iio_read_channel_processed() return value David Lechner
2018-07-22 22:02   ` Sebastian Reichel
2018-07-20 20:19 ` [PATCH 2/2] power: supply: lego_ev3_battery: fix Vce offset David Lechner
2018-07-22 22:02   ` 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).