lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 15 Sep 2023 09:02:14 +0200
From:   Vincent Whitchurch <vincent.whitchurch@...s.com>
To:     Sebastian Reichel <sre@...nel.org>
CC:     <linux-pm@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <kernel@...s.com>, Vincent Whitchurch <vincent.whitchurch@...s.com>
Subject: [PATCH v2] power: supply: Propagate of_node to child device

Ensure that the dynamically created power supply device sets its
->of_node if the driver supplies one.  This brings it in line with
several other subsystems (see git grep 'of_node =.*parent.*of_node') and
allows easier identification of the device from udev rules and similar.

Before this patch:

 /sys/class/power_supply# ls -l bq256xx-battery/of_node
 ls: cannot access 'bq256xx-battery/of_node': No such file or directory
 # ls -l bq256xx-battery/hwmon1/of_node
 ls: cannot access 'bq256xx-battery/hwmon1/of_node': No such file or directory

After:

 /sys/class/power_supply# ls -l bq256xx-battery/of_node
 lrwxrwxrwx 1 root root 0 May 17 09:14 bq256xx-battery/of_node ->
 ../../../../../../../../firmware/devicetree/base/virtio@...2c/bq25619@09
 # ls -l bq256xx-battery/hwmon1/of_node
 lrwxrwxrwx 1 root root 0 May 17 09:14 bq256xx-battery/hwmon1/of_node ->
 ../../../../../../../../../firmware/devicetree/base/virtio@...2c/bq25619@09

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@...s.com>
---
Changes in v2:
- Use psy->of_node instead of parent node.
- Link to v1: https://lore.kernel.org/r/20230704-power-of-v1-1-cc82d2eda65b@axis.com
---
 drivers/power/supply/power_supply_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 0b69fb7bafd8..ab20bc660f00 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -1380,6 +1380,7 @@ __power_supply_register(struct device *parent,
 		psy->drv_data = cfg->drv_data;
 		psy->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;
 	}

---
base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d
change-id: 20230704-power-of-4e2ab0bbe48d

Best regards,
-- 
Vincent Whitchurch <vincent.whitchurch@...s.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ