aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/microblaze/include/asm/of_device.h3
-rw-r--r--arch/microblaze/kernel/of_device.c48
-rw-r--r--arch/powerpc/include/asm/of_device.h3
-rw-r--r--arch/powerpc/kernel/of_device.c49
-rw-r--r--drivers/of/device.c48
-rw-r--r--include/linux/of_device.h4
6 files changed, 52 insertions, 103 deletions
diff --git a/arch/microblaze/include/asm/of_device.h b/arch/microblaze/include/asm/of_device.h
index 0a5f3f914b42..58e627dc1412 100644
--- a/arch/microblaze/include/asm/of_device.h
+++ b/arch/microblaze/include/asm/of_device.h
@@ -22,9 +22,6 @@ extern struct of_device *of_device_alloc(struct device_node *np,
22 const char *bus_id, 22 const char *bus_id,
23 struct device *parent); 23 struct device *parent);
24 24
25extern int of_device_uevent(struct device *dev,
26 struct kobj_uevent_env *env);
27
28extern void of_device_make_bus_id(struct of_device *dev); 25extern void of_device_make_bus_id(struct of_device *dev);
29 26
30/* This is just here during the transition */ 27/* This is just here during the transition */
diff --git a/arch/microblaze/kernel/of_device.c b/arch/microblaze/kernel/of_device.c
index b372787886ed..3a367d788451 100644
--- a/arch/microblaze/kernel/of_device.c
+++ b/arch/microblaze/kernel/of_device.c
@@ -62,51 +62,3 @@ struct of_device *of_device_alloc(struct device_node *np,
62 return dev; 62 return dev;
63} 63}
64EXPORT_SYMBOL(of_device_alloc); 64EXPORT_SYMBOL(of_device_alloc);
65
66int of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
67{
68 struct of_device *ofdev;
69 const char *compat;
70 int seen = 0, cplen, sl;
71
72 if (!dev)
73 return -ENODEV;
74
75 ofdev = to_of_device(dev);
76
77 if (add_uevent_var(env, "OF_NAME=%s", ofdev->dev.of_node->name))
78 return -ENOMEM;
79
80 if (add_uevent_var(env, "OF_TYPE=%s", ofdev->dev.of_node->type))
81 return -ENOMEM;
82
83 /* Since the compatible field can contain pretty much anything
84 * it's not really legal to split it out with commas. We split it
85 * up using a number of environment variables instead. */
86
87 compat = of_get_property(ofdev->dev.of_node, "compatible", &cplen);
88 while (compat && *compat && cplen > 0) {
89 if (add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat))
90 return -ENOMEM;
91
92 sl = strlen(compat) + 1;
93 compat += sl;
94 cplen -= sl;
95 seen++;
96 }
97
98 if (add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen))
99 return -ENOMEM;
100
101 /* modalias is trickier, we add it in 2 steps */
102 if (add_uevent_var(env, "MODALIAS="))
103 return -ENOMEM;
104 sl = of_device_get_modalias(ofdev, &env->buf[env->buflen-1],
105 sizeof(env->buf) - env->buflen);
106 if (sl >= (sizeof(env->buf) - env->buflen))
107 return -ENOMEM;
108 env->buflen += sl;
109
110 return 0;
111}
112EXPORT_SYMBOL(of_device_uevent);
diff --git a/arch/powerpc/include/asm/of_device.h b/arch/powerpc/include/asm/of_device.h
index cb36632f953c..5d5103cac641 100644
--- a/arch/powerpc/include/asm/of_device.h
+++ b/arch/powerpc/include/asm/of_device.h
@@ -9,8 +9,5 @@ extern struct of_device *of_device_alloc(struct device_node *np,
9 const char *bus_id, 9 const char *bus_id,
10 struct device *parent); 10 struct device *parent);
11 11
12extern int of_device_uevent(struct device *dev,
13 struct kobj_uevent_env *env);
14
15#endif /* __KERNEL__ */ 12#endif /* __KERNEL__ */
16#endif /* _ASM_POWERPC_OF_DEVICE_H */ 13#endif /* _ASM_POWERPC_OF_DEVICE_H */
diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c
index df78e0236a02..db91a9dbafb5 100644
--- a/arch/powerpc/kernel/of_device.c
+++ b/arch/powerpc/kernel/of_device.c
@@ -82,52 +82,3 @@ struct of_device *of_device_alloc(struct device_node *np,
82 return dev; 82 return dev;
83} 83}
84EXPORT_SYMBOL(of_device_alloc); 84EXPORT_SYMBOL(of_device_alloc);
85
86int of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
87{
88 struct of_device *ofdev;
89 const char *compat;
90 int seen = 0, cplen, sl;
91
92 if (!dev)
93 return -ENODEV;
94
95 ofdev = to_of_device(dev);
96
97 if (add_uevent_var(env, "OF_NAME=%s", ofdev->dev.of_node->name))
98 return -ENOMEM;
99
100 if (add_uevent_var(env, "OF_TYPE=%s", ofdev->dev.of_node->type))
101 return -ENOMEM;
102
103 /* Since the compatible field can contain pretty much anything
104 * it's not really legal to split it out with commas. We split it
105 * up using a number of environment variables instead. */
106
107 compat = of_get_property(ofdev->dev.of_node, "compatible", &cplen);
108 while (compat && *compat && cplen > 0) {
109 if (add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat))
110 return -ENOMEM;
111
112 sl = strlen (compat) + 1;
113 compat += sl;
114 cplen -= sl;
115 seen++;
116 }
117
118 if (add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen))
119 return -ENOMEM;
120
121 /* modalias is trickier, we add it in 2 steps */
122 if (add_uevent_var(env, "MODALIAS="))
123 return -ENOMEM;
124 sl = of_device_get_modalias(ofdev, &env->buf[env->buflen-1],
125 sizeof(env->buf) - env->buflen);
126 if (sl >= (sizeof(env->buf) - env->buflen))
127 return -ENOMEM;
128 env->buflen += sl;
129
130 return 0;
131}
132EXPORT_SYMBOL(of_device_uevent);
133EXPORT_SYMBOL(of_device_get_modalias);
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 7d18f8e0b013..275cc9cee14c 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -170,3 +170,51 @@ ssize_t of_device_get_modalias(struct of_device *ofdev,
170 170
171 return tsize; 171 return tsize;
172} 172}
173
174/**
175 * of_device_uevent - Display OF related uevent information
176 */
177int of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
178{
179 const char *compat;
180 int seen = 0, cplen, sl;
181
182 if ((!dev) || (!dev->of_node))
183 return -ENODEV;
184
185 if (add_uevent_var(env, "OF_NAME=%s", dev->of_node->name))
186 return -ENOMEM;
187
188 if (add_uevent_var(env, "OF_TYPE=%s", dev->of_node->type))
189 return -ENOMEM;
190
191 /* Since the compatible field can contain pretty much anything
192 * it's not really legal to split it out with commas. We split it
193 * up using a number of environment variables instead. */
194
195 compat = of_get_property(dev->of_node, "compatible", &cplen);
196 while (compat && *compat && cplen > 0) {
197 if (add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat))
198 return -ENOMEM;
199
200 sl = strlen(compat) + 1;
201 compat += sl;
202 cplen -= sl;
203 seen++;
204 }
205
206 if (add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen))
207 return -ENOMEM;
208
209 /* modalias is trickier, we add it in 2 steps */
210 if (add_uevent_var(env, "MODALIAS="))
211 return -ENOMEM;
212
213 sl = of_device_get_modalias(to_of_device(dev), &env->buf[env->buflen-1],
214 sizeof(env->buf) - env->buflen);
215 if (sl >= (sizeof(env->buf) - env->buflen))
216 return -ENOMEM;
217 env->buflen += sl;
218
219 return 0;
220}
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index a3ae5900fc58..da83e734c026 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -44,6 +44,10 @@ static inline void of_device_free(struct of_device *dev)
44 44
45extern ssize_t of_device_get_modalias(struct of_device *ofdev, 45extern ssize_t of_device_get_modalias(struct of_device *ofdev,
46 char *str, ssize_t len); 46 char *str, ssize_t len);
47
48extern int of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
49
50
47#endif /* CONFIG_OF_DEVICE */ 51#endif /* CONFIG_OF_DEVICE */
48 52
49#endif /* _LINUX_OF_DEVICE_H */ 53#endif /* _LINUX_OF_DEVICE_H */