Chrome platform driver development
 help / color / mirror / Atom feed
From: Armin Wolf <W_Armin@gmx.de>
To: "Thomas Weißschuh" <thomas@weissschuh.net>
Cc: "Thomas Weißschuh" <linux@weissschuh.net>,
	"Sebastian Reichel" <sre@kernel.org>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Benson Leung" <bleung@chromium.org>,
	"Guenter Roeck" <groeck@chromium.org>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	chrome-platform@lists.linux.dev
Subject: Re: [PATCH v4 1/9] power: supply: sysfs: print single value in uevent for POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR
Date: Sun, 24 Nov 2024 19:01:44 +0100	[thread overview]
Message-ID: <d3b4d121-950a-4c08-bf21-edb1ceb30d7d@gmx.de> (raw)
In-Reply-To: <e46c1453-6d47-489d-a5d1-1750d96139ad@weissschuh.net>

Am 24.11.24 um 18:55 schrieb Thomas Weißschuh:

> Nov 24, 2024 18:47:39 Armin Wolf <W_Armin@gmx.de>:
>
>> Am 11.11.24 um 22:40 schrieb Thomas Weißschuh:
>>
>>> Currently an uevent contains the same string representation of a
>>> property as sysfs. However for POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR this
>>> is specially formatted to indicate all possible values.
>>> This doesn't make sense for uevents and complicates parsing.
>>> Instead only include the currently active value in uevents.
>>>
>>> As currently no in-tree driver uses POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR
>>> this change is not a problem.
>>> Soon the property will actually be used so fix the formatting before
>>> that happens.
>> AFAIK the cros-charge-behaviour driver does use POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR,
>> so we have to make sure that no userspace application uses this uevent information.
> It only does so after this series.
> Currently it uses the ad-hoc sysfs attributes which don't show up in uevent.
> (I'm the maintainer)

I see, in this case you can ignore my comment.

Thank,
Armin Wolf

>> Other than that:
>>
>> Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Thanks!
>
>>> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
>>> ---
>>>    drivers/power/supply/power_supply_sysfs.c | 20 ++++++++++++++++----
>>>    1 file changed, 16 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
>>> index 571de43fcca9827cf0fe3023e453defbf1eaec7d..a7351b9c8fe34a464a4e69b1a1a4a4179c1a4b4f 100644
>>> --- a/drivers/power/supply/power_supply_sysfs.c
>>> +++ b/drivers/power/supply/power_supply_sysfs.c
>>> @@ -268,9 +268,11 @@ static ssize_t power_supply_show_enum_with_available(
>>>      return count;
>>>    }
>>>
>>> -static ssize_t power_supply_show_property(struct device *dev,
>>> -                     struct device_attribute *attr,
>>> -                     char *buf) {
>>> +static ssize_t power_supply_format_property(struct device *dev,
>>> +                       bool uevent,
>>> +                       struct device_attribute *attr,
>>> +                       char *buf)
>>> +{
>>>      ssize_t ret;
>>>      struct power_supply *psy = dev_get_drvdata(dev);
>>>      const struct power_supply_attr *ps_attr = to_ps_attr(attr);
>>> @@ -303,6 +305,8 @@ static ssize_t power_supply_show_property(struct device *dev,
>>>                  psy->desc->usb_types, value.intval, buf);
>>>          break;
>>>      case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR:
>>> +       if (uevent) /* no possible values in uevents */
>>> +           goto default_format;
>>>          ret = power_supply_charge_behaviour_show(dev, psy->desc->charge_behaviours,
>>>                               value.intval, buf);
>>>          break;
>>> @@ -310,6 +314,7 @@ static ssize_t power_supply_show_property(struct device *dev,
>>>          ret = sysfs_emit(buf, "%s\n", value.strval);
>>>          break;
>>>      default:
>>> +default_format:
>>>          if (ps_attr->text_values_len > 0 &&
>>>                  value.intval < ps_attr->text_values_len && value.intval >= 0) {
>>>              ret = sysfs_emit(buf, "%s\n", ps_attr->text_values[value.intval]);
>>> @@ -321,6 +326,13 @@ static ssize_t power_supply_show_property(struct device *dev,
>>>      return ret;
>>>    }
>>>
>>> +static ssize_t power_supply_show_property(struct device *dev,
>>> +                     struct device_attribute *attr,
>>> +                     char *buf)
>>> +{
>>> +   return power_supply_format_property(dev, false, attr, buf);
>>> +}
>>> +
>>>    static ssize_t power_supply_store_property(struct device *dev,
>>>                         struct device_attribute *attr,
>>>                         const char *buf, size_t count) {
>>> @@ -437,7 +449,7 @@ static int add_prop_uevent(const struct device *dev, struct kobj_uevent_env *env
>>>      pwr_attr = &power_supply_attrs[prop];
>>>      dev_attr = &pwr_attr->dev_attr;
>>>
>>> -   ret = power_supply_show_property((struct device *)dev, dev_attr, prop_buf);
>>> +   ret = power_supply_format_property((struct device *)dev, true, dev_attr, prop_buf);
>>>      if (ret == -ENODEV || ret == -ENODATA) {
>>>          /*
>>>           * When a battery is absent, we expect -ENODEV. Don't abort;
>>>

  reply	other threads:[~2024-11-24 18:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11 21:40 [PATCH v4 0/9] power: supply: extension API Thomas Weißschuh
2024-11-11 21:40 ` [PATCH v4 1/9] power: supply: sysfs: print single value in uevent for POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR Thomas Weißschuh
2024-11-24 17:47   ` Armin Wolf
2024-11-24 17:55     ` Thomas Weißschuh
2024-11-24 18:01       ` Armin Wolf [this message]
2024-11-11 21:40 ` [PATCH v4 2/9] power: supply: core: rename psy_has_property() to psy_desc_has_property() Thomas Weißschuh
2024-11-24 17:48   ` Armin Wolf
2024-11-11 21:40 ` [PATCH v4 3/9] power: supply: core: introduce power_supply_has_property() Thomas Weißschuh
2024-11-24 17:51   ` Armin Wolf
2024-11-11 21:40 ` [PATCH v4 4/9] power: supply: hwmon: prepare for power supply extensions Thomas Weißschuh
2024-11-24 17:53   ` Armin Wolf
2024-11-11 21:40 ` [PATCH v4 5/9] power: supply: sysfs: " Thomas Weißschuh
2024-11-24 17:57   ` Armin Wolf
2024-11-25  8:59     ` Thomas Weißschuh
2024-11-11 21:40 ` [PATCH v4 6/9] power: supply: sysfs: rework uevent property loop Thomas Weißschuh
2024-11-24 18:00   ` Armin Wolf
2024-11-11 21:40 ` [PATCH v4 7/9] power: supply: core: implement extension API Thomas Weißschuh
2024-11-24 18:15   ` Armin Wolf
2024-11-25  9:22     ` Thomas Weißschuh
2024-11-11 21:40 ` [PATCH v4 8/9] power: supply: test-power: implement a power supply extension Thomas Weißschuh
2024-11-11 21:40 ` [PATCH v4 9/9] power: supply: cros_charge-control: use power_supply extensions Thomas Weißschuh
2024-12-05  1:36 ` (subset) [PATCH v4 0/9] power: supply: extension API Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3b4d121-950a-4c08-bf21-edb1ceb30d7d@gmx.de \
    --to=w_armin@gmx.de \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=groeck@chromium.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=sre@kernel.org \
    --cc=thomas@weissschuh.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox