The cio driver use driver_find_device() to find all devices
to release them before the driver is unregistered. Instead,
it could easily use a lighter driver_for_each_device() helper
to iterate over all the devices.

Cc: Sebastian Ott <seb...@linux.ibm.com>
Cc: Peter Oberparleiter <ober...@linux.ibm.com>
Cc: Heiko Carstens <heiko.carst...@de.ibm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poul...@arm.com>
---
 drivers/s390/cio/ccwgroup.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 4ebf6d4..a006945 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -581,9 +581,12 @@ int ccwgroup_driver_register(struct ccwgroup_driver 
*cdriver)
 }
 EXPORT_SYMBOL(ccwgroup_driver_register);
 
-static int __ccwgroup_match_all(struct device *dev, void *data)
+static int ccwgroup_release_device(struct device *dev, void *unused)
 {
-       return 1;
+       struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
+
+       ccwgroup_ungroup(gdev);
+       return 0;
 }
 
 /**
@@ -594,16 +597,11 @@ static int __ccwgroup_match_all(struct device *dev, void 
*data)
  */
 void ccwgroup_driver_unregister(struct ccwgroup_driver *cdriver)
 {
-       struct device *dev;
+       int ret;
 
        /* We don't want ccwgroup devices to live longer than their driver. */
-       while ((dev = driver_find_device(&cdriver->driver, NULL, NULL,
-                                        __ccwgroup_match_all))) {
-               struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
-
-               ccwgroup_ungroup(gdev);
-               put_device(dev);
-       }
+       ret = driver_for_each_device(&cdriver->driver, NULL, NULL,
+                                    ccwgroup_release_device);
        driver_unregister(&cdriver->driver);
 }
 EXPORT_SYMBOL(ccwgroup_driver_unregister);
-- 
2.7.4

Reply via email to