public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Sebastian Reichel <sebastian.reichel@collabora.com>
Cc: "Mark Brown" <broonie@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Chen-Yu Tsai" <wens@csie.org>, "Pali Rohár" <pali@kernel.org>,
	"Paul Cercueil" <paul@crapouillou.net>,
	"Samuel Holland" <samuel@sholland.org>,
	"David Lechner" <david@lechnology.com>,
	"Krzysztof Kozlowski" <krzk@kernel.org>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	"Sebastian Krzyszkowiak" <sebastian.krzyszkowiak@puri.sm>,
	"Purism Kernel Team" <kernel@puri.sm>,
	"Bartosz Golaszewski" <brgl@bgdev.pl>,
	"Konrad Dybcio" <konradybcio@kernel.org>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>,
	"Orson Zhai" <orsonzhai@gmail.com>,
	"Baolin Wang" <baolin.wang@linux.alibaba.com>,
	"Chunyan Zhang" <zhang.lyra@gmail.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH 1/7] power: supply: core: get rid of of_node
Date: Tue, 25 Feb 2025 15:25:23 +0200	[thread overview]
Message-ID: <bf74173f-ccd9-43c0-a190-68512c6f63cc@gmail.com> (raw)
In-Reply-To: <ocbwzuqk56yx34kc5vp6aaxnhxqd4zp2wixlv7p3mex66ibntu@ahigikrf5cg4>

On 25/02/2025 15:11, Sebastian Reichel wrote:
> Hi,
> 
> On Tue, Feb 25, 2025 at 01:14:03PM +0200, Matti Vaittinen wrote:
>> On 25/02/2025 01:21, Sebastian Reichel wrote:
>>> This removes .of_node from 'struct power_supply', since there
>>> is already a copy in .dev.of_node and there is no need to have
>>> two copies.
>>>
>>> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
>>> ---
>>>    drivers/power/supply/power_supply_core.c | 17 ++++++++---------
>>>    include/linux/power_supply.h             |  1 -
>>>    2 files changed, 8 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
>>> index d0bb52a7a0367a8e07787be211691cad14a41a54..11030035da6f121ca76bebf800c06cfd5db57578 100644
>>> --- a/drivers/power/supply/power_supply_core.c
>>> +++ b/drivers/power/supply/power_supply_core.c
>>> @@ -200,11 +200,11 @@ static int __power_supply_populate_supplied_from(struct power_supply *epsy,
>>>    	int i = 0;
>>>    	do {
>>> -		np = of_parse_phandle(psy->of_node, "power-supplies", i++);
>>> +		np = of_parse_phandle(psy->dev.of_node, "power-supplies", i++);
>>>    		if (!np)
>>>    			break;
>>> -		if (np == epsy->of_node) {
>>> +		if (np == epsy->dev.of_node) {
>>>    			dev_dbg(&psy->dev, "%s: Found supply : %s\n",
>>>    				psy->desc->name, epsy->desc->name);
>>>    			psy->supplied_from[i-1] = (char *)epsy->desc->name;
>>> @@ -235,7 +235,7 @@ static int  __power_supply_find_supply_from_node(struct power_supply *epsy,
>>>    	struct device_node *np = data;
>>>    	/* returning non-zero breaks out of power_supply_for_each_psy loop */
>>> -	if (epsy->of_node == np)
>>> +	if (epsy->dev.of_node == np)
>>>    		return 1;
>>>    	return 0;
>>> @@ -270,13 +270,13 @@ static int power_supply_check_supplies(struct power_supply *psy)
>>>    		return 0;
>>>    	/* No device node found, nothing to do */
>>> -	if (!psy->of_node)
>>> +	if (!psy->dev.of_node)
>>>    		return 0;
>>>    	do {
>>>    		int ret;
>>> -		np = of_parse_phandle(psy->of_node, "power-supplies", cnt++);
>>> +		np = of_parse_phandle(psy->dev.of_node, "power-supplies", cnt++);
>>>    		if (!np)
>>>    			break;
>>> @@ -606,8 +606,8 @@ int power_supply_get_battery_info(struct power_supply *psy,
>>>    	const __be32 *list;
>>>    	u32 min_max[2];
>>> -	if (psy->of_node) {
>>> -		battery_np = of_parse_phandle(psy->of_node, "monitored-battery", 0);
>>> +	if (psy->dev.of_node) {
>>> +		battery_np = of_parse_phandle(psy->dev.of_node, "monitored-battery", 0);
>>>    		if (!battery_np)
>>>    			return -ENODEV;
>>
>> This reminded me of a change I once did to power_supply - but maybe never
>> got it further than RFC stage. Anyways, do you think it would be possible to
>> decouple the battery info and struct power_suppply (while at it)?
>>
>> I believe that the chargers and especially fuel-gauges which are designed to
>> operate with different batteries (and which get battery details using static
>> battery nodes), would like to get the battery info _before_ registering the
>> power_supply (to avoid sending bogus values while operating on defaults,
>> before the battery info is read and before things are set accordingly).
>>
>> I know this may be a bit much to ask, but I believe it'd be an improvement.
>>
>> Other than that, looks good to me.
> 
> I was thinking about adding an init function to power_supply_desc,
> which would be called directly before psy->initialized is set to
> true in the power-supply registration phase. I think that would be
> the right place to setup device registers based on battery-info data.

Hm. I suppose that would work.

> But it's definitely not a thing for this series.

Fair enough. I thought that might be the case but decided to ask 
anyways, because, AFAIR there were no real problems what comes to not 
requiring the struct power_supply for reading the battery_info. But yes, 
I can see why killing the of_nodes is a big enough series, even without 
added complexity :)

Yours,
	-- Matti

  reply	other threads:[~2025-02-25 13:25 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24 23:21 [PATCH 0/7] power: supply: core: convert to fwnode Sebastian Reichel
2025-02-24 23:21 ` [PATCH 1/7] power: supply: core: get rid of of_node Sebastian Reichel
2025-02-25 10:47   ` AngeloGioacchino Del Regno
2025-02-25 11:14   ` Matti Vaittinen
2025-02-25 13:11     ` Sebastian Reichel
2025-02-25 13:25       ` Matti Vaittinen [this message]
2025-02-24 23:21 ` [PATCH 2/7] regulator: act8865-regulator: switch psy_cfg from of_node to fwnode Sebastian Reichel
2025-03-12  0:12   ` Sebastian Reichel
2025-03-12 12:34     ` Mark Brown
2025-02-24 23:21 ` [PATCH 3/7] usb: common: usb-conn-gpio: " Sebastian Reichel
2025-02-25  3:32   ` Greg Kroah-Hartman
2025-03-08  1:10     ` Sebastian Reichel
2025-03-08  5:57       ` Greg Kroah-Hartman
2025-03-08  9:34         ` Konrad Dybcio
2025-03-08 16:33           ` Sebastian Reichel
2025-03-08 17:27             ` Greg Kroah-Hartman
2025-03-08 18:27               ` Konrad Dybcio
2025-03-21 16:36                 ` Konstantin Ryabitsev
2025-03-22  3:44                   ` Greg Kroah-Hartman
2025-04-11 12:45                   ` Greg Kroah-Hartman
2025-02-25 10:50   ` AngeloGioacchino Del Regno
2025-02-24 23:21 ` [PATCH 4/7] power: supply: all: " Sebastian Reichel
2025-02-25  2:40   ` Chen-Yu Tsai
2025-02-25  3:39   ` Baolin Wang
2025-02-25 10:47   ` AngeloGioacchino Del Regno
2025-02-24 23:21 ` [PATCH 5/7] power: supply: core: remove of_node from power_supply_config Sebastian Reichel
2025-02-25 10:49   ` AngeloGioacchino Del Regno
2025-02-24 23:21 ` [PATCH 6/7] power: supply: core: battery-info: fully switch to fwnode Sebastian Reichel
2025-02-25 10:49   ` AngeloGioacchino Del Regno
2025-02-24 23:21 ` [PATCH 7/7] power: supply: core: convert to fwnnode Sebastian Reichel
2025-02-25 10:49   ` AngeloGioacchino Del Regno
2025-02-25 13:16   ` Hans de Goede
2025-02-25 21:22     ` Sebastian Reichel
2025-03-08  0:45 ` (subset) [PATCH 0/7] power: supply: core: convert to fwnode 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=bf74173f-ccd9-43c0-a190-68512c6f63cc@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=david@lechnology.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=kernel@puri.sm \
    --cc=konradybcio@kernel.org \
    --cc=krzk@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=matthias.bgg@gmail.com \
    --cc=orsonzhai@gmail.com \
    --cc=pali@kernel.org \
    --cc=paul@crapouillou.net \
    --cc=samuel@sholland.org \
    --cc=sebastian.krzyszkowiak@puri.sm \
    --cc=sebastian.reichel@collabora.com \
    --cc=wens@csie.org \
    --cc=zhang.lyra@gmail.com \
    /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