Commit 0634c295 authored by Rob Herring's avatar Rob Herring

of: Add function for generating a DT modalias with a newline

The modalias sysfs attr is lacking a newline for DT aliases on platform
devices. The macio and ibmebus correctly add the newline, but open code it.
Introduce a new function, of_device_modalias(), that fills the buffer with
the modalias including the newline and update users of the old
of_device_get_modalias function.
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bcf54d53
...@@ -410,10 +410,7 @@ static ssize_t name_show(struct device *dev, ...@@ -410,10 +410,7 @@ static ssize_t name_show(struct device *dev,
static ssize_t modalias_show(struct device *dev, static ssize_t modalias_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2); return of_device_modalias(dev, buf, PAGE_SIZE);
buf[len] = '\n';
buf[len+1] = 0;
return len+1;
} }
static struct device_attribute ibmebus_bus_device_attrs[] = { static struct device_attribute ibmebus_bus_device_attrs[] = {
......
...@@ -847,7 +847,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a, ...@@ -847,7 +847,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
int len; int len;
len = of_device_get_modalias(dev, buf, PAGE_SIZE -1); len = of_device_modalias(dev, buf, PAGE_SIZE);
if (len != -ENODEV) if (len != -ENODEV)
return len; return len;
......
...@@ -41,12 +41,7 @@ compatible_show (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -41,12 +41,7 @@ compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t modalias_show (struct device *dev, struct device_attribute *attr, static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
int len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2); return of_device_modalias(dev, buf, PAGE_SIZE);
buf[len] = '\n';
buf[len+1] = 0;
return len+1;
} }
static ssize_t devspec_show(struct device *dev, static ssize_t devspec_show(struct device *dev,
......
...@@ -176,7 +176,7 @@ const void *of_device_get_match_data(const struct device *dev) ...@@ -176,7 +176,7 @@ const void *of_device_get_match_data(const struct device *dev)
} }
EXPORT_SYMBOL(of_device_get_match_data); EXPORT_SYMBOL(of_device_get_match_data);
ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len) static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
{ {
const char *compat; const char *compat;
int cplen, i; int cplen, i;
...@@ -225,7 +225,6 @@ ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len) ...@@ -225,7 +225,6 @@ ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
return repend; return repend;
} }
EXPORT_SYMBOL_GPL(of_device_get_modalias);
int of_device_request_module(struct device *dev) int of_device_request_module(struct device *dev)
{ {
...@@ -250,6 +249,21 @@ int of_device_request_module(struct device *dev) ...@@ -250,6 +249,21 @@ int of_device_request_module(struct device *dev)
} }
EXPORT_SYMBOL_GPL(of_device_request_module); EXPORT_SYMBOL_GPL(of_device_request_module);
/**
* of_device_modalias - Fill buffer with newline terminated modalias string
*/
ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len)
{
ssize_t sl = of_device_get_modalias(dev, str, len - 2);
if (sl < 0)
return sl;
str[sl++] = '\n';
str[sl] = 0;
return sl;
}
EXPORT_SYMBOL_GPL(of_device_modalias);
/** /**
* of_device_uevent - Display OF related uevent information * of_device_uevent - Display OF related uevent information
*/ */
......
...@@ -191,10 +191,7 @@ static int serdev_drv_remove(struct device *dev) ...@@ -191,10 +191,7 @@ static int serdev_drv_remove(struct device *dev)
static ssize_t modalias_show(struct device *dev, static ssize_t modalias_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2); return of_device_modalias(dev, buf, PAGE_SIZE);
buf[len] = '\n';
buf[len+1] = 0;
return len+1;
} }
static struct device_attribute serdev_device_attrs[] = { static struct device_attribute serdev_device_attrs[] = {
......
...@@ -107,7 +107,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, ...@@ -107,7 +107,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
int len; int len;
struct ulpi *ulpi = to_ulpi_dev(dev); struct ulpi *ulpi = to_ulpi_dev(dev);
len = of_device_get_modalias(dev, buf, PAGE_SIZE - 1); len = of_device_modalias(dev, buf, PAGE_SIZE);
if (len != -ENODEV) if (len != -ENODEV)
return len; return len;
......
...@@ -34,8 +34,7 @@ extern void of_device_unregister(struct platform_device *ofdev); ...@@ -34,8 +34,7 @@ extern void of_device_unregister(struct platform_device *ofdev);
extern const void *of_device_get_match_data(const struct device *dev); extern const void *of_device_get_match_data(const struct device *dev);
extern ssize_t of_device_get_modalias(struct device *dev, extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);
char *str, ssize_t len);
extern int of_device_request_module(struct device *dev); extern int of_device_request_module(struct device *dev);
extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env); extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
...@@ -72,7 +71,7 @@ static inline const void *of_device_get_match_data(const struct device *dev) ...@@ -72,7 +71,7 @@ static inline const void *of_device_get_match_data(const struct device *dev)
return NULL; return NULL;
} }
static inline int of_device_get_modalias(struct device *dev, static inline int of_device_modalias(struct device *dev,
char *str, ssize_t len) char *str, ssize_t len)
{ {
return -ENODEV; return -ENODEV;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment