platform.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. /*
  2. * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
  3. * <benh@kernel.crashing.org>
  4. * and Arnd Bergmann, IBM Corp.
  5. * Merged from powerpc/kernel/of_platform.c and
  6. * sparc{,64}/kernel/of_device.c by Stephen Rothwell
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. *
  13. */
  14. #include <linux/errno.h>
  15. #include <linux/module.h>
  16. #include <linux/device.h>
  17. #include <linux/dma-mapping.h>
  18. #include <linux/slab.h>
  19. #include <linux/of_address.h>
  20. #include <linux/of_device.h>
  21. #include <linux/of_irq.h>
  22. #include <linux/of_platform.h>
  23. #include <linux/platform_device.h>
  24. static int platform_driver_probe_shim(struct platform_device *pdev)
  25. {
  26. struct platform_driver *pdrv;
  27. struct of_platform_driver *ofpdrv;
  28. const struct of_device_id *match;
  29. pdrv = container_of(pdev->dev.driver, struct platform_driver, driver);
  30. ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver);
  31. match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev);
  32. return ofpdrv->probe(pdev, match);
  33. }
  34. static void platform_driver_shutdown_shim(struct platform_device *pdev)
  35. {
  36. struct platform_driver *pdrv;
  37. struct of_platform_driver *ofpdrv;
  38. pdrv = container_of(pdev->dev.driver, struct platform_driver, driver);
  39. ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver);
  40. ofpdrv->shutdown(pdev);
  41. }
  42. /**
  43. * of_register_platform_driver
  44. */
  45. int of_register_platform_driver(struct of_platform_driver *drv)
  46. {
  47. /* setup of_platform_driver to platform_driver adaptors */
  48. drv->platform_driver.driver = drv->driver;
  49. if (drv->probe)
  50. drv->platform_driver.probe = platform_driver_probe_shim;
  51. drv->platform_driver.remove = drv->remove;
  52. if (drv->shutdown)
  53. drv->platform_driver.shutdown = platform_driver_shutdown_shim;
  54. drv->platform_driver.suspend = drv->suspend;
  55. drv->platform_driver.resume = drv->resume;
  56. return platform_driver_register(&drv->platform_driver);
  57. }
  58. EXPORT_SYMBOL(of_register_platform_driver);
  59. void of_unregister_platform_driver(struct of_platform_driver *drv)
  60. {
  61. platform_driver_unregister(&drv->platform_driver);
  62. }
  63. EXPORT_SYMBOL(of_unregister_platform_driver);
  64. #if defined(CONFIG_PPC_DCR)
  65. #include <asm/dcr.h>
  66. #endif
  67. extern struct device_attribute of_platform_device_attrs[];
  68. static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
  69. {
  70. const struct of_device_id *matches = drv->of_match_table;
  71. if (!matches)
  72. return 0;
  73. return of_match_device(matches, dev) != NULL;
  74. }
  75. static int of_platform_device_probe(struct device *dev)
  76. {
  77. int error = -ENODEV;
  78. struct of_platform_driver *drv;
  79. struct of_device *of_dev;
  80. const struct of_device_id *match;
  81. drv = to_of_platform_driver(dev->driver);
  82. of_dev = to_of_device(dev);
  83. if (!drv->probe)
  84. return error;
  85. of_dev_get(of_dev);
  86. match = of_match_device(drv->driver.of_match_table, dev);
  87. if (match)
  88. error = drv->probe(of_dev, match);
  89. if (error)
  90. of_dev_put(of_dev);
  91. return error;
  92. }
  93. static int of_platform_device_remove(struct device *dev)
  94. {
  95. struct of_device *of_dev = to_of_device(dev);
  96. struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
  97. if (dev->driver && drv->remove)
  98. drv->remove(of_dev);
  99. return 0;
  100. }
  101. static void of_platform_device_shutdown(struct device *dev)
  102. {
  103. struct of_device *of_dev = to_of_device(dev);
  104. struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
  105. if (dev->driver && drv->shutdown)
  106. drv->shutdown(of_dev);
  107. }
  108. #ifdef CONFIG_PM_SLEEP
  109. static int of_platform_legacy_suspend(struct device *dev, pm_message_t mesg)
  110. {
  111. struct of_device *of_dev = to_of_device(dev);
  112. struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
  113. int ret = 0;
  114. if (dev->driver && drv->suspend)
  115. ret = drv->suspend(of_dev, mesg);
  116. return ret;
  117. }
  118. static int of_platform_legacy_resume(struct device *dev)
  119. {
  120. struct of_device *of_dev = to_of_device(dev);
  121. struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
  122. int ret = 0;
  123. if (dev->driver && drv->resume)
  124. ret = drv->resume(of_dev);
  125. return ret;
  126. }
  127. static int of_platform_pm_prepare(struct device *dev)
  128. {
  129. struct device_driver *drv = dev->driver;
  130. int ret = 0;
  131. if (drv && drv->pm && drv->pm->prepare)
  132. ret = drv->pm->prepare(dev);
  133. return ret;
  134. }
  135. static void of_platform_pm_complete(struct device *dev)
  136. {
  137. struct device_driver *drv = dev->driver;
  138. if (drv && drv->pm && drv->pm->complete)
  139. drv->pm->complete(dev);
  140. }
  141. #ifdef CONFIG_SUSPEND
  142. static int of_platform_pm_suspend(struct device *dev)
  143. {
  144. struct device_driver *drv = dev->driver;
  145. int ret = 0;
  146. if (!drv)
  147. return 0;
  148. if (drv->pm) {
  149. if (drv->pm->suspend)
  150. ret = drv->pm->suspend(dev);
  151. } else {
  152. ret = of_platform_legacy_suspend(dev, PMSG_SUSPEND);
  153. }
  154. return ret;
  155. }
  156. static int of_platform_pm_suspend_noirq(struct device *dev)
  157. {
  158. struct device_driver *drv = dev->driver;
  159. int ret = 0;
  160. if (!drv)
  161. return 0;
  162. if (drv->pm) {
  163. if (drv->pm->suspend_noirq)
  164. ret = drv->pm->suspend_noirq(dev);
  165. }
  166. return ret;
  167. }
  168. static int of_platform_pm_resume(struct device *dev)
  169. {
  170. struct device_driver *drv = dev->driver;
  171. int ret = 0;
  172. if (!drv)
  173. return 0;
  174. if (drv->pm) {
  175. if (drv->pm->resume)
  176. ret = drv->pm->resume(dev);
  177. } else {
  178. ret = of_platform_legacy_resume(dev);
  179. }
  180. return ret;
  181. }
  182. static int of_platform_pm_resume_noirq(struct device *dev)
  183. {
  184. struct device_driver *drv = dev->driver;
  185. int ret = 0;
  186. if (!drv)
  187. return 0;
  188. if (drv->pm) {
  189. if (drv->pm->resume_noirq)
  190. ret = drv->pm->resume_noirq(dev);
  191. }
  192. return ret;
  193. }
  194. #else /* !CONFIG_SUSPEND */
  195. #define of_platform_pm_suspend NULL
  196. #define of_platform_pm_resume NULL
  197. #define of_platform_pm_suspend_noirq NULL
  198. #define of_platform_pm_resume_noirq NULL
  199. #endif /* !CONFIG_SUSPEND */
  200. #ifdef CONFIG_HIBERNATION
  201. static int of_platform_pm_freeze(struct device *dev)
  202. {
  203. struct device_driver *drv = dev->driver;
  204. int ret = 0;
  205. if (!drv)
  206. return 0;
  207. if (drv->pm) {
  208. if (drv->pm->freeze)
  209. ret = drv->pm->freeze(dev);
  210. } else {
  211. ret = of_platform_legacy_suspend(dev, PMSG_FREEZE);
  212. }
  213. return ret;
  214. }
  215. static int of_platform_pm_freeze_noirq(struct device *dev)
  216. {
  217. struct device_driver *drv = dev->driver;
  218. int ret = 0;
  219. if (!drv)
  220. return 0;
  221. if (drv->pm) {
  222. if (drv->pm->freeze_noirq)
  223. ret = drv->pm->freeze_noirq(dev);
  224. }
  225. return ret;
  226. }
  227. static int of_platform_pm_thaw(struct device *dev)
  228. {
  229. struct device_driver *drv = dev->driver;
  230. int ret = 0;
  231. if (!drv)
  232. return 0;
  233. if (drv->pm) {
  234. if (drv->pm->thaw)
  235. ret = drv->pm->thaw(dev);
  236. } else {
  237. ret = of_platform_legacy_resume(dev);
  238. }
  239. return ret;
  240. }
  241. static int of_platform_pm_thaw_noirq(struct device *dev)
  242. {
  243. struct device_driver *drv = dev->driver;
  244. int ret = 0;
  245. if (!drv)
  246. return 0;
  247. if (drv->pm) {
  248. if (drv->pm->thaw_noirq)
  249. ret = drv->pm->thaw_noirq(dev);
  250. }
  251. return ret;
  252. }
  253. static int of_platform_pm_poweroff(struct device *dev)
  254. {
  255. struct device_driver *drv = dev->driver;
  256. int ret = 0;
  257. if (!drv)
  258. return 0;
  259. if (drv->pm) {
  260. if (drv->pm->poweroff)
  261. ret = drv->pm->poweroff(dev);
  262. } else {
  263. ret = of_platform_legacy_suspend(dev, PMSG_HIBERNATE);
  264. }
  265. return ret;
  266. }
  267. static int of_platform_pm_poweroff_noirq(struct device *dev)
  268. {
  269. struct device_driver *drv = dev->driver;
  270. int ret = 0;
  271. if (!drv)
  272. return 0;
  273. if (drv->pm) {
  274. if (drv->pm->poweroff_noirq)
  275. ret = drv->pm->poweroff_noirq(dev);
  276. }
  277. return ret;
  278. }
  279. static int of_platform_pm_restore(struct device *dev)
  280. {
  281. struct device_driver *drv = dev->driver;
  282. int ret = 0;
  283. if (!drv)
  284. return 0;
  285. if (drv->pm) {
  286. if (drv->pm->restore)
  287. ret = drv->pm->restore(dev);
  288. } else {
  289. ret = of_platform_legacy_resume(dev);
  290. }
  291. return ret;
  292. }
  293. static int of_platform_pm_restore_noirq(struct device *dev)
  294. {
  295. struct device_driver *drv = dev->driver;
  296. int ret = 0;
  297. if (!drv)
  298. return 0;
  299. if (drv->pm) {
  300. if (drv->pm->restore_noirq)
  301. ret = drv->pm->restore_noirq(dev);
  302. }
  303. return ret;
  304. }
  305. #else /* !CONFIG_HIBERNATION */
  306. #define of_platform_pm_freeze NULL
  307. #define of_platform_pm_thaw NULL
  308. #define of_platform_pm_poweroff NULL
  309. #define of_platform_pm_restore NULL
  310. #define of_platform_pm_freeze_noirq NULL
  311. #define of_platform_pm_thaw_noirq NULL
  312. #define of_platform_pm_poweroff_noirq NULL
  313. #define of_platform_pm_restore_noirq NULL
  314. #endif /* !CONFIG_HIBERNATION */
  315. static struct dev_pm_ops of_platform_dev_pm_ops = {
  316. .prepare = of_platform_pm_prepare,
  317. .complete = of_platform_pm_complete,
  318. .suspend = of_platform_pm_suspend,
  319. .resume = of_platform_pm_resume,
  320. .freeze = of_platform_pm_freeze,
  321. .thaw = of_platform_pm_thaw,
  322. .poweroff = of_platform_pm_poweroff,
  323. .restore = of_platform_pm_restore,
  324. .suspend_noirq = of_platform_pm_suspend_noirq,
  325. .resume_noirq = of_platform_pm_resume_noirq,
  326. .freeze_noirq = of_platform_pm_freeze_noirq,
  327. .thaw_noirq = of_platform_pm_thaw_noirq,
  328. .poweroff_noirq = of_platform_pm_poweroff_noirq,
  329. .restore_noirq = of_platform_pm_restore_noirq,
  330. };
  331. #define OF_PLATFORM_PM_OPS_PTR (&of_platform_dev_pm_ops)
  332. #else /* !CONFIG_PM_SLEEP */
  333. #define OF_PLATFORM_PM_OPS_PTR NULL
  334. #endif /* !CONFIG_PM_SLEEP */
  335. int of_bus_type_init(struct bus_type *bus, const char *name)
  336. {
  337. bus->name = name;
  338. bus->match = of_platform_bus_match;
  339. bus->probe = of_platform_device_probe;
  340. bus->remove = of_platform_device_remove;
  341. bus->shutdown = of_platform_device_shutdown;
  342. bus->dev_attrs = of_platform_device_attrs;
  343. bus->pm = OF_PLATFORM_PM_OPS_PTR;
  344. return bus_register(bus);
  345. }
  346. int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus)
  347. {
  348. /*
  349. * Temporary: of_platform_bus used to be distinct from the platform
  350. * bus. It isn't anymore, and so drivers on the platform bus need
  351. * to be registered in a special way.
  352. *
  353. * After all of_platform_bus_type drivers are converted to
  354. * platform_drivers, this exception can be removed.
  355. */
  356. if (bus == &platform_bus_type)
  357. return of_register_platform_driver(drv);
  358. /* register with core */
  359. drv->driver.bus = bus;
  360. return driver_register(&drv->driver);
  361. }
  362. EXPORT_SYMBOL(of_register_driver);
  363. void of_unregister_driver(struct of_platform_driver *drv)
  364. {
  365. if (drv->driver.bus == &platform_bus_type)
  366. of_unregister_platform_driver(drv);
  367. else
  368. driver_unregister(&drv->driver);
  369. }
  370. EXPORT_SYMBOL(of_unregister_driver);
  371. #if !defined(CONFIG_SPARC)
  372. /*
  373. * The following routines scan a subtree and registers a device for
  374. * each applicable node.
  375. *
  376. * Note: sparc doesn't use these routines because it has a different
  377. * mechanism for creating devices from device tree nodes.
  378. */
  379. /**
  380. * of_device_make_bus_id - Use the device node data to assign a unique name
  381. * @dev: pointer to device structure that is linked to a device tree node
  382. *
  383. * This routine will first try using either the dcr-reg or the reg property
  384. * value to derive a unique name. As a last resort it will use the node
  385. * name followed by a unique number.
  386. */
  387. static void of_device_make_bus_id(struct device *dev)
  388. {
  389. static atomic_t bus_no_reg_magic;
  390. struct device_node *node = dev->of_node;
  391. const u32 *reg;
  392. u64 addr;
  393. int magic;
  394. #ifdef CONFIG_PPC_DCR
  395. /*
  396. * If it's a DCR based device, use 'd' for native DCRs
  397. * and 'D' for MMIO DCRs.
  398. */
  399. reg = of_get_property(node, "dcr-reg", NULL);
  400. if (reg) {
  401. #ifdef CONFIG_PPC_DCR_NATIVE
  402. dev_set_name(dev, "d%x.%s", *reg, node->name);
  403. #else /* CONFIG_PPC_DCR_NATIVE */
  404. u64 addr = of_translate_dcr_address(node, *reg, NULL);
  405. if (addr != OF_BAD_ADDR) {
  406. dev_set_name(dev, "D%llx.%s",
  407. (unsigned long long)addr, node->name);
  408. return;
  409. }
  410. #endif /* !CONFIG_PPC_DCR_NATIVE */
  411. }
  412. #endif /* CONFIG_PPC_DCR */
  413. /*
  414. * For MMIO, get the physical address
  415. */
  416. reg = of_get_property(node, "reg", NULL);
  417. if (reg) {
  418. addr = of_translate_address(node, reg);
  419. if (addr != OF_BAD_ADDR) {
  420. dev_set_name(dev, "%llx.%s",
  421. (unsigned long long)addr, node->name);
  422. return;
  423. }
  424. }
  425. /*
  426. * No BusID, use the node name and add a globally incremented
  427. * counter (and pray...)
  428. */
  429. magic = atomic_add_return(1, &bus_no_reg_magic);
  430. dev_set_name(dev, "%s.%d", node->name, magic - 1);
  431. }
  432. /**
  433. * of_device_alloc - Allocate and initialize an of_device
  434. * @np: device node to assign to device
  435. * @bus_id: Name to assign to the device. May be null to use default name.
  436. * @parent: Parent device.
  437. */
  438. struct of_device *of_device_alloc(struct device_node *np,
  439. const char *bus_id,
  440. struct device *parent)
  441. {
  442. struct of_device *dev;
  443. int rc, i, num_reg = 0, num_irq = 0;
  444. struct resource *res, temp_res;
  445. /* First count how many resources are needed */
  446. while (of_address_to_resource(np, num_reg, &temp_res) == 0)
  447. num_reg++;
  448. while (of_irq_to_resource(np, num_irq, &temp_res) != NO_IRQ)
  449. num_irq++;
  450. /* Allocate memory for both the struct device and the resource table */
  451. dev = kzalloc(sizeof(*dev) + (sizeof(*res) * (num_reg + num_irq)),
  452. GFP_KERNEL);
  453. if (!dev)
  454. return NULL;
  455. res = (struct resource *) &dev[1];
  456. /* Populate the resource table */
  457. if (num_irq || num_reg) {
  458. dev->num_resources = num_reg + num_irq;
  459. dev->resource = res;
  460. for (i = 0; i < num_reg; i++, res++) {
  461. rc = of_address_to_resource(np, i, res);
  462. WARN_ON(rc);
  463. }
  464. for (i = 0; i < num_irq; i++, res++) {
  465. rc = of_irq_to_resource(np, i, res);
  466. WARN_ON(rc == NO_IRQ);
  467. }
  468. }
  469. dev->dev.of_node = of_node_get(np);
  470. #if defined(CONFIG_PPC) || defined(CONFIG_MICROBLAZE)
  471. dev->dev.dma_mask = &dev->archdata.dma_mask;
  472. #endif
  473. dev->dev.parent = parent;
  474. dev->dev.release = of_release_dev;
  475. if (bus_id)
  476. dev_set_name(&dev->dev, "%s", bus_id);
  477. else
  478. of_device_make_bus_id(&dev->dev);
  479. return dev;
  480. }
  481. EXPORT_SYMBOL(of_device_alloc);
  482. /**
  483. * of_platform_device_create - Alloc, initialize and register an of_device
  484. * @np: pointer to node to create device for
  485. * @bus_id: name to assign device
  486. * @parent: Linux device model parent device.
  487. */
  488. struct of_device *of_platform_device_create(struct device_node *np,
  489. const char *bus_id,
  490. struct device *parent)
  491. {
  492. struct of_device *dev;
  493. dev = of_device_alloc(np, bus_id, parent);
  494. if (!dev)
  495. return NULL;
  496. #if defined(CONFIG_PPC) || defined(CONFIG_MICROBLAZE)
  497. dev->archdata.dma_mask = 0xffffffffUL;
  498. #endif
  499. dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
  500. dev->dev.bus = &platform_bus_type;
  501. /* We do not fill the DMA ops for platform devices by default.
  502. * This is currently the responsibility of the platform code
  503. * to do such, possibly using a device notifier
  504. */
  505. if (of_device_register(dev) != 0) {
  506. of_device_free(dev);
  507. return NULL;
  508. }
  509. return dev;
  510. }
  511. EXPORT_SYMBOL(of_platform_device_create);
  512. /**
  513. * of_platform_bus_create - Create an OF device for a bus node and all its
  514. * children. Optionally recursively instantiate matching busses.
  515. * @bus: device node of the bus to instantiate
  516. * @matches: match table, NULL to use the default, OF_NO_DEEP_PROBE to
  517. * disallow recursive creation of child busses
  518. */
  519. static int of_platform_bus_create(const struct device_node *bus,
  520. const struct of_device_id *matches,
  521. struct device *parent)
  522. {
  523. struct device_node *child;
  524. struct of_device *dev;
  525. int rc = 0;
  526. for_each_child_of_node(bus, child) {
  527. pr_debug(" create child: %s\n", child->full_name);
  528. dev = of_platform_device_create(child, NULL, parent);
  529. if (dev == NULL)
  530. rc = -ENOMEM;
  531. else if (!of_match_node(matches, child))
  532. continue;
  533. if (rc == 0) {
  534. pr_debug(" and sub busses\n");
  535. rc = of_platform_bus_create(child, matches, &dev->dev);
  536. }
  537. if (rc) {
  538. of_node_put(child);
  539. break;
  540. }
  541. }
  542. return rc;
  543. }
  544. /**
  545. * of_platform_bus_probe - Probe the device-tree for platform busses
  546. * @root: parent of the first level to probe or NULL for the root of the tree
  547. * @matches: match table, NULL to use the default
  548. * @parent: parent to hook devices from, NULL for toplevel
  549. *
  550. * Note that children of the provided root are not instantiated as devices
  551. * unless the specified root itself matches the bus list and is not NULL.
  552. */
  553. int of_platform_bus_probe(struct device_node *root,
  554. const struct of_device_id *matches,
  555. struct device *parent)
  556. {
  557. struct device_node *child;
  558. struct of_device *dev;
  559. int rc = 0;
  560. if (matches == NULL)
  561. matches = of_default_bus_ids;
  562. if (matches == OF_NO_DEEP_PROBE)
  563. return -EINVAL;
  564. if (root == NULL)
  565. root = of_find_node_by_path("/");
  566. else
  567. of_node_get(root);
  568. if (root == NULL)
  569. return -EINVAL;
  570. pr_debug("of_platform_bus_probe()\n");
  571. pr_debug(" starting at: %s\n", root->full_name);
  572. /* Do a self check of bus type, if there's a match, create
  573. * children
  574. */
  575. if (of_match_node(matches, root)) {
  576. pr_debug(" root match, create all sub devices\n");
  577. dev = of_platform_device_create(root, NULL, parent);
  578. if (dev == NULL) {
  579. rc = -ENOMEM;
  580. goto bail;
  581. }
  582. pr_debug(" create all sub busses\n");
  583. rc = of_platform_bus_create(root, matches, &dev->dev);
  584. goto bail;
  585. }
  586. for_each_child_of_node(root, child) {
  587. if (!of_match_node(matches, child))
  588. continue;
  589. pr_debug(" match: %s\n", child->full_name);
  590. dev = of_platform_device_create(child, NULL, parent);
  591. if (dev == NULL)
  592. rc = -ENOMEM;
  593. else
  594. rc = of_platform_bus_create(child, matches, &dev->dev);
  595. if (rc) {
  596. of_node_put(child);
  597. break;
  598. }
  599. }
  600. bail:
  601. of_node_put(root);
  602. return rc;
  603. }
  604. EXPORT_SYMBOL(of_platform_bus_probe);
  605. #endif /* !CONFIG_SPARC */