aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2010-06-08 09:48:13 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-07-05 18:14:28 -0400
commit34a1c1e8c700f7cd849deb21193718a172722f8d (patch)
tree8cb17243ca49acda328f3561d55b6d3d2f62f0d2 /drivers/of
parentdd27dcda37f0b1a3b674760fb411abc5c8fe309c (diff)
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
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/device.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 275cc9cee14c..c2a98f5ca80d 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -68,10 +68,7 @@ static ssize_t name_show(struct device *dev,
68static ssize_t modalias_show(struct device *dev, 68static ssize_t modalias_show(struct device *dev,
69 struct device_attribute *attr, char *buf) 69 struct device_attribute *attr, char *buf)
70{ 70{
71 struct of_device *ofdev = to_of_device(dev); 71 ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2);
72 ssize_t len = 0;
73
74 len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2);
75 buf[len] = '\n'; 72 buf[len] = '\n';
76 buf[len+1] = 0; 73 buf[len+1] = 0;
77 return len+1; 74 return len+1;
@@ -123,19 +120,18 @@ void of_device_unregister(struct of_device *ofdev)
123} 120}
124EXPORT_SYMBOL(of_device_unregister); 121EXPORT_SYMBOL(of_device_unregister);
125 122
126ssize_t of_device_get_modalias(struct of_device *ofdev, 123ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
127 char *str, ssize_t len)
128{ 124{
129 const char *compat; 125 const char *compat;
130 int cplen, i; 126 int cplen, i;
131 ssize_t tsize, csize, repend; 127 ssize_t tsize, csize, repend;
132 128
133 /* Name & Type */ 129 /* Name & Type */
134 csize = snprintf(str, len, "of:N%sT%s", ofdev->dev.of_node->name, 130 csize = snprintf(str, len, "of:N%sT%s", dev->of_node->name,
135 ofdev->dev.of_node->type); 131 dev->of_node->type);
136 132
137 /* Get compatible property if any */ 133 /* Get compatible property if any */
138 compat = of_get_property(ofdev->dev.of_node, "compatible", &cplen); 134 compat = of_get_property(dev->of_node, "compatible", &cplen);
139 if (!compat) 135 if (!compat)
140 return csize; 136 return csize;
141 137
@@ -210,7 +206,7 @@ int of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
210 if (add_uevent_var(env, "MODALIAS=")) 206 if (add_uevent_var(env, "MODALIAS="))
211 return -ENOMEM; 207 return -ENOMEM;
212 208
213 sl = of_device_get_modalias(to_of_device(dev), &env->buf[env->buflen-1], 209 sl = of_device_get_modalias(dev, &env->buf[env->buflen-1],
214 sizeof(env->buf) - env->buflen); 210 sizeof(env->buf) - env->buflen);
215 if (sl >= (sizeof(env->buf) - env->buflen)) 211 if (sl >= (sizeof(env->buf) - env->buflen))
216 return -ENOMEM; 212 return -ENOMEM;