aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2007-02-12 17:13:26 -0500
committerPaul Mackerras <paulus@samba.org>2007-04-12 13:55:13 -0400
commitcc11645b9d04c3df5180620bded522e14e619604 (patch)
tree42168285c248d8600d4d3311ba7881ab26e60f28
parenteb0cb8a07e320ed3237789cc4f29858338d14d8e (diff)
[POWERPC] powermac: Use the new of_device common uevent handler
The generation of the uevent is now common to all bus using of_device. Signed-off-by: Sylvain Munaut <tnt@246tNt.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r--drivers/macintosh/macio_asic.c98
1 files changed, 1 insertions, 97 deletions
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index d56216067549..e851266a2db1 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -134,108 +134,12 @@ static int macio_device_resume(struct device * dev)
134 return 0; 134 return 0;
135} 135}
136 136
137static int macio_uevent(struct device *dev, char **envp, int num_envp,
138 char *buffer, int buffer_size)
139{
140 struct macio_dev * macio_dev;
141 struct of_device * of;
142 char *scratch;
143 const char *compat, *compat2;
144
145 int i = 0;
146 int length, cplen, cplen2, seen = 0;
147
148 if (!dev)
149 return -ENODEV;
150
151 macio_dev = to_macio_device(dev);
152 if (!macio_dev)
153 return -ENODEV;
154
155 of = &macio_dev->ofdev;
156
157 /* stuff we want to pass to /sbin/hotplug */
158 envp[i++] = scratch = buffer;
159 length = scnprintf (scratch, buffer_size, "OF_NAME=%s", of->node->name);
160 ++length;
161 buffer_size -= length;
162 if ((buffer_size <= 0) || (i >= num_envp))
163 return -ENOMEM;
164 scratch += length;
165
166 envp[i++] = scratch;
167 length = scnprintf (scratch, buffer_size, "OF_TYPE=%s", of->node->type);
168 ++length;
169 buffer_size -= length;
170 if ((buffer_size <= 0) || (i >= num_envp))
171 return -ENOMEM;
172 scratch += length;
173
174 /* Since the compatible field can contain pretty much anything
175 * it's not really legal to split it out with commas. We split it
176 * up using a number of environment variables instead. */
177
178 compat = get_property(of->node, "compatible", &cplen);
179 compat2 = compat;
180 cplen2= cplen;
181 while (compat && cplen > 0) {
182 envp[i++] = scratch;
183 length = scnprintf (scratch, buffer_size,
184 "OF_COMPATIBLE_%d=%s", seen, compat);
185 ++length;
186 buffer_size -= length;
187 if ((buffer_size <= 0) || (i >= num_envp))
188 return -ENOMEM;
189 scratch += length;
190 length = strlen (compat) + 1;
191 compat += length;
192 cplen -= length;
193 seen++;
194 }
195
196 envp[i++] = scratch;
197 length = scnprintf (scratch, buffer_size, "OF_COMPATIBLE_N=%d", seen);
198 ++length;
199 buffer_size -= length;
200 if ((buffer_size <= 0) || (i >= num_envp))
201 return -ENOMEM;
202 scratch += length;
203
204 envp[i++] = scratch;
205 length = scnprintf (scratch, buffer_size, "MODALIAS=of:N%sT%s",
206 of->node->name, of->node->type);
207 /* overwrite '\0' */
208 buffer_size -= length;
209 if ((buffer_size <= 0) || (i >= num_envp))
210 return -ENOMEM;
211 scratch += length;
212
213 if (!compat2) {
214 compat2 = "";
215 cplen2 = 1;
216 }
217 while (cplen2 > 0) {
218 length = snprintf (scratch, buffer_size, "C%s", compat2);
219 buffer_size -= length;
220 if (buffer_size <= 0)
221 return -ENOMEM;
222 scratch += length;
223 length = strlen (compat2) + 1;
224 compat2 += length;
225 cplen2 -= length;
226 }
227
228 envp[i] = NULL;
229
230 return 0;
231}
232
233extern struct device_attribute macio_dev_attrs[]; 137extern struct device_attribute macio_dev_attrs[];
234 138
235struct bus_type macio_bus_type = { 139struct bus_type macio_bus_type = {
236 .name = "macio", 140 .name = "macio",
237 .match = macio_bus_match, 141 .match = macio_bus_match,
238 .uevent = macio_uevent, 142 .uevent = of_device_uevent,
239 .probe = macio_device_probe, 143 .probe = macio_device_probe,
240 .remove = macio_device_remove, 144 .remove = macio_device_remove,
241 .shutdown = macio_device_shutdown, 145 .shutdown = macio_device_shutdown,