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: Rob Herring <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Frank Rowand <[email protected]>
Cc: [email protected]
Acked-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
Rob Herring 2017-03-22 09:16:27 -05:00
commit 0634c29589
7 changed files with 24 additions and 22 deletions

View file

@ -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,
char *buf)
{
int len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2);
buf[len] = '\n';
buf[len+1] = 0;
return len+1;
return of_device_modalias(dev, buf, PAGE_SIZE);
}
static ssize_t devspec_show(struct device *dev,