PowerPC: adapt for dma_map_ops changes
[deliverable/linux.git] / arch / powerpc / kernel / ibmebus.c
CommitLineData
d7a30103
HS
1/*
2 * IBM PowerPC IBM eBus Infrastructure Support.
3 *
4 * Copyright (c) 2005 IBM Corporation
6bccf755 5 * Joachim Fenkes <fenkes@de.ibm.com>
d7a30103 6 * Heiko J Schick <schickhj@de.ibm.com>
a8308800 7 *
d7a30103
HS
8 * All rights reserved.
9 *
a8308800
JF
10 * This source code is distributed under a dual license of GPL v2.0 and OpenIB
11 * BSD.
d7a30103
HS
12 *
13 * OpenIB BSD License
14 *
a8308800
JF
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are met:
d7a30103 17 *
a8308800
JF
18 * Redistributions of source code must retain the above copyright notice, this
19 * list of conditions and the following disclaimer.
d7a30103 20 *
a8308800
JF
21 * Redistributions in binary form must reproduce the above copyright notice,
22 * this list of conditions and the following disclaimer in the documentation
d7a30103 23 * and/or other materials
a8308800 24 * provided with the distribution.
d7a30103 25 *
a8308800
JF
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
d7a30103
HS
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
33 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
a8308800
JF
34 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
d7a30103
HS
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#include <linux/init.h>
66b15db6 40#include <linux/export.h>
d7a30103
HS
41#include <linux/console.h>
42#include <linux/kobject.h>
43#include <linux/dma-mapping.h>
44#include <linux/interrupt.h>
283029d1 45#include <linux/of.h>
5a0e3ad6 46#include <linux/slab.h>
b56eade5 47#include <linux/stat.h>
a988c0a6 48#include <linux/of_platform.h>
d7a30103
HS
49#include <asm/ibmebus.h>
50#include <asm/abs_addr.h>
51
6bccf755 52static struct device ibmebus_bus_device = { /* fake "parent" device */
aab0d375 53 .init_name = "ibmebus",
d7a30103
HS
54};
55
6bccf755
JF
56struct bus_type ibmebus_bus_type;
57
55347cc9 58/* These devices will automatically be added to the bus during init */
1b17adf1 59static struct of_device_id __initdata ibmebus_matches[] = {
55347cc9
JF
60 { .compatible = "IBM,lhca" },
61 { .compatible = "IBM,lhea" },
62 {},
63};
64
d7a30103
HS
65static void *ibmebus_alloc_coherent(struct device *dev,
66 size_t size,
67 dma_addr_t *dma_handle,
bfbf7d61
AP
68 gfp_t flag,
69 struct dma_attrs *attrs)
d7a30103
HS
70{
71 void *mem;
a8308800 72
d7a30103
HS
73 mem = kmalloc(size, flag);
74 *dma_handle = (dma_addr_t)mem;
75
76 return mem;
77}
78
79static void ibmebus_free_coherent(struct device *dev,
a8308800 80 size_t size, void *vaddr,
bfbf7d61
AP
81 dma_addr_t dma_handle,
82 struct dma_attrs *attrs)
d7a30103
HS
83{
84 kfree(vaddr);
85}
86
f9226d57
MN
87static dma_addr_t ibmebus_map_page(struct device *dev,
88 struct page *page,
89 unsigned long offset,
90 size_t size,
91 enum dma_data_direction direction,
92 struct dma_attrs *attrs)
d7a30103 93{
f9226d57 94 return (dma_addr_t)(page_address(page) + offset);
d7a30103
HS
95}
96
f9226d57
MN
97static void ibmebus_unmap_page(struct device *dev,
98 dma_addr_t dma_addr,
99 size_t size,
100 enum dma_data_direction direction,
101 struct dma_attrs *attrs)
d7a30103
HS
102{
103 return;
104}
105
106static int ibmebus_map_sg(struct device *dev,
78bdc310 107 struct scatterlist *sgl,
3affedc4
MN
108 int nents, enum dma_data_direction direction,
109 struct dma_attrs *attrs)
d7a30103 110{
78bdc310 111 struct scatterlist *sg;
d7a30103 112 int i;
a8308800 113
78bdc310 114 for_each_sg(sgl, sg, nents, i) {
58b053e4 115 sg->dma_address = (dma_addr_t) sg_virt(sg);
78bdc310 116 sg->dma_length = sg->length;
d7a30103 117 }
a8308800 118
d7a30103
HS
119 return nents;
120}
121
122static void ibmebus_unmap_sg(struct device *dev,
123 struct scatterlist *sg,
3affedc4
MN
124 int nents, enum dma_data_direction direction,
125 struct dma_attrs *attrs)
d7a30103
HS
126{
127 return;
128}
129
130static int ibmebus_dma_supported(struct device *dev, u64 mask)
131{
d24f9c69
MM
132 return mask == DMA_BIT_MASK(64);
133}
134
135static u64 ibmebus_dma_get_required_mask(struct device *dev)
136{
137 return DMA_BIT_MASK(64);
d7a30103
HS
138}
139
45223c54 140static struct dma_map_ops ibmebus_dma_ops = {
bfbf7d61
AP
141 .alloc = ibmebus_alloc_coherent,
142 .free = ibmebus_free_coherent,
2eccacd0
MM
143 .map_sg = ibmebus_map_sg,
144 .unmap_sg = ibmebus_unmap_sg,
145 .dma_supported = ibmebus_dma_supported,
d24f9c69 146 .get_required_mask = ibmebus_dma_get_required_mask,
2eccacd0
MM
147 .map_page = ibmebus_map_page,
148 .unmap_page = ibmebus_unmap_page,
d7a30103
HS
149};
150
55347cc9
JF
151static int ibmebus_match_path(struct device *dev, void *data)
152{
a454dc50 153 struct device_node *dn = to_platform_device(dev)->dev.of_node;
55347cc9
JF
154 return (dn->full_name &&
155 (strcasecmp((char *)data, dn->full_name) == 0));
156}
157
158static int ibmebus_match_node(struct device *dev, void *data)
159{
a454dc50 160 return to_platform_device(dev)->dev.of_node == data;
55347cc9
JF
161}
162
163static int ibmebus_create_device(struct device_node *dn)
164{
a454dc50 165 struct platform_device *dev;
55347cc9
JF
166 int ret;
167
168 dev = of_device_alloc(dn, NULL, &ibmebus_bus_device);
169 if (!dev)
170 return -ENOMEM;
171
172 dev->dev.bus = &ibmebus_bus_type;
173 dev->dev.archdata.dma_ops = &ibmebus_dma_ops;
174
7096d042
GL
175 ret = of_device_add(dev);
176 if (ret)
177 platform_device_put(dev);
178 return ret;
55347cc9
JF
179}
180
181static int ibmebus_create_devices(const struct of_device_id *matches)
182{
183 struct device_node *root, *child;
184 int ret = 0;
185
186 root = of_find_node_by_path("/");
187
85e99b9f 188 for_each_child_of_node(root, child) {
55347cc9
JF
189 if (!of_match_node(matches, child))
190 continue;
191
192 if (bus_find_device(&ibmebus_bus_type, NULL, child,
193 ibmebus_match_node))
194 continue;
195
196 ret = ibmebus_create_device(child);
197 if (ret) {
198 printk(KERN_ERR "%s: failed to create device (%i)",
e48b1b45 199 __func__, ret);
55347cc9
JF
200 of_node_put(child);
201 break;
202 }
203 }
204
205 of_node_put(root);
206 return ret;
207}
208
6b08f3ae 209int ibmebus_register_driver(struct of_platform_driver *drv)
d7a30103 210{
6b08f3ae 211 /* If the driver uses devices that ibmebus doesn't know, add them */
597b9d1e 212 ibmebus_create_devices(drv->driver.of_match_table);
6b08f3ae 213
710ac54b
GL
214 drv->driver.bus = &ibmebus_bus_type;
215 return driver_register(&drv->driver);
d7a30103
HS
216}
217EXPORT_SYMBOL(ibmebus_register_driver);
218
6b08f3ae 219void ibmebus_unregister_driver(struct of_platform_driver *drv)
a8308800 220{
710ac54b 221 driver_unregister(&drv->driver);
d7a30103
HS
222}
223EXPORT_SYMBOL(ibmebus_unregister_driver);
224
6b08f3ae
JF
225int ibmebus_request_irq(u32 ist, irq_handler_t handler,
226 unsigned long irq_flags, const char *devname,
d7a30103
HS
227 void *dev_id)
228{
6e99e458 229 unsigned int irq = irq_create_mapping(NULL, ist);
a8308800 230
d7a30103
HS
231 if (irq == NO_IRQ)
232 return -EINVAL;
a8308800 233
6b08f3ae 234 return request_irq(irq, handler, irq_flags, devname, dev_id);
d7a30103
HS
235}
236EXPORT_SYMBOL(ibmebus_request_irq);
237
6b08f3ae 238void ibmebus_free_irq(u32 ist, void *dev_id)
d7a30103 239{
0ebfff14 240 unsigned int irq = irq_find_mapping(NULL, ist);
a8308800 241
d7a30103 242 free_irq(irq, dev_id);
6358d6cb 243 irq_dispose_mapping(irq);
d7a30103
HS
244}
245EXPORT_SYMBOL(ibmebus_free_irq);
246
0727702a
JF
247static char *ibmebus_chomp(const char *in, size_t count)
248{
61a564fd
JJ
249 char *out = kmalloc(count + 1, GFP_KERNEL);
250
0727702a
JF
251 if (!out)
252 return NULL;
253
254 memcpy(out, in, count);
255 out[count] = '\0';
256 if (out[count - 1] == '\n')
257 out[count - 1] = '\0';
258
259 return out;
6bccf755
JF
260}
261
262static ssize_t ibmebus_store_probe(struct bus_type *bus,
263 const char *buf, size_t count)
264{
265 struct device_node *dn = NULL;
0727702a 266 char *path;
55347cc9 267 ssize_t rc = 0;
0727702a
JF
268
269 path = ibmebus_chomp(buf, count);
270 if (!path)
271 return -ENOMEM;
272
273 if (bus_find_device(&ibmebus_bus_type, NULL, path,
74c9b99d 274 ibmebus_match_path)) {
0727702a 275 printk(KERN_WARNING "%s: %s has already been probed\n",
e48b1b45 276 __func__, path);
74c9b99d 277 rc = -EEXIST;
0727702a 278 goto out;
6bccf755
JF
279 }
280
0727702a 281 if ((dn = of_find_node_by_path(path))) {
55347cc9 282 rc = ibmebus_create_device(dn);
0727702a 283 of_node_put(dn);
0727702a
JF
284 } else {
285 printk(KERN_WARNING "%s: no such device node: %s\n",
e48b1b45 286 __func__, path);
0727702a 287 rc = -ENODEV;
6bccf755
JF
288 }
289
0727702a
JF
290out:
291 kfree(path);
55347cc9
JF
292 if (rc)
293 return rc;
294 return count;
6bccf755
JF
295}
296
297static ssize_t ibmebus_store_remove(struct bus_type *bus,
298 const char *buf, size_t count)
299{
300 struct device *dev;
0727702a 301 char *path;
6bccf755 302
0727702a
JF
303 path = ibmebus_chomp(buf, count);
304 if (!path)
305 return -ENOMEM;
306
307 if ((dev = bus_find_device(&ibmebus_bus_type, NULL, path,
308 ibmebus_match_path))) {
a454dc50 309 of_device_unregister(to_platform_device(dev));
0727702a
JF
310
311 kfree(path);
312 return count;
6bccf755 313 } else {
0727702a 314 printk(KERN_WARNING "%s: %s not on the bus\n",
e48b1b45 315 __func__, path);
0727702a
JF
316
317 kfree(path);
6bccf755
JF
318 return -ENODEV;
319 }
6bccf755
JF
320}
321
710ac54b 322
6bccf755
JF
323static struct bus_attribute ibmebus_bus_attrs[] = {
324 __ATTR(probe, S_IWUSR, NULL, ibmebus_store_probe),
325 __ATTR(remove, S_IWUSR, NULL, ibmebus_store_remove),
326 __ATTR_NULL
327};
328
710ac54b
GL
329static int ibmebus_bus_bus_match(struct device *dev, struct device_driver *drv)
330{
331 const struct of_device_id *matches = drv->of_match_table;
332
333 if (!matches)
334 return 0;
335
336 return of_match_device(matches, dev) != NULL;
337}
338
339static int ibmebus_bus_device_probe(struct device *dev)
340{
341 int error = -ENODEV;
342 struct of_platform_driver *drv;
343 struct platform_device *of_dev;
344 const struct of_device_id *match;
345
346 drv = to_of_platform_driver(dev->driver);
347 of_dev = to_platform_device(dev);
348
349 if (!drv->probe)
350 return error;
351
352 of_dev_get(of_dev);
353
354 match = of_match_device(drv->driver.of_match_table, dev);
355 if (match)
356 error = drv->probe(of_dev, match);
357 if (error)
358 of_dev_put(of_dev);
359
360 return error;
361}
362
363static int ibmebus_bus_device_remove(struct device *dev)
364{
365 struct platform_device *of_dev = to_platform_device(dev);
366 struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
367
368 if (dev->driver && drv->remove)
369 drv->remove(of_dev);
370 return 0;
371}
372
373static void ibmebus_bus_device_shutdown(struct device *dev)
374{
375 struct platform_device *of_dev = to_platform_device(dev);
376 struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
377
378 if (dev->driver && drv->shutdown)
379 drv->shutdown(of_dev);
380}
381
382/*
383 * ibmebus_bus_device_attrs
384 */
385static ssize_t devspec_show(struct device *dev,
386 struct device_attribute *attr, char *buf)
387{
388 struct platform_device *ofdev;
389
390 ofdev = to_platform_device(dev);
391 return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name);
392}
393
394static ssize_t name_show(struct device *dev,
395 struct device_attribute *attr, char *buf)
396{
397 struct platform_device *ofdev;
398
399 ofdev = to_platform_device(dev);
400 return sprintf(buf, "%s\n", ofdev->dev.of_node->name);
401}
402
403static ssize_t modalias_show(struct device *dev,
404 struct device_attribute *attr, char *buf)
405{
406 ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2);
407 buf[len] = '\n';
408 buf[len+1] = 0;
409 return len+1;
410}
411
412struct device_attribute ibmebus_bus_device_attrs[] = {
413 __ATTR_RO(devspec),
414 __ATTR_RO(name),
415 __ATTR_RO(modalias),
416 __ATTR_NULL
417};
418
419#ifdef CONFIG_PM_SLEEP
420static int ibmebus_bus_legacy_suspend(struct device *dev, pm_message_t mesg)
421{
422 struct platform_device *of_dev = to_platform_device(dev);
423 struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
424 int ret = 0;
425
426 if (dev->driver && drv->suspend)
427 ret = drv->suspend(of_dev, mesg);
428 return ret;
429}
430
431static int ibmebus_bus_legacy_resume(struct device *dev)
432{
433 struct platform_device *of_dev = to_platform_device(dev);
434 struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
435 int ret = 0;
436
437 if (dev->driver && drv->resume)
438 ret = drv->resume(of_dev);
439 return ret;
440}
441
442static int ibmebus_bus_pm_prepare(struct device *dev)
443{
444 struct device_driver *drv = dev->driver;
445 int ret = 0;
446
447 if (drv && drv->pm && drv->pm->prepare)
448 ret = drv->pm->prepare(dev);
449
450 return ret;
451}
452
453static void ibmebus_bus_pm_complete(struct device *dev)
454{
455 struct device_driver *drv = dev->driver;
456
457 if (drv && drv->pm && drv->pm->complete)
458 drv->pm->complete(dev);
459}
460
461#ifdef CONFIG_SUSPEND
462
463static int ibmebus_bus_pm_suspend(struct device *dev)
464{
465 struct device_driver *drv = dev->driver;
466 int ret = 0;
467
468 if (!drv)
469 return 0;
470
471 if (drv->pm) {
472 if (drv->pm->suspend)
473 ret = drv->pm->suspend(dev);
474 } else {
475 ret = ibmebus_bus_legacy_suspend(dev, PMSG_SUSPEND);
476 }
477
478 return ret;
479}
480
481static int ibmebus_bus_pm_suspend_noirq(struct device *dev)
482{
483 struct device_driver *drv = dev->driver;
484 int ret = 0;
485
486 if (!drv)
487 return 0;
488
489 if (drv->pm) {
490 if (drv->pm->suspend_noirq)
491 ret = drv->pm->suspend_noirq(dev);
492 }
493
494 return ret;
495}
496
497static int ibmebus_bus_pm_resume(struct device *dev)
498{
499 struct device_driver *drv = dev->driver;
500 int ret = 0;
501
502 if (!drv)
503 return 0;
504
505 if (drv->pm) {
506 if (drv->pm->resume)
507 ret = drv->pm->resume(dev);
508 } else {
509 ret = ibmebus_bus_legacy_resume(dev);
510 }
511
512 return ret;
513}
514
515static int ibmebus_bus_pm_resume_noirq(struct device *dev)
516{
517 struct device_driver *drv = dev->driver;
518 int ret = 0;
519
520 if (!drv)
521 return 0;
522
523 if (drv->pm) {
524 if (drv->pm->resume_noirq)
525 ret = drv->pm->resume_noirq(dev);
526 }
527
528 return ret;
529}
530
531#else /* !CONFIG_SUSPEND */
532
533#define ibmebus_bus_pm_suspend NULL
534#define ibmebus_bus_pm_resume NULL
535#define ibmebus_bus_pm_suspend_noirq NULL
536#define ibmebus_bus_pm_resume_noirq NULL
537
538#endif /* !CONFIG_SUSPEND */
539
1f112cee 540#ifdef CONFIG_HIBERNATE_CALLBACKS
710ac54b
GL
541
542static int ibmebus_bus_pm_freeze(struct device *dev)
543{
544 struct device_driver *drv = dev->driver;
545 int ret = 0;
546
547 if (!drv)
548 return 0;
549
550 if (drv->pm) {
551 if (drv->pm->freeze)
552 ret = drv->pm->freeze(dev);
553 } else {
554 ret = ibmebus_bus_legacy_suspend(dev, PMSG_FREEZE);
555 }
556
557 return ret;
558}
559
560static int ibmebus_bus_pm_freeze_noirq(struct device *dev)
561{
562 struct device_driver *drv = dev->driver;
563 int ret = 0;
564
565 if (!drv)
566 return 0;
567
568 if (drv->pm) {
569 if (drv->pm->freeze_noirq)
570 ret = drv->pm->freeze_noirq(dev);
571 }
572
573 return ret;
574}
575
576static int ibmebus_bus_pm_thaw(struct device *dev)
577{
578 struct device_driver *drv = dev->driver;
579 int ret = 0;
580
581 if (!drv)
582 return 0;
583
584 if (drv->pm) {
585 if (drv->pm->thaw)
586 ret = drv->pm->thaw(dev);
587 } else {
588 ret = ibmebus_bus_legacy_resume(dev);
589 }
590
591 return ret;
592}
593
594static int ibmebus_bus_pm_thaw_noirq(struct device *dev)
595{
596 struct device_driver *drv = dev->driver;
597 int ret = 0;
598
599 if (!drv)
600 return 0;
601
602 if (drv->pm) {
603 if (drv->pm->thaw_noirq)
604 ret = drv->pm->thaw_noirq(dev);
605 }
606
607 return ret;
608}
609
610static int ibmebus_bus_pm_poweroff(struct device *dev)
611{
612 struct device_driver *drv = dev->driver;
613 int ret = 0;
614
615 if (!drv)
616 return 0;
617
618 if (drv->pm) {
619 if (drv->pm->poweroff)
620 ret = drv->pm->poweroff(dev);
621 } else {
622 ret = ibmebus_bus_legacy_suspend(dev, PMSG_HIBERNATE);
623 }
624
625 return ret;
626}
627
628static int ibmebus_bus_pm_poweroff_noirq(struct device *dev)
629{
630 struct device_driver *drv = dev->driver;
631 int ret = 0;
632
633 if (!drv)
634 return 0;
635
636 if (drv->pm) {
637 if (drv->pm->poweroff_noirq)
638 ret = drv->pm->poweroff_noirq(dev);
639 }
640
641 return ret;
642}
643
644static int ibmebus_bus_pm_restore(struct device *dev)
645{
646 struct device_driver *drv = dev->driver;
647 int ret = 0;
648
649 if (!drv)
650 return 0;
651
652 if (drv->pm) {
653 if (drv->pm->restore)
654 ret = drv->pm->restore(dev);
655 } else {
656 ret = ibmebus_bus_legacy_resume(dev);
657 }
658
659 return ret;
660}
661
662static int ibmebus_bus_pm_restore_noirq(struct device *dev)
663{
664 struct device_driver *drv = dev->driver;
665 int ret = 0;
666
667 if (!drv)
668 return 0;
669
670 if (drv->pm) {
671 if (drv->pm->restore_noirq)
672 ret = drv->pm->restore_noirq(dev);
673 }
674
675 return ret;
676}
677
1f112cee 678#else /* !CONFIG_HIBERNATE_CALLBACKS */
710ac54b
GL
679
680#define ibmebus_bus_pm_freeze NULL
681#define ibmebus_bus_pm_thaw NULL
682#define ibmebus_bus_pm_poweroff NULL
683#define ibmebus_bus_pm_restore NULL
684#define ibmebus_bus_pm_freeze_noirq NULL
685#define ibmebus_bus_pm_thaw_noirq NULL
686#define ibmebus_bus_pm_poweroff_noirq NULL
687#define ibmebus_bus_pm_restore_noirq NULL
688
1f112cee 689#endif /* !CONFIG_HIBERNATE_CALLBACKS */
710ac54b
GL
690
691static struct dev_pm_ops ibmebus_bus_dev_pm_ops = {
692 .prepare = ibmebus_bus_pm_prepare,
693 .complete = ibmebus_bus_pm_complete,
694 .suspend = ibmebus_bus_pm_suspend,
695 .resume = ibmebus_bus_pm_resume,
696 .freeze = ibmebus_bus_pm_freeze,
697 .thaw = ibmebus_bus_pm_thaw,
698 .poweroff = ibmebus_bus_pm_poweroff,
699 .restore = ibmebus_bus_pm_restore,
700 .suspend_noirq = ibmebus_bus_pm_suspend_noirq,
701 .resume_noirq = ibmebus_bus_pm_resume_noirq,
702 .freeze_noirq = ibmebus_bus_pm_freeze_noirq,
703 .thaw_noirq = ibmebus_bus_pm_thaw_noirq,
704 .poweroff_noirq = ibmebus_bus_pm_poweroff_noirq,
705 .restore_noirq = ibmebus_bus_pm_restore_noirq,
706};
707
708#define IBMEBUS_BUS_PM_OPS_PTR (&ibmebus_bus_dev_pm_ops)
709
710#else /* !CONFIG_PM_SLEEP */
711
712#define IBMEBUS_BUS_PM_OPS_PTR NULL
713
714#endif /* !CONFIG_PM_SLEEP */
715
d7a30103 716struct bus_type ibmebus_bus_type = {
710ac54b 717 .name = "ibmebus",
55347cc9 718 .uevent = of_device_uevent,
710ac54b
GL
719 .bus_attrs = ibmebus_bus_attrs,
720 .match = ibmebus_bus_bus_match,
721 .probe = ibmebus_bus_device_probe,
722 .remove = ibmebus_bus_device_remove,
723 .shutdown = ibmebus_bus_device_shutdown,
724 .dev_attrs = ibmebus_bus_device_attrs,
725 .pm = IBMEBUS_BUS_PM_OPS_PTR,
d7a30103
HS
726};
727EXPORT_SYMBOL(ibmebus_bus_type);
728
729static int __init ibmebus_bus_init(void)
730{
731 int err;
a8308800 732
d7a30103 733 printk(KERN_INFO "IBM eBus Device Driver\n");
a8308800 734
710ac54b 735 err = bus_register(&ibmebus_bus_type);
d7a30103 736 if (err) {
a988c0a6 737 printk(KERN_ERR "%s: failed to register IBM eBus.\n",
e48b1b45 738 __func__);
d7a30103
HS
739 return err;
740 }
a8308800 741
6bccf755 742 err = device_register(&ibmebus_bus_device);
d7a30103 743 if (err) {
a8308800 744 printk(KERN_WARNING "%s: device_register returned %i\n",
e48b1b45 745 __func__, err);
d7a30103
HS
746 bus_unregister(&ibmebus_bus_type);
747
748 return err;
749 }
a8308800 750
1b17adf1 751 err = ibmebus_create_devices(ibmebus_matches);
55347cc9
JF
752 if (err) {
753 device_unregister(&ibmebus_bus_device);
754 bus_unregister(&ibmebus_bus_type);
755 return err;
756 }
757
d7a30103
HS
758 return 0;
759}
a988c0a6 760postcore_initcall(ibmebus_bus_init);
This page took 0.603949 seconds and 5 git commands to generate.