All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power: supply: core: simplify charge_behaviour formatting
@ 2024-03-29  8:18 Thomas Weißschuh
  2024-03-29 11:32 ` Hans de Goede
  2024-03-30 23:01   ` Sebastian Reichel
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2024-03-29  8:18 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, linux-pm, linux-kernel, Hans de Goede,
	Thomas Weißschuh

The function power_supply_show_charge_behaviour() is not needed and can
be removed completely.
Removing the function also saves a spurious read of the property from
the driver on each call.

The convulted logic was a leftover from an earlier patch revision.
Some restructuring made this cleanup possible.

Suggested-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/all/9e035ae4-cb07-4f84-8336-1a0050855bea@redhat.com/
Fixes: 4e61f1e9d58f ("power: supply: core: fix charge_behaviour formatting")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 drivers/power/supply/power_supply_sysfs.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index 0d2c3724d0bc..b86e11bdc07e 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -271,23 +271,6 @@ static ssize_t power_supply_show_usb_type(struct device *dev,
 	return count;
 }
 
-static ssize_t power_supply_show_charge_behaviour(struct device *dev,
-						  struct power_supply *psy,
-						  union power_supply_propval *value,
-						  char *buf)
-{
-	int ret;
-
-	ret = power_supply_get_property(psy,
-					POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR,
-					value);
-	if (ret < 0)
-		return ret;
-
-	return power_supply_charge_behaviour_show(dev, psy->desc->charge_behaviours,
-						  value->intval, buf);
-}
-
 static ssize_t power_supply_show_property(struct device *dev,
 					  struct device_attribute *attr,
 					  char *buf) {
@@ -321,7 +304,8 @@ static ssize_t power_supply_show_property(struct device *dev,
 						&value, buf);
 		break;
 	case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR:
-		ret = power_supply_show_charge_behaviour(dev, psy, &value, buf);
+		ret = power_supply_charge_behaviour_show(dev, psy->desc->charge_behaviours,
+							 value.intval, buf);
 		break;
 	case POWER_SUPPLY_PROP_MODEL_NAME ... POWER_SUPPLY_PROP_SERIAL_NUMBER:
 		ret = sysfs_emit(buf, "%s\n", value.strval);

---
base-commit: 070c1470ae24317e7b19bd3882b300b6d69922a4
change-id: 20240329-power-supply-simplify-5722806eefdd

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>


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

* Re: [PATCH] power: supply: core: simplify charge_behaviour formatting
  2024-03-29  8:18 [PATCH] power: supply: core: simplify charge_behaviour formatting Thomas Weißschuh
@ 2024-03-29 11:32 ` Hans de Goede
  2024-03-30 23:01   ` Sebastian Reichel
  1 sibling, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2024-03-29 11:32 UTC (permalink / raw)
  To: Thomas Weißschuh, Sebastian Reichel
  Cc: Sebastian Reichel, linux-pm, linux-kernel

Hi,

On 3/29/24 9:18 AM, Thomas Weißschuh wrote:
> The function power_supply_show_charge_behaviour() is not needed and can
> be removed completely.
> Removing the function also saves a spurious read of the property from
> the driver on each call.
> 
> The convulted logic was a leftover from an earlier patch revision.
> Some restructuring made this cleanup possible.
> 
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Link: https://lore.kernel.org/all/9e035ae4-cb07-4f84-8336-1a0050855bea@redhat.com/
> Fixes: 4e61f1e9d58f ("power: supply: core: fix charge_behaviour formatting")
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>  drivers/power/supply/power_supply_sysfs.c | 20 ++------------------
>  1 file changed, 2 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index 0d2c3724d0bc..b86e11bdc07e 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -271,23 +271,6 @@ static ssize_t power_supply_show_usb_type(struct device *dev,
>  	return count;
>  }
>  
> -static ssize_t power_supply_show_charge_behaviour(struct device *dev,
> -						  struct power_supply *psy,
> -						  union power_supply_propval *value,
> -						  char *buf)
> -{
> -	int ret;
> -
> -	ret = power_supply_get_property(psy,
> -					POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR,
> -					value);
> -	if (ret < 0)
> -		return ret;
> -
> -	return power_supply_charge_behaviour_show(dev, psy->desc->charge_behaviours,
> -						  value->intval, buf);
> -}
> -
>  static ssize_t power_supply_show_property(struct device *dev,
>  					  struct device_attribute *attr,
>  					  char *buf) {
> @@ -321,7 +304,8 @@ static ssize_t power_supply_show_property(struct device *dev,
>  						&value, buf);
>  		break;
>  	case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR:
> -		ret = power_supply_show_charge_behaviour(dev, psy, &value, buf);
> +		ret = power_supply_charge_behaviour_show(dev, psy->desc->charge_behaviours,
> +							 value.intval, buf);
>  		break;
>  	case POWER_SUPPLY_PROP_MODEL_NAME ... POWER_SUPPLY_PROP_SERIAL_NUMBER:
>  		ret = sysfs_emit(buf, "%s\n", value.strval);
> 
> ---
> base-commit: 070c1470ae24317e7b19bd3882b300b6d69922a4
> change-id: 20240329-power-supply-simplify-5722806eefdd
> 
> Best regards,


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

* Re: [PATCH] power: supply: core: simplify charge_behaviour formatting
@ 2024-03-30 23:01   ` Sebastian Reichel
  0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2024-03-30 23:01 UTC (permalink / raw)
  To: Sebastian Reichel, Thomas Weißschuh
  Cc: linux-pm, linux-kernel, Hans de Goede


On Fri, 29 Mar 2024 09:18:29 +0100, Thomas Weißschuh wrote:
> The function power_supply_show_charge_behaviour() is not needed and can
> be removed completely.
> Removing the function also saves a spurious read of the property from
> the driver on each call.
> 
> The convulted logic was a leftover from an earlier patch revision.
> Some restructuring made this cleanup possible.
> 
> [...]

Applied, thanks!

[1/1] power: supply: core: simplify charge_behaviour formatting
      commit: 91b623cda43e449a49177ba99b6723f551a4bfbe

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>


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

* Re: [PATCH] power: supply: core: simplify charge_behaviour formatting
@ 2024-03-30 23:01   ` Sebastian Reichel
  0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2024-03-30 23:01 UTC (permalink / raw)
  To: Sebastian Reichel, Thomas Weißschuh
  Cc: linux-pm, linux-kernel, Hans de Goede


On Fri, 29 Mar 2024 09:18:29 +0100, Thomas Weißschuh wrote:
> The function power_supply_show_charge_behaviour() is not needed and can
> be removed completely.
> Removing the function also saves a spurious read of the property from
> the driver on each call.
> 
> The convulted logic was a leftover from an earlier patch revision.
> Some restructuring made this cleanup possible.
> 
> [...]

Applied, thanks!

[1/1] power: supply: core: simplify charge_behaviour formatting
      commit: 91b623cda43e449a49177ba99b6723f551a4bfbe

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>



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

end of thread, other threads:[~2024-03-31 16:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-29  8:18 [PATCH] power: supply: core: simplify charge_behaviour formatting Thomas Weißschuh
2024-03-29 11:32 ` Hans de Goede
2024-03-30 23:01 ` Sebastian Reichel
2024-03-30 23:01   ` Sebastian Reichel

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.