From: "Pali Rohár" <pali@kernel.org>
To: Andres Salomon <dilinger@queued.net>
Cc: linux-kernel@vger.kernel.org,
platform-driver-x86@vger.kernel.org,
"Matthew Garrett" <mjg59@srcf.ucam.org>,
"Sebastian Reichel" <sre@kernel.org>,
"Hans de Goede" <hdegoede@redhat.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
linux-pm@vger.kernel.org, Dell.Client.Kernel@dell.com
Subject: Re: [PATCH v3 1/2] platform/x86:dell-laptop: Add knobs to change battery charge settings
Date: Fri, 16 Aug 2024 19:16:51 +0200 [thread overview]
Message-ID: <20240816171651.jmqa7tmfkc3jmsm4@pali> (raw)
In-Reply-To: <20240815192848.3489d3e1@5400>
Hello Andres,
I have just comments for this change. It looks good. After resolving
them you can add my tag: Reviewed-by: Pali Rohár <pali@kernel.org>
On Thursday 15 August 2024 19:28:48 Andres Salomon wrote:
> The Dell BIOS allows you to set custom charging modes, which is useful
> in particular for extending battery life. This adds support for tweaking
> those various settings from Linux via sysfs knobs. One might, for
> example, have their laptop plugged into power at their desk the vast
> majority of the time and choose fairly aggressive battery-saving
> settings (eg, only charging once the battery drops below 50% and only
> charging up to 80%). When leaving for a trip, it would be more useful
> to instead switch to a standard charging mode (top off at 100%, charge
> any time power is available). Rebooting into the BIOS to change the
> charging mode settings is a hassle.
>
> For the Custom charging type mode, we reuse the common
> charge_control_{start,end}_threshold sysfs power_supply entries. The
> BIOS also has a bunch of other charging modes (with varying levels of
> usefulness), so this also adds a 'charge_type' sysfs entry that maps the
> standard values to Dell-specific ones and documents those mappings in
> sysfs-class-power-dell.
>
> This work is based on a patch by Perry Yuan <perry_yuan@dell.com> and
> Limonciello Mario <Mario_Limonciello@Dell.com> submitted back in 2020:
I think that the information below is not needed to have in commit
message. We also do not include links or information about previous
version of patch sent by you.
> https://lore.kernel.org/all/20200729065424.12851-1-Perry_Yuan@Dell.com/
> Both of their email addresses bounce, so I'm assuming they're no longer
> with the company. I've reworked most of the patch to make it smaller and
> cleaner.
...
> +static ssize_t charge_type_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t size)
> +{
> + bool matched = false;
> + int err, i;
> +
> + for (i = 0; i < ARRAY_SIZE(battery_modes); i++) {
> + if (!(battery_supported_modes & BIT(i)))
> + continue;
> +
> + if (sysfs_streq(battery_modes[i].label, buf)) {
> + matched = true;
> + break;
> + }
> + }
> + if (!matched || !(battery_supported_modes & BIT(i)))
> + return -EINVAL;
Check for "!(battery_supported_modes & BIT(i))" is redundant here.
"matched" can be true only in case if the i-th mode is supported and was
specified in buffer.
> +
> + err = dell_battery_set_mode(battery_modes[i].token);
> + if (err)
> + return err;
> +
> + return size;
> +}
next prev parent reply other threads:[~2024-08-16 17:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 23:28 [PATCH v3 1/2] platform/x86:dell-laptop: Add knobs to change battery charge settings Andres Salomon
2024-08-15 23:35 ` [PATCH v2 2/2] platform/x86:dell-laptop: remove duplicate code w/ battery function Andres Salomon
2024-08-16 17:24 ` Pali Rohár
2024-08-16 7:27 ` [PATCH v3 1/2] platform/x86:dell-laptop: Add knobs to change battery charge settings kernel test robot
2024-08-16 13:56 ` Ilpo Järvinen
2024-08-16 16:33 ` Pali Rohár
2024-08-16 18:52 ` Andres Salomon
2024-08-19 11:03 ` Ilpo Järvinen
2024-08-16 17:16 ` Pali Rohár [this message]
2024-08-18 1:36 ` kernel test robot
2024-08-19 13:59 ` Hans de Goede
2024-08-24 2:39 ` Andres Salomon
2024-08-24 12:35 ` Hans de Goede
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=20240816171651.jmqa7tmfkc3jmsm4@pali \
--to=pali@kernel.org \
--cc=Dell.Client.Kernel@dell.com \
--cc=dilinger@queued.net \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mjg59@srcf.ucam.org \
--cc=platform-driver-x86@vger.kernel.org \
--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