ibmebus.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. /*
  2. * IBM PowerPC IBM eBus Infrastructure Support.
  3. *
  4. * Copyright (c) 2005 IBM Corporation
  5. * Joachim Fenkes <fenkes@de.ibm.com>
  6. * Heiko J Schick <schickhj@de.ibm.com>
  7. *
  8. * All rights reserved.
  9. *
  10. * This source code is distributed under a dual license of GPL v2.0 and OpenIB
  11. * BSD.
  12. *
  13. * OpenIB BSD License
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions are met:
  17. *
  18. * Redistributions of source code must retain the above copyright notice, this
  19. * list of conditions and the following disclaimer.
  20. *
  21. * Redistributions in binary form must reproduce the above copyright notice,
  22. * this list of conditions and the following disclaimer in the documentation
  23. * and/or other materials
  24. * provided with the distribution.
  25. *
  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
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  33. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  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
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. */
  38. #include <linux/init.h>
  39. #include <linux/console.h>
  40. #include <linux/kobject.h>
  41. #include <linux/dma-mapping.h>
  42. #include <linux/interrupt.h>
  43. #include <linux/of.h>
  44. #include <linux/slab.h>
  45. #include <linux/of_platform.h>
  46. #include <asm/ibmebus.h>
  47. #include <asm/abs_addr.h>
  48. static struct device ibmebus_bus_device = { /* fake "parent" device */
  49. .init_name = "ibmebus",
  50. };
  51. struct bus_type ibmebus_bus_type;
  52. /* These devices will automatically be added to the bus during init */
  53. static struct of_device_id __initdata ibmebus_matches[] = {
  54. { .compatible = "IBM,lhca" },
  55. { .compatible = "IBM,lhea" },
  56. {},
  57. };
  58. static void *ibmebus_alloc_coherent(struct device *dev,
  59. size_t size,
  60. dma_addr_t *dma_handle,
  61. gfp_t flag)
  62. {
  63. void *mem;
  64. mem = kmalloc(size, flag);
  65. *dma_handle = (dma_addr_t)mem;
  66. return mem;
  67. }
  68. static void ibmebus_free_coherent(struct device *dev,
  69. size_t size, void *vaddr,
  70. dma_addr_t dma_handle)
  71. {
  72. kfree(vaddr);
  73. }
  74. static dma_addr_t ibmebus_map_page(struct device *dev,
  75. struct page *page,
  76. unsigned long offset,
  77. size_t size,
  78. enum dma_data_direction direction,
  79. struct dma_attrs *attrs)
  80. {
  81. return (dma_addr_t)(page_address(page) + offset);
  82. }
  83. static void ibmebus_unmap_page(struct device *dev,
  84. dma_addr_t dma_addr,
  85. size_t size,
  86. enum dma_data_direction direction,
  87. struct dma_attrs *attrs)
  88. {
  89. return;
  90. }
  91. static int ibmebus_map_sg(struct device *dev,
  92. struct scatterlist *sgl,
  93. int nents, enum dma_data_direction direction,
  94. struct dma_attrs *attrs)
  95. {
  96. struct scatterlist *sg;
  97. int i;
  98. for_each_sg(sgl, sg, nents, i) {
  99. sg->dma_address = (dma_addr_t) sg_virt(sg);
  100. sg->dma_length = sg->length;
  101. }
  102. return nents;
  103. }
  104. static void ibmebus_unmap_sg(struct device *dev,
  105. struct scatterlist *sg,
  106. int nents, enum dma_data_direction direction,
  107. struct dma_attrs *attrs)
  108. {
  109. return;
  110. }
  111. static int ibmebus_dma_supported(struct device *dev, u64 mask)
  112. {
  113. return 1;
  114. }
  115. static struct dma_map_ops ibmebus_dma_ops = {
  116. .alloc_coherent = ibmebus_alloc_coherent,
  117. .free_coherent = ibmebus_free_coherent,
  118. .map_sg = ibmebus_map_sg,
  119. .unmap_sg = ibmebus_unmap_sg,
  120. .dma_supported = ibmebus_dma_supported,
  121. .map_page = ibmebus_map_page,
  122. .unmap_page = ibmebus_unmap_page,
  123. };
  124. static int ibmebus_match_path(struct device *dev, void *data)
  125. {
  126. struct device_node *dn = to_platform_device(dev)->dev.of_node;
  127. return (dn->full_name &&
  128. (strcasecmp((char *)data, dn->full_name) == 0));
  129. }
  130. static int ibmebus_match_node(struct device *dev, void *data)
  131. {
  132. return to_platform_device(dev)->dev.of_node == data;
  133. }
  134. static int ibmebus_create_device(struct device_node *dn)
  135. {
  136. struct platform_device *dev;
  137. int ret;
  138. dev = of_device_alloc(dn, NULL, &ibmebus_bus_device);
  139. if (!dev)
  140. return -ENOMEM;
  141. dev->dev.bus = &ibmebus_bus_type;
  142. dev->dev.archdata.dma_ops = &ibmebus_dma_ops;
  143. ret = of_device_add(dev);
  144. if (ret)
  145. platform_device_put(dev);
  146. return ret;
  147. }
  148. static int ibmebus_create_devices(const struct of_device_id *matches)
  149. {
  150. struct device_node *root, *child;
  151. int ret = 0;
  152. root = of_find_node_by_path("/");
  153. for_each_child_of_node(root, child) {
  154. if (!of_match_node(matches, child))
  155. continue;
  156. if (bus_find_device(&ibmebus_bus_type, NULL, child,
  157. ibmebus_match_node))
  158. continue;
  159. ret = ibmebus_create_device(child);
  160. if (ret) {
  161. printk(KERN_ERR "%s: failed to create device (%i)",
  162. __func__, ret);
  163. of_node_put(child);
  164. break;
  165. }
  166. }
  167. of_node_put(root);
  168. return ret;
  169. }
  170. int ibmebus_register_driver(struct of_platform_driver *drv)
  171. {
  172. /* If the driver uses devices that ibmebus doesn't know, add them */
  173. ibmebus_create_devices(drv->driver.of_match_table);
  174. drv->driver.bus = &ibmebus_bus_type;
  175. return driver_register(&drv->driver);
  176. }
  177. EXPORT_SYMBOL(ibmebus_register_driver);
  178. void ibmebus_unregister_driver(struct of_platform_driver *drv)
  179. {
  180. driver_unregister(&drv->driver);
  181. }
  182. EXPORT_SYMBOL(ibmebus_unregister_driver);
  183. int ibmebus_request_irq(u32 ist, irq_handler_t handler,
  184. unsigned long irq_flags, const char *devname,
  185. void *dev_id)
  186. {
  187. unsigned int irq = irq_create_mapping(NULL, ist);
  188. if (irq == NO_IRQ)
  189. return -EINVAL;
  190. return request_irq(irq, handler, irq_flags, devname, dev_id);
  191. }
  192. EXPORT_SYMBOL(ibmebus_request_irq);
  193. void ibmebus_free_irq(u32 ist, void *dev_id)
  194. {
  195. unsigned int irq = irq_find_mapping(NULL, ist);
  196. free_irq(irq, dev_id);
  197. irq_dispose_mapping(irq);
  198. }
  199. EXPORT_SYMBOL(ibmebus_free_irq);
  200. static char *ibmebus_chomp(const char *in, size_t count)
  201. {
  202. char *out = kmalloc(count + 1, GFP_KERNEL);
  203. if (!out)
  204. return NULL;
  205. memcpy(out, in, count);
  206. out[count] = '\0';
  207. if (out[count - 1] == '\n')
  208. out[count - 1] = '\0';
  209. return out;
  210. }
  211. static ssize_t ibmebus_store_probe(struct bus_type *bus,
  212. const char *buf, size_t count)
  213. {
  214. struct device_node *dn = NULL;
  215. char *path;
  216. ssize_t rc = 0;
  217. path = ibmebus_chomp(buf, count);
  218. if (!path)
  219. return -ENOMEM;
  220. if (bus_find_device(&ibmebus_bus_type, NULL, path,
  221. ibmebus_match_path)) {
  222. printk(KERN_WARNING "%s: %s has already been probed\n",
  223. __func__, path);
  224. rc = -EEXIST;
  225. goto out;
  226. }
  227. if ((dn = of_find_node_by_path(path))) {
  228. rc = ibmebus_create_device(dn);
  229. of_node_put(dn);
  230. } else {
  231. printk(KERN_WARNING "%s: no such device node: %s\n",
  232. __func__, path);
  233. rc = -ENODEV;
  234. }
  235. out:
  236. kfree(path);
  237. if (rc)
  238. return rc;
  239. return count;
  240. }
  241. static ssize_t ibmebus_store_remove(struct bus_type *bus,
  242. const char *buf, size_t count)
  243. {
  244. struct device *dev;
  245. char *path;
  246. path = ibmebus_chomp(buf, count);
  247. if (!path)
  248. return -ENOMEM;
  249. if ((dev = bus_find_device(&ibmebus_bus_type, NULL, path,
  250. ibmebus_match_path))) {
  251. of_device_unregister(to_platform_device(dev));
  252. kfree(path);
  253. return count;
  254. } else {
  255. printk(KERN_WARNING "%s: %s not on the bus\n",
  256. __func__, path);
  257. kfree(path);
  258. return -ENODEV;
  259. }
  260. }
  261. static struct bus_attribute ibmebus_bus_attrs[] = {
  262. __ATTR(probe, S_IWUSR, NULL, ibmebus_store_probe),
  263. __ATTR(remove, S_IWUSR, NULL, ibmebus_store_remove),
  264. __ATTR_NULL
  265. };
  266. static int ibmebus_bus_bus_match(struct device *dev, struct device_driver *drv)
  267. {
  268. const struct of_device_id *matches = drv->of_match_table;
  269. if (!matches)
  270. return 0;
  271. return of_match_device(matches, dev) != NULL;
  272. }
  273. static int ibmebus_bus_device_probe(struct device *dev)
  274. {
  275. int error = -ENODEV;
  276. struct of_platform_driver *drv;
  277. struct platform_device *of_dev;
  278. const struct of_device_id *match;
  279. drv = to_of_platform_driver(dev->driver);
  280. of_dev = to_platform_device(dev);
  281. if (!drv->probe)
  282. return error;
  283. of_dev_get(of_dev);
  284. match = of_match_device(drv->driver.of_match_table, dev);
  285. if (match)
  286. error = drv->probe(of_dev, match);
  287. if (error)
  288. of_dev_put(of_dev);
  289. return error;
  290. }
  291. static int ibmebus_bus_device_remove(struct device *dev)
  292. {
  293. struct platform_device *of_dev = to_platform_device(dev);
  294. struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
  295. if (dev->driver && drv->remove)
  296. drv->remove(of_dev);
  297. return 0;
  298. }
  299. static void ibmebus_bus_device_shutdown(struct device *dev)
  300. {
  301. struct platform_device *of_dev = to_platform_device(dev);
  302. struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
  303. if (dev->driver && drv->shutdown)
  304. drv->shutdown(of_dev);
  305. }
  306. /*
  307. * ibmebus_bus_device_attrs
  308. */
  309. static ssize_t devspec_show(struct device *dev,
  310. struct device_attribute *attr, char *buf)
  311. {
  312. struct platform_device *ofdev;
  313. ofdev = to_platform_device(dev);
  314. return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name);
  315. }
  316. static ssize_t name_show(struct device *dev,
  317. struct device_attribute *attr, char *buf)
  318. {
  319. struct platform_device *ofdev;
  320. ofdev = to_platform_device(dev);
  321. return sprintf(buf, "%s\n", ofdev->dev.of_node->name);
  322. }
  323. static ssize_t modalias_show(struct device *dev,
  324. struct device_attribute *attr, char *buf)
  325. {
  326. ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2);
  327. buf[len] = '\n';
  328. buf[len+1] = 0;
  329. return len+1;
  330. }
  331. struct device_attribute ibmebus_bus_device_attrs[] = {
  332. __ATTR_RO(devspec),
  333. __ATTR_RO(name),
  334. __ATTR_RO(modalias),
  335. __ATTR_NULL
  336. };
  337. #ifdef CONFIG_PM_SLEEP
  338. static int ibmebus_bus_legacy_suspend(struct device *dev, pm_message_t mesg)
  339. {
  340. struct platform_device *of_dev = to_platform_device(dev);
  341. struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
  342. int ret = 0;
  343. if (dev->driver && drv->suspend)
  344. ret = drv->suspend(of_dev, mesg);
  345. return ret;
  346. }
  347. static int ibmebus_bus_legacy_resume(struct device *dev)
  348. {
  349. struct platform_device *of_dev = to_platform_device(dev);
  350. struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
  351. int ret = 0;
  352. if (dev->driver && drv->resume)
  353. ret = drv->resume(of_dev);
  354. return ret;
  355. }
  356. static int ibmebus_bus_pm_prepare(struct device *dev)
  357. {
  358. struct device_driver *drv = dev->driver;
  359. int ret = 0;
  360. if (drv && drv->pm && drv->pm->prepare)
  361. ret = drv->pm->prepare(dev);
  362. return ret;
  363. }
  364. static void ibmebus_bus_pm_complete(struct device *dev)
  365. {
  366. struct device_driver *drv = dev->driver;
  367. if (drv && drv->pm && drv->pm->complete)
  368. drv->pm->complete(dev);
  369. }
  370. #ifdef CONFIG_SUSPEND
  371. static int ibmebus_bus_pm_suspend(struct device *dev)
  372. {
  373. struct device_driver *drv = dev->driver;
  374. int ret = 0;
  375. if (!drv)
  376. return 0;
  377. if (drv->pm) {
  378. if (drv->pm->suspend)
  379. ret = drv->pm->suspend(dev);
  380. } else {
  381. ret = ibmebus_bus_legacy_suspend(dev, PMSG_SUSPEND);
  382. }
  383. return ret;
  384. }
  385. static int ibmebus_bus_pm_suspend_noirq(struct device *dev)
  386. {
  387. struct device_driver *drv = dev->driver;
  388. int ret = 0;
  389. if (!drv)
  390. return 0;
  391. if (drv->pm) {
  392. if (drv->pm->suspend_noirq)
  393. ret = drv->pm->suspend_noirq(dev);
  394. }
  395. return ret;
  396. }
  397. static int ibmebus_bus_pm_resume(struct device *dev)
  398. {
  399. struct device_driver *drv = dev->driver;
  400. int ret = 0;
  401. if (!drv)
  402. return 0;
  403. if (drv->pm) {
  404. if (drv->pm->resume)
  405. ret = drv->pm->resume(dev);
  406. } else {
  407. ret = ibmebus_bus_legacy_resume(dev);
  408. }
  409. return ret;
  410. }
  411. static int ibmebus_bus_pm_resume_noirq(struct device *dev)
  412. {
  413. struct device_driver *drv = dev->driver;
  414. int ret = 0;
  415. if (!drv)
  416. return 0;
  417. if (drv->pm) {
  418. if (drv->pm->resume_noirq)
  419. ret = drv->pm->resume_noirq(dev);
  420. }
  421. return ret;
  422. }
  423. #else /* !CONFIG_SUSPEND */
  424. #define ibmebus_bus_pm_suspend NULL
  425. #define ibmebus_bus_pm_resume NULL
  426. #define ibmebus_bus_pm_suspend_noirq NULL
  427. #define ibmebus_bus_pm_resume_noirq NULL
  428. #endif /* !CONFIG_SUSPEND */
  429. #ifdef CONFIG_HIBERNATE_CALLBACKS
  430. static int ibmebus_bus_pm_freeze(struct device *dev)
  431. {
  432. struct device_driver *drv = dev->driver;
  433. int ret = 0;
  434. if (!drv)
  435. return 0;
  436. if (drv->pm) {
  437. if (drv->pm->freeze)
  438. ret = drv->pm->freeze(dev);
  439. } else {
  440. ret = ibmebus_bus_legacy_suspend(dev, PMSG_FREEZE);
  441. }
  442. return ret;
  443. }
  444. static int ibmebus_bus_pm_freeze_noirq(struct device *dev)
  445. {
  446. struct device_driver *drv = dev->driver;
  447. int ret = 0;
  448. if (!drv)
  449. return 0;
  450. if (drv->pm) {
  451. if (drv->pm->freeze_noirq)
  452. ret = drv->pm->freeze_noirq(dev);
  453. }
  454. return ret;
  455. }
  456. static int ibmebus_bus_pm_thaw(struct device *dev)
  457. {
  458. struct device_driver *drv = dev->driver;
  459. int ret = 0;
  460. if (!drv)
  461. return 0;
  462. if (drv->pm) {
  463. if (drv->pm->thaw)
  464. ret = drv->pm->thaw(dev);
  465. } else {
  466. ret = ibmebus_bus_legacy_resume(dev);
  467. }
  468. return ret;
  469. }
  470. static int ibmebus_bus_pm_thaw_noirq(struct device *dev)
  471. {
  472. struct device_driver *drv = dev->driver;
  473. int ret = 0;
  474. if (!drv)
  475. return 0;
  476. if (drv->pm) {
  477. if (drv->pm->thaw_noirq)
  478. ret = drv->pm->thaw_noirq(dev);
  479. }
  480. return ret;
  481. }
  482. static int ibmebus_bus_pm_poweroff(struct device *dev)
  483. {
  484. struct device_driver *drv = dev->driver;
  485. int ret = 0;
  486. if (!drv)
  487. return 0;
  488. if (drv->pm) {
  489. if (drv->pm->poweroff)
  490. ret = drv->pm->poweroff(dev);
  491. } else {
  492. ret = ibmebus_bus_legacy_suspend(dev, PMSG_HIBERNATE);
  493. }
  494. return ret;
  495. }
  496. static int ibmebus_bus_pm_poweroff_noirq(struct device *dev)
  497. {
  498. struct device_driver *drv = dev->driver;
  499. int ret = 0;
  500. if (!drv)
  501. return 0;
  502. if (drv->pm) {
  503. if (drv->pm->poweroff_noirq)
  504. ret = drv->pm->poweroff_noirq(dev);
  505. }
  506. return ret;
  507. }
  508. static int ibmebus_bus_pm_restore(struct device *dev)
  509. {
  510. struct device_driver *drv = dev->driver;
  511. int ret = 0;
  512. if (!drv)
  513. return 0;
  514. if (drv->pm) {
  515. if (drv->pm->restore)
  516. ret = drv->pm->restore(dev);
  517. } else {
  518. ret = ibmebus_bus_legacy_resume(dev);
  519. }
  520. return ret;
  521. }
  522. static int ibmebus_bus_pm_restore_noirq(struct device *dev)
  523. {
  524. struct device_driver *drv = dev->driver;
  525. int ret = 0;
  526. if (!drv)
  527. return 0;
  528. if (drv->pm) {
  529. if (drv->pm->restore_noirq)
  530. ret = drv->pm->restore_noirq(dev);
  531. }
  532. return ret;
  533. }
  534. #else /* !CONFIG_HIBERNATE_CALLBACKS */
  535. #define ibmebus_bus_pm_freeze NULL
  536. #define ibmebus_bus_pm_thaw NULL
  537. #define ibmebus_bus_pm_poweroff NULL
  538. #define ibmebus_bus_pm_restore NULL
  539. #define ibmebus_bus_pm_freeze_noirq NULL
  540. #define ibmebus_bus_pm_thaw_noirq NULL
  541. #define ibmebus_bus_pm_poweroff_noirq NULL
  542. #define ibmebus_bus_pm_restore_noirq NULL
  543. #endif /* !CONFIG_HIBERNATE_CALLBACKS */
  544. static struct dev_pm_ops ibmebus_bus_dev_pm_ops = {
  545. .prepare = ibmebus_bus_pm_prepare,
  546. .complete = ibmebus_bus_pm_complete,
  547. .suspend = ibmebus_bus_pm_suspend,
  548. .resume = ibmebus_bus_pm_resume,
  549. .freeze = ibmebus_bus_pm_freeze,
  550. .thaw = ibmebus_bus_pm_thaw,
  551. .poweroff = ibmebus_bus_pm_poweroff,
  552. .restore = ibmebus_bus_pm_restore,
  553. .suspend_noirq = ibmebus_bus_pm_suspend_noirq,
  554. .resume_noirq = ibmebus_bus_pm_resume_noirq,
  555. .freeze_noirq = ibmebus_bus_pm_freeze_noirq,
  556. .thaw_noirq = ibmebus_bus_pm_thaw_noirq,
  557. .poweroff_noirq = ibmebus_bus_pm_poweroff_noirq,
  558. .restore_noirq = ibmebus_bus_pm_restore_noirq,
  559. };
  560. #define IBMEBUS_BUS_PM_OPS_PTR (&ibmebus_bus_dev_pm_ops)
  561. #else /* !CONFIG_PM_SLEEP */
  562. #define IBMEBUS_BUS_PM_OPS_PTR NULL
  563. #endif /* !CONFIG_PM_SLEEP */
  564. struct bus_type ibmebus_bus_type = {
  565. .name = "ibmebus",
  566. .uevent = of_device_uevent,
  567. .bus_attrs = ibmebus_bus_attrs,
  568. .match = ibmebus_bus_bus_match,
  569. .probe = ibmebus_bus_device_probe,
  570. .remove = ibmebus_bus_device_remove,
  571. .shutdown = ibmebus_bus_device_shutdown,
  572. .dev_attrs = ibmebus_bus_device_attrs,
  573. .pm = IBMEBUS_BUS_PM_OPS_PTR,
  574. };
  575. EXPORT_SYMBOL(ibmebus_bus_type);
  576. static int __init ibmebus_bus_init(void)
  577. {
  578. int err;
  579. printk(KERN_INFO "IBM eBus Device Driver\n");
  580. err = bus_register(&ibmebus_bus_type);
  581. if (err) {
  582. printk(KERN_ERR "%s: failed to register IBM eBus.\n",
  583. __func__);
  584. return err;
  585. }
  586. err = device_register(&ibmebus_bus_device);
  587. if (err) {
  588. printk(KERN_WARNING "%s: device_register returned %i\n",
  589. __func__, err);
  590. bus_unregister(&ibmebus_bus_type);
  591. return err;
  592. }
  593. err = ibmebus_create_devices(ibmebus_matches);
  594. if (err) {
  595. device_unregister(&ibmebus_bus_device);
  596. bus_unregister(&ibmebus_bus_type);
  597. return err;
  598. }
  599. return 0;
  600. }
  601. postcore_initcall(ibmebus_bus_init);