aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/cio/ccwgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2014-02-03 14:03:04 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-07 18:42:41 -0500
commit0b60f9ead5d4816e7e3d6e28f4a0d22d4a1b2513 (patch)
tree2c46f7db6815641b51553b3c4bfa5a76e0ccd06d /drivers/s390/cio/ccwgroup.c
parentac0ece9174aca9aa895ce0accc54f1f8ff12d117 (diff)
s390: use device_remove_file_self() instead of device_schedule_callback()
driver-core now supports synchrnous self-deletion of attributes and the asynchrnous removal mechanism is scheduled for removal. Use it instead of device_schedule_callback(). * Conversions in arch/s390/pci/pci_sysfs.c and drivers/s390/block/dcssblk.c are straightforward. * drivers/s390/cio/ccwgroup.c is a bit more tricky because ccwgroup_notifier() was (ab)using device_schedule_callback() to purely obtain a process context to kick off ungroup operation which may block from a notifier callback. Rename ccwgroup_ungroup_callback() to ccwgroup_ungroup() and make it take ccwgroup_device * instead. The new function is now called directly from ccwgroup_ungroup_store(). ccwgroup_notifier() chain is updated to explicitly bounce through ccwgroup_device->ungroup_work. This also removes possible failure from memory pressure. Only compile-tested. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: linux390@de.ibm.com Cc: linux-s390@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/s390/cio/ccwgroup.c')
-rw-r--r--drivers/s390/cio/ccwgroup.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index fd3367a1dc7a..dfd7bc681c25 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -168,14 +168,12 @@ static ssize_t ccwgroup_online_show(struct device *dev,
168 * Provide an 'ungroup' attribute so the user can remove group devices no 168 * Provide an 'ungroup' attribute so the user can remove group devices no
169 * longer needed or accidentially created. Saves memory :) 169 * longer needed or accidentially created. Saves memory :)
170 */ 170 */
171static void ccwgroup_ungroup_callback(struct device *dev) 171static void ccwgroup_ungroup(struct ccwgroup_device *gdev)
172{ 172{
173 struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
174
175 mutex_lock(&gdev->reg_mutex); 173 mutex_lock(&gdev->reg_mutex);
176 if (device_is_registered(&gdev->dev)) { 174 if (device_is_registered(&gdev->dev)) {
177 __ccwgroup_remove_symlinks(gdev); 175 __ccwgroup_remove_symlinks(gdev);
178 device_unregister(dev); 176 device_unregister(&gdev->dev);
179 __ccwgroup_remove_cdev_refs(gdev); 177 __ccwgroup_remove_cdev_refs(gdev);
180 } 178 }
181 mutex_unlock(&gdev->reg_mutex); 179 mutex_unlock(&gdev->reg_mutex);
@@ -195,10 +193,9 @@ static ssize_t ccwgroup_ungroup_store(struct device *dev,
195 rc = -EINVAL; 193 rc = -EINVAL;
196 goto out; 194 goto out;
197 } 195 }
198 /* Note that we cannot unregister the device from one of its 196
199 * attribute methods, so we have to use this roundabout approach. 197 if (device_remove_file_self(dev, attr))
200 */ 198 ccwgroup_ungroup(gdev);
201 rc = device_schedule_callback(dev, ccwgroup_ungroup_callback);
202out: 199out:
203 if (rc) { 200 if (rc) {
204 if (rc != -EAGAIN) 201 if (rc != -EAGAIN)
@@ -224,6 +221,14 @@ static const struct attribute_group *ccwgroup_attr_groups[] = {
224 NULL, 221 NULL,
225}; 222};
226 223
224static void ccwgroup_ungroup_workfn(struct work_struct *work)
225{
226 struct ccwgroup_device *gdev =
227 container_of(work, struct ccwgroup_device, ungroup_work);
228
229 ccwgroup_ungroup(gdev);
230}
231
227static void ccwgroup_release(struct device *dev) 232static void ccwgroup_release(struct device *dev)
228{ 233{
229 kfree(to_ccwgroupdev(dev)); 234 kfree(to_ccwgroupdev(dev));
@@ -323,6 +328,7 @@ int ccwgroup_create_dev(struct device *parent, struct ccwgroup_driver *gdrv,
323 atomic_set(&gdev->onoff, 0); 328 atomic_set(&gdev->onoff, 0);
324 mutex_init(&gdev->reg_mutex); 329 mutex_init(&gdev->reg_mutex);
325 mutex_lock(&gdev->reg_mutex); 330 mutex_lock(&gdev->reg_mutex);
331 INIT_WORK(&gdev->ungroup_work, ccwgroup_ungroup_workfn);
326 gdev->count = num_devices; 332 gdev->count = num_devices;
327 gdev->dev.bus = &ccwgroup_bus_type; 333 gdev->dev.bus = &ccwgroup_bus_type;
328 gdev->dev.parent = parent; 334 gdev->dev.parent = parent;
@@ -404,10 +410,10 @@ EXPORT_SYMBOL(ccwgroup_create_dev);
404static int ccwgroup_notifier(struct notifier_block *nb, unsigned long action, 410static int ccwgroup_notifier(struct notifier_block *nb, unsigned long action,
405 void *data) 411 void *data)
406{ 412{
407 struct device *dev = data; 413 struct ccwgroup_device *gdev = to_ccwgroupdev(data);
408 414
409 if (action == BUS_NOTIFY_UNBIND_DRIVER) 415 if (action == BUS_NOTIFY_UNBIND_DRIVER)
410 device_schedule_callback(dev, ccwgroup_ungroup_callback); 416 schedule_work(&gdev->ungroup_work);
411 417
412 return NOTIFY_OK; 418 return NOTIFY_OK;
413} 419}