[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <i6uuefpyklm76a3yxablaoltdqs6vjxea5mbaxfscr554im64d@nd22ixtydjnz>
Date: Wed, 6 Mar 2024 01:27:56 +0100
From: Sebastian Reichel <sebastian.reichel@...labora.com>
To: Thomas Weißschuh <linux@...ssschuh.net>
Cc: Hans de Goede <hdegoede@...hat.com>,
Konrad Dybcio <konradybcio@...nel.org>, linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/4] power: supply: core: fix charge_behaviour
formatting
Hi,
On Sun, Mar 03, 2024 at 04:31:15PM +0100, Thomas Weißschuh wrote:
> This property is documented to have a special format which exposes all
> available behaviours and the currently active one at the same time.
> For this special format some helpers are provided.
>
> However the default property logic in power_supply_sysfs.c is not using
> the helper and the default logic only prints the currently active
> behaviour.
>
> Adjust power_supply_sysfs.c to follow the documented format.
>
> There are currently two in-tree drivers exposing charge behaviours:
> thinkpad_acpi and mm8013.
> thinkpad_acpi is not affected by the change, as it directly uses the
> helpers and does not use the power_supply_sysfs.c logic.
>
> As mm8013 does not set implement desc->charge_behaviours.
> the new logic will preserve the simple output format in this case.
>
> Fixes: 1b0b6cc8030d ("power: supply: add charge_behaviour attributes")
> Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
> ---
Thanks, I also queued this one, but reworked the commit message and
removed the Fixes tag considering we have only thinkpad_acpi using
this feature in-tree.
-- Sebastian
> drivers/power/supply/power_supply_sysfs.c | 20 ++++++++++++++++++++
> include/linux/power_supply.h | 1 +
> 2 files changed, 21 insertions(+)
>
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index 10fec411794b..a20aa0156b0a 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -271,6 +271,23 @@ 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) {
> @@ -303,6 +320,9 @@ static ssize_t power_supply_show_property(struct device *dev,
> ret = power_supply_show_usb_type(dev, psy->desc,
> &value, buf);
> break;
> + case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR:
> + ret = power_supply_show_charge_behaviour(dev, psy, &value, buf);
> + break;
> case POWER_SUPPLY_PROP_MODEL_NAME ... POWER_SUPPLY_PROP_SERIAL_NUMBER:
> ret = sysfs_emit(buf, "%s\n", value.strval);
> break;
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index c0992a77feea..a50ee69503bf 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -242,6 +242,7 @@ struct power_supply_config {
> struct power_supply_desc {
> const char *name;
> enum power_supply_type type;
> + u8 charge_behaviours;
> const enum power_supply_usb_type *usb_types;
> size_t num_usb_types;
> const enum power_supply_property *properties;
>
> --
> 2.44.0
>
>
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists