···210210EXPORT_SYMBOL(of_platform_device_create);211211212212/**213213- * of_platform_bus_create - Create an OF device for a bus node and all its214214- * children. Optionally recursively instantiate matching busses.213213+ * of_platform_bus_create() - Create a device for a node and its children.215214 * @bus: device node of the bus to instantiate216215 * @matches: match table, NULL to use the default, OF_NO_DEEP_PROBE to217217- * disallow recursive creation of child busses216216+ * disallow recursive creation of child buses217217+ * @parent: parent for new device, or NULL for top level.218218+ *219219+ * Creates a platform_device for the provided device_node, and optionally220220+ * recursively create devices for all the child nodes.218221 */219219-static int of_platform_bus_create(const struct device_node *bus,222222+static int of_platform_bus_create(struct device_node *bus,220223 const struct of_device_id *matches,221224 struct device *parent)222225{···227224 struct platform_device *dev;228225 int rc = 0;229226227227+ dev = of_platform_device_create(bus, NULL, parent);228228+ if (!dev || !of_match_node(matches, bus))229229+ return 0;230230+230231 for_each_child_of_node(bus, child) {231232 pr_debug(" create child: %s\n", child->full_name);232232- dev = of_platform_device_create(child, NULL, parent);233233- if (dev == NULL)234234- continue;235235-236236- if (!of_match_node(matches, child))237237- continue;238238- if (rc == 0) {239239- pr_debug(" and sub busses\n");240240- rc = of_platform_bus_create(child, matches, &dev->dev);241241- }233233+ rc = of_platform_bus_create(child, matches, &dev->dev);242234 if (rc) {243235 of_node_put(child);244236 break;···243245}244246245247/**246246- * of_platform_bus_probe - Probe the device-tree for platform busses248248+ * of_platform_bus_probe() - Probe the device-tree for platform buses247249 * @root: parent of the first level to probe or NULL for the root of the tree248250 * @matches: match table, NULL to use the default249251 * @parent: parent to hook devices from, NULL for toplevel···256258 struct device *parent)257259{258260 struct device_node *child;259259- struct platform_device *dev;260261 int rc = 0;261262262263 if (WARN_ON(!matches || matches == OF_NO_DEEP_PROBE))···274277 * children275278 */276279 if (of_match_node(matches, root)) {277277- pr_debug(" root match, create all sub devices\n");278278- dev = of_platform_device_create(root, NULL, parent);279279- if (dev == NULL)280280- goto bail;281281-282282- pr_debug(" create all sub busses\n");283283- rc = of_platform_bus_create(root, matches, &dev->dev);284284- goto bail;285285- }286286- for_each_child_of_node(root, child) {280280+ rc = of_platform_bus_create(root, matches, parent);281281+ } else for_each_child_of_node(root, child) {287282 if (!of_match_node(matches, child))288283 continue;289289-290290- pr_debug(" match: %s\n", child->full_name);291291- dev = of_platform_device_create(child, NULL, parent);292292- if (dev == NULL)293293- continue;294294-295295- rc = of_platform_bus_create(child, matches, &dev->dev);296296- if (rc) {297297- of_node_put(child);284284+ rc = of_platform_bus_create(child, matches, parent);285285+ if (rc)298286 break;299299- }300287 }301301- bail:288288+302289 of_node_put(root);303290 return rc;304291}