of: Modify of_device_get_modalias to be passed struct device
Now that the of_node pointer is part of struct device, of_device_get_modalias could be used on any struct device that has the device node pointer set. This patch changes of_device_get_modalias to accept a struct device instead of a struct of_device. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> CC: Michal Simek <monstr@monstr.eu> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org> CC: Wolfram Sang <w.sang@pengutronix.de> CC: Stephen Rothwell <sfr@canb.auug.org.au> CC: microblaze-uclinux@itee.uq.edu.au CC: linuxppc-dev@ozlabs.org
This commit is contained in:
Родитель
dd27dcda37
Коммит
34a1c1e8c7
|
@ -15,9 +15,6 @@
|
|||
#include <linux/device.h>
|
||||
#include <linux/of.h>
|
||||
|
||||
extern ssize_t of_device_get_modalias(struct of_device *ofdev,
|
||||
char *str, ssize_t len);
|
||||
|
||||
extern struct of_device *of_device_alloc(struct device_node *np,
|
||||
const char *bus_id,
|
||||
struct device *parent);
|
||||
|
|
|
@ -41,10 +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)
|
||||
{
|
||||
struct of_device *ofdev = to_of_device(dev);
|
||||
int len;
|
||||
|
||||
len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2);
|
||||
int len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2);
|
||||
|
||||
buf[len] = '\n';
|
||||
buf[len+1] = 0;
|
||||
|
|
|
@ -68,10 +68,7 @@ static ssize_t name_show(struct device *dev,
|
|||
static ssize_t modalias_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct of_device *ofdev = to_of_device(dev);
|
||||
ssize_t len = 0;
|
||||
|
||||
len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2);
|
||||
ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2);
|
||||
buf[len] = '\n';
|
||||
buf[len+1] = 0;
|
||||
return len+1;
|
||||
|
@ -123,19 +120,18 @@ void of_device_unregister(struct of_device *ofdev)
|
|||
}
|
||||
EXPORT_SYMBOL(of_device_unregister);
|
||||
|
||||
ssize_t of_device_get_modalias(struct of_device *ofdev,
|
||||
char *str, ssize_t len)
|
||||
ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
|
||||
{
|
||||
const char *compat;
|
||||
int cplen, i;
|
||||
ssize_t tsize, csize, repend;
|
||||
|
||||
/* Name & Type */
|
||||
csize = snprintf(str, len, "of:N%sT%s", ofdev->dev.of_node->name,
|
||||
ofdev->dev.of_node->type);
|
||||
csize = snprintf(str, len, "of:N%sT%s", dev->of_node->name,
|
||||
dev->of_node->type);
|
||||
|
||||
/* Get compatible property if any */
|
||||
compat = of_get_property(ofdev->dev.of_node, "compatible", &cplen);
|
||||
compat = of_get_property(dev->of_node, "compatible", &cplen);
|
||||
if (!compat)
|
||||
return csize;
|
||||
|
||||
|
@ -210,7 +206,7 @@ int of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
|
|||
if (add_uevent_var(env, "MODALIAS="))
|
||||
return -ENOMEM;
|
||||
|
||||
sl = of_device_get_modalias(to_of_device(dev), &env->buf[env->buflen-1],
|
||||
sl = of_device_get_modalias(dev, &env->buf[env->buflen-1],
|
||||
sizeof(env->buf) - env->buflen);
|
||||
if (sl >= (sizeof(env->buf) - env->buflen))
|
||||
return -ENOMEM;
|
||||
|
|
|
@ -42,7 +42,7 @@ static inline void of_device_free(struct of_device *dev)
|
|||
of_release_dev(&dev->dev);
|
||||
}
|
||||
|
||||
extern ssize_t of_device_get_modalias(struct of_device *ofdev,
|
||||
extern ssize_t of_device_get_modalias(struct device *dev,
|
||||
char *str, ssize_t len);
|
||||
|
||||
extern int of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
|
||||
|
|
Загрузка…
Ссылка в новой задаче