ACPI / dock: Initialize ACPI dock subsystem upfront
[firefly-linux-kernel-4.4.55.git] / drivers / acpi / dock.c
index 4fdea381ef21e07017a87b94ae16ce0f8860fb75..c3b34f94382fa92f228bff68de17b562f1982f78 100644 (file)
@@ -868,8 +868,10 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
        if (!count)
                return -EINVAL;
 
+       acpi_scan_lock_acquire();
        begin_undock(dock_station);
        ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
+       acpi_scan_lock_release();
        return ret ? ret: count;
 }
 static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
@@ -991,30 +993,6 @@ err_unregister:
        return ret;
 }
 
-/**
- * dock_remove - free up resources related to the dock station
- */
-static int dock_remove(struct dock_station *ds)
-{
-       struct dock_dependent_device *dd, *tmp;
-       struct platform_device *dock_device = ds->dock_device;
-
-       if (!dock_station_count)
-               return 0;
-
-       /* remove dependent devices */
-       list_for_each_entry_safe(dd, tmp, &ds->dependent_devices, list)
-               kfree(dd);
-
-       list_del(&ds->sibling);
-
-       /* cleanup sysfs */
-       sysfs_remove_group(&dock_device->dev.kobj, &dock_attribute_group);
-       platform_device_unregister(dock_device);
-
-       return 0;
-}
-
 /**
  * find_dock_and_bay - look for dock stations and bays
  * @handle: acpi handle of a device
@@ -1033,7 +1011,7 @@ find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
        return AE_OK;
 }
 
-static int __init dock_init(void)
+int __init acpi_dock_init(void)
 {
        if (acpi_disabled)
                return 0;
@@ -1052,19 +1030,3 @@ static int __init dock_init(void)
                ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count);
        return 0;
 }
-
-static void __exit dock_exit(void)
-{
-       struct dock_station *tmp, *dock_station;
-
-       unregister_acpi_bus_notifier(&dock_acpi_notifier);
-       list_for_each_entry_safe(dock_station, tmp, &dock_stations, sibling)
-               dock_remove(dock_station);
-}
-
-/*
- * Must be called before drivers of devices in dock, otherwise we can't know
- * which devices are in a dock
- */
-subsys_initcall(dock_init);
-module_exit(dock_exit);