ACPI: dock: dock_add - hoist up platform_device_register_simple()
Move the call to platform_device_register_simple so that we do it before allocating and initializing our struct dock_station. Signed-off-by: Alex Chiang <achiang@hp.com> Acked-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
@@ -948,11 +948,18 @@ static int dock_add(acpi_handle handle)
|
|||||||
struct dock_station *dock_station;
|
struct dock_station *dock_station;
|
||||||
struct platform_device *dock_device;
|
struct platform_device *dock_device;
|
||||||
|
|
||||||
|
dock_device =
|
||||||
|
platform_device_register_simple("dock",
|
||||||
|
dock_station_count, NULL, 0);
|
||||||
|
if (IS_ERR(dock_device))
|
||||||
|
return PTR_ERR(dock_device);
|
||||||
|
|
||||||
/* allocate & initialize the dock_station private data */
|
/* allocate & initialize the dock_station private data */
|
||||||
dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL);
|
dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL);
|
||||||
if (!dock_station)
|
if (!dock_station)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
dock_station->handle = handle;
|
dock_station->handle = handle;
|
||||||
|
dock_station->dock_device = dock_device;
|
||||||
dock_station->last_dock_time = jiffies - HZ;
|
dock_station->last_dock_time = jiffies - HZ;
|
||||||
INIT_LIST_HEAD(&dock_station->dependent_devices);
|
INIT_LIST_HEAD(&dock_station->dependent_devices);
|
||||||
INIT_LIST_HEAD(&dock_station->hotplug_devices);
|
INIT_LIST_HEAD(&dock_station->hotplug_devices);
|
||||||
@@ -961,15 +968,6 @@ static int dock_add(acpi_handle handle)
|
|||||||
mutex_init(&dock_station->hp_lock);
|
mutex_init(&dock_station->hp_lock);
|
||||||
ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
|
ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
|
||||||
|
|
||||||
/* initialize platform device stuff */
|
|
||||||
dock_station->dock_device =
|
|
||||||
platform_device_register_simple("dock",
|
|
||||||
dock_station_count, NULL, 0);
|
|
||||||
dock_device = dock_station->dock_device;
|
|
||||||
if (IS_ERR(dock_device)) {
|
|
||||||
ret = PTR_ERR(dock_device);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
platform_device_add_data(dock_device, &dock_station,
|
platform_device_add_data(dock_device, &dock_station,
|
||||||
sizeof(struct dock_station *));
|
sizeof(struct dock_station *));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user