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] [thread-next>] [day] [month] [year] [list]
Date:   Wed,  1 Mar 2023 16:22:34 +0100
From:   Miquel Raynal <miquel.raynal@...tlin.com>
To:     Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
        <linux-kernel@...r.kernel.org>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Michael Walle <michael@...le.cc>, devicetree@...r.kernel.org,
        Rob Herring <robh+dt@...nel.org>,
        Frank Rowand <frowand.list@...il.com>,
        Robert Marko <robert.marko@...tura.hr>,
        Luka Perkov <luka.perkov@...tura.hr>,
        Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
        rafal@...ecki.pl, Miquel Raynal <miquel.raynal@...tlin.com>
Subject: [PATCH 3/8] of: Create an of_device_request_module() receiving an OF node

of_device_request_module() currently receives a "struct device" as main
argument, but the only use of this pointer is to access its .of_node
member. In practice, this function only needs a "struct
device_node". Let's move the logic into another helper which would
receive a "struct device_node" instead, and use that new helper from the
ancient of_device_request_module(). Exporting this new function will be
useful to request module loading when the "struct device" is not
available.

Signed-off-by: Miquel Raynal <miquel.raynal@...tlin.com>
---
 drivers/of/device.c       | 17 +++++++++++++----
 include/linux/of_device.h |  6 ++++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/of/device.c b/drivers/of/device.c
index 3efc17de1d57..7cdf252b9526 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -284,16 +284,16 @@ static ssize_t of_device_get_modalias(struct device_node *np, char *str, ssize_t
 	return tsize;
 }
 
-int of_device_request_module(struct device *dev)
+int of_device_node_request_module(struct device_node *np)
 {
 	char *str;
 	ssize_t size;
 	int ret;
 
-	if (!dev || !dev->of_node)
+	if (!np)
 		return -ENODEV;
 
-	size = of_device_get_modalias(dev->of_node, NULL, 0);
+	size = of_device_get_modalias(np, NULL, 0);
 	if (size < 0)
 		return size;
 
@@ -304,13 +304,22 @@ int of_device_request_module(struct device *dev)
 	if (!str)
 		return -ENOMEM;
 
-	of_device_get_modalias(dev->of_node, str, size);
+	of_device_get_modalias(np, str, size);
 	str[size - 1] = '\0';
 	ret = request_module(str);
 	kfree(str);
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(of_device_node_request_module);
+
+int of_device_request_module(struct device *dev)
+{
+	if (!dev)
+		return -ENODEV;
+
+	return of_device_node_request_module(dev->of_node);
+}
 EXPORT_SYMBOL_GPL(of_device_request_module);
 
 /**
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index ab7d557d541d..8918f9071ffb 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -33,6 +33,7 @@ extern void of_device_unregister(struct platform_device *ofdev);
 extern const void *of_device_get_match_data(const struct device *dev);
 
 extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);
+extern int of_device_node_request_module(struct device_node *np);
 extern int of_device_request_module(struct device *dev);
 
 extern void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env);
@@ -78,6 +79,11 @@ static inline int of_device_modalias(struct device *dev,
 	return -ENODEV;
 }
 
+static inline int of_device_node_request_module(struct device_node *np)
+{
+	return -ENODEV;
+}
+
 static inline int of_device_request_module(struct device *dev)
 {
 	return -ENODEV;
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ