From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Sebastian Reichel <sebastian.reichel@collabora.com>,
Sebastian Reichel <sre@kernel.org>,
Mark Brown <broonie@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Linus Walleij <linus.walleij@linaro.org>,
Hans de Goede <hdegoede@redhat.com>
Cc: "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 13:14:03 +0200 [thread overview]
Message-ID: <491e20bb-5ab4-40e9-bb35-5e05dc7bd46c@gmail.com> (raw)
In-Reply-To: <20250225-psy-core-convert-to-fwnode-v1-1-d5e4369936bb@collabora.com>
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.
>
> @@ -1544,9 +1544,8 @@ __power_supply_register(struct device *parent,
> if (cfg) {
> dev->groups = cfg->attr_grp;
> psy->drv_data = cfg->drv_data;
> - psy->of_node =
> + dev->of_node =
> cfg->fwnode ? to_of_node(cfg->fwnode) : cfg->of_node;
> - dev->of_node = psy->of_node;
> psy->supplied_to = cfg->supplied_to;
> psy->num_supplicants = cfg->num_supplicants;
> }
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index 6ed53b292162469d7b357734d5589bff18a201d0..975ccab56597ef579ef0c9dc913dcb0a26b5855a 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -316,7 +316,6 @@ struct power_supply {
>
> char **supplied_from;
> size_t num_supplies;
> - struct device_node *of_node;
>
> /* Driver private data */
> void *drv_data;
>
next prev parent reply other threads:[~2025-02-25 11:14 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 [this message]
2025-02-25 13:11 ` Sebastian Reichel
2025-02-25 13:25 ` Matti Vaittinen
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=491e20bb-5ab4-40e9-bb35-5e05dc7bd46c@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=sre@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.