[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1559577023-558-2-git-send-email-suzuki.poulose@arm.com>
Date: Mon, 3 Jun 2019 16:49:27 +0100
From: Suzuki K Poulose <suzuki.poulose@....com>
To: linux-kernel@...r.kernel.org
Cc: gregkh@...uxfoundation.org, rafael@...nel.org,
suzuki.poulose@....com, Sebastian Ott <sebott@...ux.ibm.com>,
Peter Oberparleiter <oberpar@...ux.ibm.com>,
Heiko Carstens <heiko.carstens@...ibm.com>
Subject: [RFC PATCH 01/57] drivers: s390/cio: Use driver_for_each_device
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 <sebott@...ux.ibm.com>
Cc: Peter Oberparleiter <oberpar@...ux.ibm.com>
Cc: Heiko Carstens <heiko.carstens@...ibm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@....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
Powered by blists - more mailing lists