Revert "s390: use device_remove_file_self() instead of device_schedule_callback()"
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / s390 / cio / ccwgroup.c
index 67b9dc9..959135a 100644 (file)
@@ -168,12 +168,14 @@ static ssize_t ccwgroup_online_show(struct device *dev,
  * Provide an 'ungroup' attribute so the user can remove group devices no
  * longer needed or accidentially created. Saves memory :)
  */
-static void ccwgroup_ungroup(struct ccwgroup_device *gdev)
+static void ccwgroup_ungroup_callback(struct device *dev)
 {
+       struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
+
        mutex_lock(&gdev->reg_mutex);
        if (device_is_registered(&gdev->dev)) {
                __ccwgroup_remove_symlinks(gdev);
-               device_unregister(&gdev->dev);
+               device_unregister(dev);
                __ccwgroup_remove_cdev_refs(gdev);
        }
        mutex_unlock(&gdev->reg_mutex);
@@ -193,9 +195,10 @@ static ssize_t ccwgroup_ungroup_store(struct device *dev,
                rc = -EINVAL;
                goto out;
        }
-
-       if (device_remove_file_self(dev, attr))
-               ccwgroup_ungroup(gdev);
+       /* Note that we cannot unregister the device from one of its
+        * attribute methods, so we have to use this roundabout approach.
+        */
+       rc = device_schedule_callback(dev, ccwgroup_ungroup_callback);
 out:
        if (rc) {
                if (rc != -EAGAIN)
@@ -221,14 +224,6 @@ static const struct attribute_group *ccwgroup_attr_groups[] = {
        NULL,
 };
 
-static void ccwgroup_ungroup_workfn(struct work_struct *work)
-{
-       struct ccwgroup_device *gdev =
-               container_of(work, struct ccwgroup_device, ungroup_work);
-
-       ccwgroup_ungroup(gdev);
-}
-
 static void ccwgroup_release(struct device *dev)
 {
        kfree(to_ccwgroupdev(dev));
@@ -328,7 +323,6 @@ int ccwgroup_create_dev(struct device *parent, struct ccwgroup_driver *gdrv,
        atomic_set(&gdev->onoff, 0);
        mutex_init(&gdev->reg_mutex);
        mutex_lock(&gdev->reg_mutex);
-       INIT_WORK(&gdev->ungroup_work, ccwgroup_ungroup_workfn);
        gdev->count = num_devices;
        gdev->dev.bus = &ccwgroup_bus_type;
        gdev->dev.parent = parent;
@@ -410,10 +404,10 @@ EXPORT_SYMBOL(ccwgroup_create_dev);
 static int ccwgroup_notifier(struct notifier_block *nb, unsigned long action,
                             void *data)
 {
-       struct ccwgroup_device *gdev = to_ccwgroupdev(data);
+       struct device *dev = data;
 
        if (action == BUS_NOTIFY_UNBIND_DRIVER)
-               schedule_work(&gdev->ungroup_work);
+               device_schedule_callback(dev, ccwgroup_ungroup_callback);
 
        return NOTIFY_OK;
 }