aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/ibmebus.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel/ibmebus.c')
-rw-r--r--arch/powerpc/kernel/ibmebus.c288
1 files changed, 195 insertions, 93 deletions
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 82bd2f10770f..9a8c9af43b22 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -2,36 +2,37 @@
2 * IBM PowerPC IBM eBus Infrastructure Support. 2 * IBM PowerPC IBM eBus Infrastructure Support.
3 * 3 *
4 * Copyright (c) 2005 IBM Corporation 4 * Copyright (c) 2005 IBM Corporation
5 * Joachim Fenkes <fenkes@de.ibm.com>
5 * Heiko J Schick <schickhj@de.ibm.com> 6 * Heiko J Schick <schickhj@de.ibm.com>
6 * 7 *
7 * All rights reserved. 8 * All rights reserved.
8 * 9 *
9 * This source code is distributed under a dual license of GPL v2.0 and OpenIB 10 * This source code is distributed under a dual license of GPL v2.0 and OpenIB
10 * BSD. 11 * BSD.
11 * 12 *
12 * OpenIB BSD License 13 * OpenIB BSD License
13 * 14 *
14 * Redistribution and use in source and binary forms, with or without 15 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are met: 16 * modification, are permitted provided that the following conditions are met:
16 * 17 *
17 * Redistributions of source code must retain the above copyright notice, this 18 * Redistributions of source code must retain the above copyright notice, this
18 * list of conditions and the following disclaimer. 19 * list of conditions and the following disclaimer.
19 * 20 *
20 * Redistributions in binary form must reproduce the above copyright notice, 21 * Redistributions in binary form must reproduce the above copyright notice,
21 * this list of conditions and the following disclaimer in the documentation 22 * this list of conditions and the following disclaimer in the documentation
22 * and/or other materials 23 * and/or other materials
23 * provided with the distribution. 24 * provided with the distribution.
24 * 25 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 33 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
33 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE. 36 * POSSIBILITY OF SUCH DAMAGE.
36 */ 37 */
37 38
@@ -43,19 +44,19 @@
43#include <asm/ibmebus.h> 44#include <asm/ibmebus.h>
44#include <asm/abs_addr.h> 45#include <asm/abs_addr.h>
45 46
46static struct ibmebus_dev ibmebus_bus_device = { /* fake "parent" device */ 47static struct device ibmebus_bus_device = { /* fake "parent" device */
47 .name = ibmebus_bus_device.ofdev.dev.bus_id, 48 .bus_id = "ibmebus",
48 .ofdev.dev.bus_id = "ibmebus",
49 .ofdev.dev.bus = &ibmebus_bus_type,
50}; 49};
51 50
51struct bus_type ibmebus_bus_type;
52
52static void *ibmebus_alloc_coherent(struct device *dev, 53static void *ibmebus_alloc_coherent(struct device *dev,
53 size_t size, 54 size_t size,
54 dma_addr_t *dma_handle, 55 dma_addr_t *dma_handle,
55 gfp_t flag) 56 gfp_t flag)
56{ 57{
57 void *mem; 58 void *mem;
58 59
59 mem = kmalloc(size, flag); 60 mem = kmalloc(size, flag);
60 *dma_handle = (dma_addr_t)mem; 61 *dma_handle = (dma_addr_t)mem;
61 62
@@ -63,7 +64,7 @@ static void *ibmebus_alloc_coherent(struct device *dev,
63} 64}
64 65
65static void ibmebus_free_coherent(struct device *dev, 66static void ibmebus_free_coherent(struct device *dev,
66 size_t size, void *vaddr, 67 size_t size, void *vaddr,
67 dma_addr_t dma_handle) 68 dma_addr_t dma_handle)
68{ 69{
69 kfree(vaddr); 70 kfree(vaddr);
@@ -79,7 +80,7 @@ static dma_addr_t ibmebus_map_single(struct device *dev,
79 80
80static void ibmebus_unmap_single(struct device *dev, 81static void ibmebus_unmap_single(struct device *dev,
81 dma_addr_t dma_addr, 82 dma_addr_t dma_addr,
82 size_t size, 83 size_t size,
83 enum dma_data_direction direction) 84 enum dma_data_direction direction)
84{ 85{
85 return; 86 return;
@@ -90,13 +91,13 @@ static int ibmebus_map_sg(struct device *dev,
90 int nents, enum dma_data_direction direction) 91 int nents, enum dma_data_direction direction)
91{ 92{
92 int i; 93 int i;
93 94
94 for (i = 0; i < nents; i++) { 95 for (i = 0; i < nents; i++) {
95 sg[i].dma_address = (dma_addr_t)page_address(sg[i].page) 96 sg[i].dma_address = (dma_addr_t)page_address(sg[i].page)
96 + sg[i].offset; 97 + sg[i].offset;
97 sg[i].dma_length = sg[i].length; 98 sg[i].dma_length = sg[i].length;
98 } 99 }
99 100
100 return nents; 101 return nents;
101} 102}
102 103
@@ -128,15 +129,15 @@ static int ibmebus_bus_probe(struct device *dev)
128 struct ibmebus_driver *ibmebusdrv = to_ibmebus_driver(dev->driver); 129 struct ibmebus_driver *ibmebusdrv = to_ibmebus_driver(dev->driver);
129 const struct of_device_id *id; 130 const struct of_device_id *id;
130 int error = -ENODEV; 131 int error = -ENODEV;
131 132
132 if (!ibmebusdrv->probe) 133 if (!ibmebusdrv->probe)
133 return error; 134 return error;
134 135
135 id = of_match_device(ibmebusdrv->id_table, &ibmebusdev->ofdev); 136 id = of_match_device(ibmebusdrv->id_table, &ibmebusdev->ofdev);
136 if (id) { 137 if (id) {
137 error = ibmebusdrv->probe(ibmebusdev, id); 138 error = ibmebusdrv->probe(ibmebusdev, id);
138 } 139 }
139 140
140 return error; 141 return error;
141} 142}
142 143
@@ -144,11 +145,11 @@ static int ibmebus_bus_remove(struct device *dev)
144{ 145{
145 struct ibmebus_dev *ibmebusdev = to_ibmebus_dev(dev); 146 struct ibmebus_dev *ibmebusdev = to_ibmebus_dev(dev);
146 struct ibmebus_driver *ibmebusdrv = to_ibmebus_driver(dev->driver); 147 struct ibmebus_driver *ibmebusdrv = to_ibmebus_driver(dev->driver);
147 148
148 if (ibmebusdrv->remove) { 149 if (ibmebusdrv->remove) {
149 return ibmebusdrv->remove(ibmebusdev); 150 return ibmebusdrv->remove(ibmebusdev);
150 } 151 }
151 152
152 return 0; 153 return 0;
153} 154}
154 155
@@ -158,21 +159,12 @@ static void __devinit ibmebus_dev_release(struct device *dev)
158 kfree(to_ibmebus_dev(dev)); 159 kfree(to_ibmebus_dev(dev));
159} 160}
160 161
161static ssize_t ibmebusdev_show_name(struct device *dev, 162static int __devinit ibmebus_register_device_common(
162 struct device_attribute *attr, char *buf)
163{
164 return sprintf(buf, "%s\n", to_ibmebus_dev(dev)->name);
165}
166static DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, ibmebusdev_show_name,
167 NULL);
168
169static struct ibmebus_dev* __devinit ibmebus_register_device_common(
170 struct ibmebus_dev *dev, const char *name) 163 struct ibmebus_dev *dev, const char *name)
171{ 164{
172 int err = 0; 165 int err = 0;
173 166
174 dev->name = name; 167 dev->ofdev.dev.parent = &ibmebus_bus_device;
175 dev->ofdev.dev.parent = &ibmebus_bus_device.ofdev.dev;
176 dev->ofdev.dev.bus = &ibmebus_bus_type; 168 dev->ofdev.dev.bus = &ibmebus_bus_type;
177 dev->ofdev.dev.release = ibmebus_dev_release; 169 dev->ofdev.dev.release = ibmebus_dev_release;
178 170
@@ -181,17 +173,15 @@ static struct ibmebus_dev* __devinit ibmebus_register_device_common(
181 dev->ofdev.dev.archdata.numa_node = of_node_to_nid(dev->ofdev.node); 173 dev->ofdev.dev.archdata.numa_node = of_node_to_nid(dev->ofdev.node);
182 174
183 /* An ibmebusdev is based on a of_device. We have to change the 175 /* An ibmebusdev is based on a of_device. We have to change the
184 * bus type to use our own DMA mapping operations. 176 * bus type to use our own DMA mapping operations.
185 */ 177 */
186 if ((err = of_device_register(&dev->ofdev)) != 0) { 178 if ((err = of_device_register(&dev->ofdev)) != 0) {
187 printk(KERN_ERR "%s: failed to register device (%d).\n", 179 printk(KERN_ERR "%s: failed to register device (%d).\n",
188 __FUNCTION__, err); 180 __FUNCTION__, err);
189 return NULL; 181 return -ENODEV;
190 } 182 }
191 183
192 device_create_file(&dev->ofdev.dev, &dev_attr_name); 184 return 0;
193
194 return dev;
195} 185}
196 186
197static struct ibmebus_dev* __devinit ibmebus_register_device_node( 187static struct ibmebus_dev* __devinit ibmebus_register_device_node(
@@ -201,35 +191,35 @@ static struct ibmebus_dev* __devinit ibmebus_register_device_node(
201 const char *loc_code; 191 const char *loc_code;
202 int length; 192 int length;
203 193
204 loc_code = get_property(dn, "ibm,loc-code", NULL); 194 loc_code = of_get_property(dn, "ibm,loc-code", NULL);
205 if (!loc_code) { 195 if (!loc_code) {
206 printk(KERN_WARNING "%s: node %s missing 'ibm,loc-code'\n", 196 printk(KERN_WARNING "%s: node %s missing 'ibm,loc-code'\n",
207 __FUNCTION__, dn->name ? dn->name : "<unknown>"); 197 __FUNCTION__, dn->name ? dn->name : "<unknown>");
208 return NULL; 198 return ERR_PTR(-EINVAL);
209 } 199 }
210 200
211 if (strlen(loc_code) == 0) { 201 if (strlen(loc_code) == 0) {
212 printk(KERN_WARNING "%s: 'ibm,loc-code' is invalid\n", 202 printk(KERN_WARNING "%s: 'ibm,loc-code' is invalid\n",
213 __FUNCTION__); 203 __FUNCTION__);
214 return NULL; 204 return ERR_PTR(-EINVAL);
215 } 205 }
216 206
217 dev = kzalloc(sizeof(struct ibmebus_dev), GFP_KERNEL); 207 dev = kzalloc(sizeof(struct ibmebus_dev), GFP_KERNEL);
218 if (!dev) { 208 if (!dev) {
219 return NULL; 209 return ERR_PTR(-ENOMEM);
220 } 210 }
221 211
222 dev->ofdev.node = of_node_get(dn); 212 dev->ofdev.node = of_node_get(dn);
223 213
224 length = strlen(loc_code); 214 length = strlen(loc_code);
225 memcpy(dev->ofdev.dev.bus_id, loc_code 215 memcpy(dev->ofdev.dev.bus_id, loc_code
226 + (length - min(length, BUS_ID_SIZE - 1)), 216 + (length - min(length, BUS_ID_SIZE - 1)),
227 min(length, BUS_ID_SIZE - 1)); 217 min(length, BUS_ID_SIZE - 1));
228 218
229 /* Register with generic device framework. */ 219 /* Register with generic device framework. */
230 if (ibmebus_register_device_common(dev, dn->name) == NULL) { 220 if (ibmebus_register_device_common(dev, dn->name) != 0) {
231 kfree(dev); 221 kfree(dev);
232 return NULL; 222 return ERR_PTR(-ENODEV);
233 } 223 }
234 224
235 return dev; 225 return dev;
@@ -238,17 +228,16 @@ static struct ibmebus_dev* __devinit ibmebus_register_device_node(
238static void ibmebus_probe_of_nodes(char* name) 228static void ibmebus_probe_of_nodes(char* name)
239{ 229{
240 struct device_node *dn = NULL; 230 struct device_node *dn = NULL;
241 231
242 while ((dn = of_find_node_by_name(dn, name))) { 232 while ((dn = of_find_node_by_name(dn, name))) {
243 if (ibmebus_register_device_node(dn) == NULL) { 233 if (IS_ERR(ibmebus_register_device_node(dn))) {
244 of_node_put(dn); 234 of_node_put(dn);
245
246 return; 235 return;
247 } 236 }
248 } 237 }
249 238
250 of_node_put(dn); 239 of_node_put(dn);
251 240
252 return; 241 return;
253} 242}
254 243
@@ -262,17 +251,21 @@ static void ibmebus_add_devices_by_id(struct of_device_id *idt)
262 return; 251 return;
263} 252}
264 253
265static int ibmebus_match_helper(struct device *dev, void *data) 254static int ibmebus_match_name(struct device *dev, void *data)
266{ 255{
267 if (strcmp((char*)data, to_ibmebus_dev(dev)->name) == 0) 256 const struct ibmebus_dev *ebus_dev = to_ibmebus_dev(dev);
257 const char *name;
258
259 name = of_get_property(ebus_dev->ofdev.node, "name", NULL);
260
261 if (name && (strcmp(data, name) == 0))
268 return 1; 262 return 1;
269 263
270 return 0; 264 return 0;
271} 265}
272 266
273static int ibmebus_unregister_device(struct device *dev) 267static int ibmebus_unregister_device(struct device *dev)
274{ 268{
275 device_remove_file(dev, &dev_attr_name);
276 of_device_unregister(to_of_device(dev)); 269 of_device_unregister(to_of_device(dev));
277 270
278 return 0; 271 return 0;
@@ -281,17 +274,16 @@ static int ibmebus_unregister_device(struct device *dev)
281static void ibmebus_remove_devices_by_id(struct of_device_id *idt) 274static void ibmebus_remove_devices_by_id(struct of_device_id *idt)
282{ 275{
283 struct device *dev; 276 struct device *dev;
284 277
285 while (strlen(idt->name) > 0) { 278 while (strlen(idt->name) > 0) {
286 while ((dev = bus_find_device(&ibmebus_bus_type, NULL, 279 while ((dev = bus_find_device(&ibmebus_bus_type, NULL,
287 (void*)idt->name, 280 (void*)idt->name,
288 ibmebus_match_helper))) { 281 ibmebus_match_name))) {
289 ibmebus_unregister_device(dev); 282 ibmebus_unregister_device(dev);
290 } 283 }
291 idt++; 284 idt++;
292
293 } 285 }
294 286
295 return; 287 return;
296} 288}
297 289
@@ -307,30 +299,33 @@ int ibmebus_register_driver(struct ibmebus_driver *drv)
307 if ((err = driver_register(&drv->driver) != 0)) 299 if ((err = driver_register(&drv->driver) != 0))
308 return err; 300 return err;
309 301
302 /* remove all supported devices first, in case someone
303 * probed them manually before registering the driver */
304 ibmebus_remove_devices_by_id(drv->id_table);
310 ibmebus_add_devices_by_id(drv->id_table); 305 ibmebus_add_devices_by_id(drv->id_table);
311 306
312 return 0; 307 return 0;
313} 308}
314EXPORT_SYMBOL(ibmebus_register_driver); 309EXPORT_SYMBOL(ibmebus_register_driver);
315 310
316void ibmebus_unregister_driver(struct ibmebus_driver *drv) 311void ibmebus_unregister_driver(struct ibmebus_driver *drv)
317{ 312{
318 driver_unregister(&drv->driver); 313 driver_unregister(&drv->driver);
319 ibmebus_remove_devices_by_id(drv->id_table); 314 ibmebus_remove_devices_by_id(drv->id_table);
320} 315}
321EXPORT_SYMBOL(ibmebus_unregister_driver); 316EXPORT_SYMBOL(ibmebus_unregister_driver);
322 317
323int ibmebus_request_irq(struct ibmebus_dev *dev, 318int ibmebus_request_irq(struct ibmebus_dev *dev,
324 u32 ist, 319 u32 ist,
325 irq_handler_t handler, 320 irq_handler_t handler,
326 unsigned long irq_flags, const char * devname, 321 unsigned long irq_flags, const char * devname,
327 void *dev_id) 322 void *dev_id)
328{ 323{
329 unsigned int irq = irq_create_mapping(NULL, ist); 324 unsigned int irq = irq_create_mapping(NULL, ist);
330 325
331 if (irq == NO_IRQ) 326 if (irq == NO_IRQ)
332 return -EINVAL; 327 return -EINVAL;
333 328
334 return request_irq(irq, handler, 329 return request_irq(irq, handler,
335 irq_flags, devname, dev_id); 330 irq_flags, devname, dev_id);
336} 331}
@@ -339,56 +334,163 @@ EXPORT_SYMBOL(ibmebus_request_irq);
339void ibmebus_free_irq(struct ibmebus_dev *dev, u32 ist, void *dev_id) 334void ibmebus_free_irq(struct ibmebus_dev *dev, u32 ist, void *dev_id)
340{ 335{
341 unsigned int irq = irq_find_mapping(NULL, ist); 336 unsigned int irq = irq_find_mapping(NULL, ist);
342 337
343 free_irq(irq, dev_id); 338 free_irq(irq, dev_id);
344} 339}
345EXPORT_SYMBOL(ibmebus_free_irq); 340EXPORT_SYMBOL(ibmebus_free_irq);
346 341
347static int ibmebus_bus_match(struct device *dev, struct device_driver *drv) 342static int ibmebus_bus_match(struct device *dev, struct device_driver *drv)
348{ 343{
349 const struct ibmebus_dev *ebus_dev = to_ibmebus_dev(dev); 344 const struct ibmebus_dev *ebus_dev = to_ibmebus_dev(dev);
350 struct ibmebus_driver *ebus_drv = to_ibmebus_driver(drv); 345 struct ibmebus_driver *ebus_drv = to_ibmebus_driver(drv);
351 const struct of_device_id *ids = ebus_drv->id_table; 346 const struct of_device_id *ids = ebus_drv->id_table;
352 const struct of_device_id *found_id; 347 const struct of_device_id *found_id;
353 348
354 if (!ids) 349 if (!ids)
355 return 0; 350 return 0;
356 351
357 found_id = of_match_device(ids, &ebus_dev->ofdev); 352 found_id = of_match_device(ids, &ebus_dev->ofdev);
358 if (found_id) 353 if (found_id)
359 return 1; 354 return 1;
360 355
361 return 0; 356 return 0;
362} 357}
363 358
359static ssize_t name_show(struct device *dev,
360 struct device_attribute *attr, char *buf)
361{
362 struct ibmebus_dev *ebus_dev = to_ibmebus_dev(dev);
363 const char *name = of_get_property(ebus_dev->ofdev.node, "name", NULL);
364 return sprintf(buf, "%s\n", name);
365}
366
367static struct device_attribute ibmebus_dev_attrs[] = {
368 __ATTR_RO(name),
369 __ATTR_NULL
370};
371
372static int ibmebus_match_path(struct device *dev, void *data)
373{
374 int rc;
375 struct device_node *dn =
376 of_node_get(to_ibmebus_dev(dev)->ofdev.node);
377
378 rc = (dn->full_name && (strcasecmp((char*)data, dn->full_name) == 0));
379
380 of_node_put(dn);
381 return rc;
382}
383
384static char *ibmebus_chomp(const char *in, size_t count)
385{
386 char *out = (char*)kmalloc(count + 1, GFP_KERNEL);
387 if (!out)
388 return NULL;
389
390 memcpy(out, in, count);
391 out[count] = '\0';
392 if (out[count - 1] == '\n')
393 out[count - 1] = '\0';
394
395 return out;
396}
397
398static ssize_t ibmebus_store_probe(struct bus_type *bus,
399 const char *buf, size_t count)
400{
401 struct device_node *dn = NULL;
402 struct ibmebus_dev *dev;
403 char *path;
404 ssize_t rc;
405
406 path = ibmebus_chomp(buf, count);
407 if (!path)
408 return -ENOMEM;
409
410 if (bus_find_device(&ibmebus_bus_type, NULL, path,
411 ibmebus_match_path)) {
412 printk(KERN_WARNING "%s: %s has already been probed\n",
413 __FUNCTION__, path);
414 rc = -EINVAL;
415 goto out;
416 }
417
418 if ((dn = of_find_node_by_path(path))) {
419 dev = ibmebus_register_device_node(dn);
420 of_node_put(dn);
421 rc = IS_ERR(dev) ? PTR_ERR(dev) : count;
422 } else {
423 printk(KERN_WARNING "%s: no such device node: %s\n",
424 __FUNCTION__, path);
425 rc = -ENODEV;
426 }
427
428out:
429 kfree(path);
430 return rc;
431}
432
433static ssize_t ibmebus_store_remove(struct bus_type *bus,
434 const char *buf, size_t count)
435{
436 struct device *dev;
437 char *path;
438
439 path = ibmebus_chomp(buf, count);
440 if (!path)
441 return -ENOMEM;
442
443 if ((dev = bus_find_device(&ibmebus_bus_type, NULL, path,
444 ibmebus_match_path))) {
445 ibmebus_unregister_device(dev);
446
447 kfree(path);
448 return count;
449 } else {
450 printk(KERN_WARNING "%s: %s not on the bus\n",
451 __FUNCTION__, path);
452
453 kfree(path);
454 return -ENODEV;
455 }
456}
457
458static struct bus_attribute ibmebus_bus_attrs[] = {
459 __ATTR(probe, S_IWUSR, NULL, ibmebus_store_probe),
460 __ATTR(remove, S_IWUSR, NULL, ibmebus_store_remove),
461 __ATTR_NULL
462};
463
364struct bus_type ibmebus_bus_type = { 464struct bus_type ibmebus_bus_type = {
365 .name = "ibmebus", 465 .name = "ibmebus",
366 .match = ibmebus_bus_match, 466 .match = ibmebus_bus_match,
467 .dev_attrs = ibmebus_dev_attrs,
468 .bus_attrs = ibmebus_bus_attrs
367}; 469};
368EXPORT_SYMBOL(ibmebus_bus_type); 470EXPORT_SYMBOL(ibmebus_bus_type);
369 471
370static int __init ibmebus_bus_init(void) 472static int __init ibmebus_bus_init(void)
371{ 473{
372 int err; 474 int err;
373 475
374 printk(KERN_INFO "IBM eBus Device Driver\n"); 476 printk(KERN_INFO "IBM eBus Device Driver\n");
375 477
376 err = bus_register(&ibmebus_bus_type); 478 err = bus_register(&ibmebus_bus_type);
377 if (err) { 479 if (err) {
378 printk(KERN_ERR ":%s: failed to register IBM eBus.\n", 480 printk(KERN_ERR ":%s: failed to register IBM eBus.\n",
379 __FUNCTION__); 481 __FUNCTION__);
380 return err; 482 return err;
381 } 483 }
382 484
383 err = device_register(&ibmebus_bus_device.ofdev.dev); 485 err = device_register(&ibmebus_bus_device);
384 if (err) { 486 if (err) {
385 printk(KERN_WARNING "%s: device_register returned %i\n", 487 printk(KERN_WARNING "%s: device_register returned %i\n",
386 __FUNCTION__, err); 488 __FUNCTION__, err);
387 bus_unregister(&ibmebus_bus_type); 489 bus_unregister(&ibmebus_bus_type);
388 490
389 return err; 491 return err;
390 } 492 }
391 493
392 return 0; 494 return 0;
393} 495}
394__initcall(ibmebus_bus_init); 496__initcall(ibmebus_bus_init);