From: Hans de Goede <hdegoede@redhat.com>
To: "Thomas Weißschuh" <linux@weissschuh.net>,
"Sebastian Reichel" <sre@kernel.org>,
"Konrad Dybcio" <konradybcio@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: Re: [PATCH v2 2/4] power: supply: core: ease special formatting implementations
Date: Wed, 27 Mar 2024 11:36:27 +0100 [thread overview]
Message-ID: <c217d7e6-5f20-4362-b59c-adb64bd54dab@redhat.com> (raw)
In-Reply-To: <20240303-power_supply-charge_behaviour_prop-v2-2-8ebb0a7c2409@weissschuh.net>
Hi,
On 3/3/24 4:31 PM, Thomas Weißschuh wrote:
> By moving the conditional into the default-branch of the switch new
> additions to the switch won't have to bypass the conditional.
>
> This makes it easier to implement those special cases like the upcoming
> change to the formatting of "charge_behaviour".
>
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Link: https://lore.kernel.org/lkml/53082075-852f-4698-b354-ed30e7fd2683@redhat.com/
> 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 | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index 977611e16373..10fec411794b 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -298,11 +298,6 @@ static ssize_t power_supply_show_property(struct device *dev,
> }
> }
>
> - if (ps_attr->text_values_len > 0 &&
> - value.intval < ps_attr->text_values_len && value.intval >= 0) {
> - return sysfs_emit(buf, "%s\n", ps_attr->text_values[value.intval]);
> - }
> -
> switch (psp) {
> case POWER_SUPPLY_PROP_USB_TYPE:
> ret = power_supply_show_usb_type(dev, psy->desc,
> @@ -312,7 +307,12 @@ static ssize_t power_supply_show_property(struct device *dev,
> ret = sysfs_emit(buf, "%s\n", value.strval);
> break;
> default:
> - ret = sysfs_emit(buf, "%d\n", value.intval);
> + 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]);
> + } else {
> + ret = sysfs_emit(buf, "%d\n", value.intval);
> + }
> }
>
> return ret;
>
next prev parent reply other threads:[~2024-03-27 10:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-03 15:31 [PATCH v2 0/4] power: supply: core: align charge_behaviour format with docs Thomas Weißschuh
2024-03-03 15:31 ` [PATCH v2 1/4] power: supply: mm8013: fix "not charging" detection Thomas Weißschuh
2024-03-06 0:25 ` Sebastian Reichel
2024-03-27 10:36 ` Hans de Goede
2024-03-27 20:48 ` Konrad Dybcio
2024-03-03 15:31 ` [PATCH v2 2/4] power: supply: core: ease special formatting implementations Thomas Weißschuh
2024-03-06 0:25 ` Sebastian Reichel
2024-03-27 10:36 ` Hans de Goede [this message]
2024-03-03 15:31 ` [PATCH v2 3/4] power: supply: core: fix charge_behaviour formatting Thomas Weißschuh
2024-03-06 0:27 ` Sebastian Reichel
2024-03-27 10:43 ` Hans de Goede
2024-03-03 15:31 ` [PATCH v2 4/4] power: supply: test-power: implement charge_behaviour property Thomas Weißschuh
2024-03-06 0:39 ` 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=c217d7e6-5f20-4362-b59c-adb64bd54dab@redhat.com \
--to=hdegoede@redhat.com \
--cc=konradybcio@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=sebastian.reichel@collabora.com \
--cc=sre@kernel.org \
/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
all inboxes | Powered by JetHome®