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-prev] [day] [month] [year] [list]
Message-Id: <20191216141909.30063-3-lukasz.luba@arm.com>
Date:   Mon, 16 Dec 2019 14:19:09 +0000
From:   lukasz.luba@....com
To:     linux-kernel@...r.kernel.org, rui.zhang@...el.com,
        daniel.lezcano@...aro.org, linux-pm@...r.kernel.org
Cc:     amit.kucheria@...durent.com, lukasz.luba@....com,
        dietmar.eggemann@....com
Subject: [PATCH  2/2] thermal: devfreq_cooling: Add device node reclaiming in devfreq_cooling_register()

From: Lukasz Luba <lukasz.luba@....com>

Since the devfreq device parent might have the proper device node, devfreq
cooling registration can re-use it. This will allow thermal bind function
to pin thermal zone with cooling device based on definition in the device
tree automatically. It will simplify registration of cooling device in
drivers code.
Fix also 'unregister path' and add IS_ERR_OR_NULL() check.

Signed-off-by: Lukasz Luba <lukasz.luba@....com>
---
 drivers/thermal/devfreq_cooling.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c
index 1861241c7ef5..c29056cb4a71 100644
--- a/drivers/thermal/devfreq_cooling.c
+++ b/drivers/thermal/devfreq_cooling.c
@@ -574,7 +574,24 @@ EXPORT_SYMBOL_GPL(of_devfreq_cooling_register);
  */
 struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df)
 {
-	return of_devfreq_cooling_register(NULL, df);
+	struct thermal_cooling_device *dfc;
+	struct device_node *np = NULL;
+	struct device *dev;
+
+	if (IS_ERR_OR_NULL(df))
+		return ERR_PTR(-EINVAL);
+
+	dev = df->dev.parent;
+
+	if (dev && dev->of_node)
+		np = of_node_get(dev->of_node);
+
+	dfc = of_devfreq_cooling_register(np, df);
+
+	if (np)
+		of_node_put(np);
+
+	return dfc;
 }
 EXPORT_SYMBOL_GPL(devfreq_cooling_register);
 
@@ -586,7 +603,7 @@ void devfreq_cooling_unregister(struct thermal_cooling_device *cdev)
 {
 	struct devfreq_cooling_device *dfc;
 
-	if (!cdev)
+	if (IS_ERR_OR_NULL(cdev))
 		return;
 
 	dfc = cdev->devdata;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ