Linux Power Management development
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Andreas Kemnade <andreas@kemnade.info>,
	sre@kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] power: supply: bd71828: sysfs for auto input current limitation
Date: Tue, 5 May 2026 08:22:40 +0300	[thread overview]
Message-ID: <53fe896c-a357-46d9-86db-4b0381f8c066@gmail.com> (raw)
In-Reply-To: <20260504164017.467679-1-andreas@kemnade.info>

Thanks Andreas!

On 04/05/2026 19:40, Andreas Kemnade wrote:
> Add the possibility to disable the auto adjustment for input current
> limitation via sysfs because it gives strange results under certain
> circumstances e.g. when powering the device with solar panels
> resulting in no input power usage at all.
> 
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

> ---
>   .../ABI/testing/sysfs-class-power-bd71828     | 12 ++++
>   drivers/power/supply/bd71828-power.c          | 69 ++++++++++++++++++-
>   2 files changed, 80 insertions(+), 1 deletion(-)
>   create mode 100644 Documentation/ABI/testing/sysfs-class-power-bd71828

// snip

> +static ssize_t auto_dcin_limit_store(struct device *dev,
> +				     struct device_attribute *attr,
> +				     const char *buf, size_t len)
> +{
> +	struct bd71828_power *pwr = dev_get_drvdata(dev->parent);
> +	int ret;
> +	bool v;
> +
> +	ret = kstrtobool(buf, &v);
> +	if (ret < 0)
> +		return ret;
> +
> +	ret = regmap_update_bits(pwr->regmap, BD71828_REG_DCIN_SET,
> +				 BD71828_MASK_ILIM_DCIN_EN,
> +				 v ? BD71828_MASK_ILIM_DCIN_EN : 0);

'nit'. I am not a big fan of the ternary. I would consider using an 
if-else or the regmap_assign_bits(). Not worth re-spinning though.


> +static bool bd71828_ac_sysfs_group_visible(struct kobject *kobj)
> +{
> +	struct device *dev = kobj_to_dev(kobj);
> +	struct bd71828_power *pwr = dev_get_drvdata(dev->parent);
> +
> +	return !!pwr->regs->dcin_set;
> +}
> +
> +DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(bd71828_ac_sysfs);

Ah. I didn't know DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE() existed. Thanks 
for teaching me a thing again :)

Yours,
	-- Matti
-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~

      reply	other threads:[~2026-05-05  5:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-04 16:40 [PATCH] power: supply: bd71828: sysfs for auto input current limitation Andreas Kemnade
2026-05-05  5:22 ` Matti Vaittinen [this message]

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=53fe896c-a357-46d9-86db-4b0381f8c066@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=andreas@kemnade.info \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@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