@@ -246,31 +246,6 @@ const void *of_device_get_match_data(const struct device *dev)
}
EXPORT_SYMBOL(of_device_get_match_data);
-/**
- * of_device_modalias - Fill buffer with newline terminated modalias string
- * @dev: Calling device
- * @str: Modalias string
- * @len: Size of @str
- */
-ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len)
-{
- ssize_t sl;
-
- if (!dev || !dev->of_node || dev->of_node_reused)
- return -ENODEV;
-
- sl = of_modalias(dev->of_node, str, len - 2);
- if (sl < 0)
- return sl;
- if (sl > len - 2)
- return -ENOMEM;
-
- str[sl++] = '\n';
- str[sl] = 0;
- return sl;
-}
-EXPORT_SYMBOL_GPL(of_device_modalias);
-
/**
* of_device_uevent - Display OF related uevent information
* @dev: Device to display the uevent information for
@@ -44,6 +44,25 @@ ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
return tsize;
}
+ssize_t of_printable_modalias(const struct device_node *np, char *str, ssize_t len)
+{
+ ssize_t sl;
+
+ if (!np)
+ return -ENODEV;
+
+ sl = of_modalias(np, str, len - 2);
+ if (sl < 0)
+ return sl;
+ if (sl > len - 2)
+ return -ENOMEM;
+
+ str[sl++] = '\n';
+ str[sl] = 0;
+ return sl;
+}
+EXPORT_SYMBOL_GPL(of_printable_modalias);
+
int of_request_module(const struct device_node *np)
{
char *str;
@@ -385,6 +385,8 @@ extern int of_count_phandle_with_args(const struct device_node *np,
/* module functions */
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);
/* phandle iterator functions */
@@ -758,6 +760,12 @@ static inline ssize_t of_modalias(const struct device_node *np, char *str,
return -ENODEV;
}
+static inline ssize_t of_printable_modalias(const struct device_node *np,
+ char *str, ssize_t len)
+{
+ return -ENODEV;
+}
+
static inline int of_request_module(const struct device_node *np)
{
return -ENODEV;
@@ -26,7 +26,14 @@ static inline int of_driver_match_device(struct device *dev,
return of_match_device(drv->of_match_table, dev) != NULL;
}
-extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);
+static inline ssize_t of_device_modalias(struct device *dev, char *str,
+ ssize_t len)
+{
+ if (!dev || !dev->of_node || dev->of_node_reused)
+ return -ENODEV;
+
+ return of_printable_modalias(dev->of_node, str, len);
+}
extern void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env);
extern int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env);
@@ -51,8 +58,8 @@ static inline int of_driver_match_device(struct device *dev,
static inline void of_device_uevent(const struct device *dev,
struct kobj_uevent_env *env) { }
-static inline int of_device_modalias(struct device *dev,
- char *str, ssize_t len)
+static inline ssize_t of_device_modalias(struct device *dev,
+ char *str, ssize_t len)
{
return -ENODEV;
}
Move the content of the helper providing printable modaliases in module.c. Call this new function from an of_device.c inline helper. There is no functional changes. However, as a side effect, we fix the return value of the inline helper (in the !CONFIG_OF case) which should be a ssize_t instead of int. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> --- drivers/of/device.c | 25 ------------------------- drivers/of/module.c | 19 +++++++++++++++++++ include/linux/of.h | 8 ++++++++ include/linux/of_device.h | 13 ++++++++++--- 4 files changed, 37 insertions(+), 28 deletions(-)