static int __init kgdbmpsc_pdev_init(void) { struct platform_device *pdev; /* get the platform data for the specified port. */ pdev = mv64x60_early_get_pdev_data(MPSC_CTLR_NAME, kgdbmpsc_ttyMM, 1); if (pdev) { memcpy(&mpsc_dev, pdev, sizeof(struct platform_device)); if (platform_notify) { kgdbmpsc_update_pdata(&mpsc_dev); platform_notify(&mpsc_dev.dev); } /* get the platform data for the shared registers. */ pdev = mv64x60_early_get_pdev_data(MPSC_SHARED_NAME, 0, 0); if (pdev) { memcpy(&shared_dev, pdev, sizeof(struct platform_device)); if (platform_notify) { kgdbmpsc_update_pdata(&shared_dev); platform_notify(&shared_dev.dev); } } } return 0; }
/** * device_add - add device to device hierarchy. * @dev: device. * * This is part 2 of device_register(), though may be called * separately _iff_ device_initialize() has been called separately. * * This adds it to the kobject hierarchy via kobject_add(), adds it * to the global and sibling lists for the device, then * adds it to the other relevant subsystems of the driver model. */ int device_add(struct device *dev) { struct device *parent = NULL; int error = -EINVAL; dev = get_device(dev); if (!dev || !strlen(dev->bus_id)) goto Error; parent = get_device(dev->parent); pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id); /* first, register with generic layer. */ kobject_set_name(&dev->kobj, "%s", dev->bus_id); if (parent) dev->kobj.parent = &parent->kobj; if ((error = kobject_add(&dev->kobj))) goto Error; kobject_hotplug(&dev->kobj, KOBJ_ADD); if ((error = device_pm_add(dev))) goto PMError; if ((error = bus_add_device(dev))) goto BusError; if (parent) klist_add_tail(&parent->klist_children, &dev->knode_parent); /* notify platform of device entry */ if (platform_notify) platform_notify(dev); Done: put_device(dev); return error; BusError: device_pm_remove(dev); PMError: kobject_hotplug(&dev->kobj, KOBJ_REMOVE); kobject_del(&dev->kobj); Error: if (parent) put_device(parent); goto Done; }