@@ -246,48 +246,6 @@ const void *of_device_get_match_data(const struct device *dev)
}
EXPORT_SYMBOL(of_device_get_match_data);
-/**
- * of_device_uevent - Display OF related uevent information
- * @dev: Device to display the uevent information for
- * @env: Kernel object's userspace event reference to fill up
- */
-void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env)
-{
- const char *compat, *type;
- struct alias_prop *app;
- struct property *p;
- int seen = 0;
-
- if ((!dev) || (!dev->of_node))
- return;
-
- add_uevent_var(env, "OF_NAME=%pOFn", dev->of_node);
- add_uevent_var(env, "OF_FULLNAME=%pOF", dev->of_node);
- type = of_node_get_device_type(dev->of_node);
- if (type)
- add_uevent_var(env, "OF_TYPE=%s", type);
-
- /* Since the compatible field can contain pretty much anything
- * it's not really legal to split it out with commas. We split it
- * up using a number of environment variables instead. */
- of_property_for_each_string(dev->of_node, "compatible", p, compat) {
- add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat);
- seen++;
- }
- add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen);
-
- seen = 0;
- mutex_lock(&of_mutex);
- list_for_each_entry(app, &aliases_lookup, link) {
- if (dev->of_node == app->np) {
- add_uevent_var(env, "OF_ALIAS_%d=%s", seen,
- app->alias);
- seen++;
- }
- }
- mutex_unlock(&of_mutex);
-}
-
int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env)
{
int sl;
@@ -8,6 +8,8 @@
#include <linux/slab.h>
#include <linux/string.h>
+#include "of_private.h"
+
ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
{
const char *compat;
@@ -91,3 +93,42 @@ int of_request_module(const struct device_node *np)
return ret;
}
EXPORT_SYMBOL_GPL(of_request_module);
+
+int of_uevent(struct device_node *np, struct kobj_uevent_env *env)
+{
+ const char *compat, *type;
+ struct alias_prop *app;
+ struct property *p;
+ int seen = 0;
+
+ if (!np)
+ return -ENODEV;
+
+ add_uevent_var(env, "OF_NAME=%pOFn", np);
+ add_uevent_var(env, "OF_FULLNAME=%pOF", np);
+ type = of_node_get_device_type(np);
+ if (type)
+ add_uevent_var(env, "OF_TYPE=%s", type);
+
+ /* Since the compatible field can contain pretty much anything
+ * it's not really legal to split it out with commas. We split it
+ * up using a number of environment variables instead. */
+ of_property_for_each_string(np, "compatible", p, compat) {
+ add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat);
+ seen++;
+ }
+ add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen);
+
+ seen = 0;
+ mutex_lock(&of_mutex);
+ list_for_each_entry(app, &aliases_lookup, link) {
+ if (np == app->np) {
+ add_uevent_var(env, "OF_ALIAS_%d=%s", seen,
+ app->alias);
+ seen++;
+ }
+ }
+ mutex_unlock(&of_mutex);
+
+ return 0;
+}
@@ -388,6 +388,7 @@ extern ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
extern ssize_t of_printable_modalias(const struct device_node *np, char *str,
ssize_t len);
extern int of_request_module(const struct device_node *np);
+extern int of_uevent(struct device_node *np, struct kobj_uevent_env *env);
/* phandle iterator functions */
extern int of_phandle_iterator_init(struct of_phandle_iterator *it,
@@ -771,6 +772,11 @@ static inline int of_request_module(const struct device_node *np)
return -ENODEV;
}
+static inline int of_uevent(struct device_node *np, struct kobj_uevent_env *env)
+{
+ return -ENODEV;
+}
+
static inline int of_phandle_iterator_init(struct of_phandle_iterator *it,
const struct device_node *np,
const char *list_name,
@@ -35,7 +35,15 @@ static inline ssize_t of_device_modalias(struct device *dev, char *str,
return of_printable_modalias(dev->of_node, str, len);
}
-extern void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env);
+static inline int of_device_uevent(const struct device *dev,
+ struct kobj_uevent_env *env)
+{
+ if (!dev || !dev->of_node)
+ return -ENODEV;
+
+ return of_uevent(dev->of_node, env);
+}
+
extern int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env);
int of_dma_configure_id(struct device *dev,
@@ -55,8 +63,11 @@ static inline int of_driver_match_device(struct device *dev,
return 0;
}
-static inline void of_device_uevent(const struct device *dev,
- struct kobj_uevent_env *env) { }
+static inline int of_device_uevent(const struct device *dev,
+ struct kobj_uevent_env *env)
+{
+ return -ENODEV;
+}
static inline ssize_t of_device_modalias(struct device *dev,
char *str, ssize_t len)
Move the OF related logic inside of/module.c and use it from of_device.h with an inline helper so there is no visible change from the users point of view. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> --- drivers/of/device.c | 42 --------------------------------------- drivers/of/module.c | 41 ++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 6 ++++++ include/linux/of_device.h | 17 +++++++++++++--- 4 files changed, 61 insertions(+), 45 deletions(-)