Message ID | 1559577023-558-2-git-send-email-suzuki.poulose@arm.com |
---|---|
State | New |
Headers | show |
Series | [RFC,01/57] drivers: s390/cio: Use driver_for_each_device | expand |
Heiko, Sebastian, Peter, Please could you review the following patch ? On 03/06/2019 16:49, Suzuki K Poulose wrote: > 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@linux.ibm.com> > Cc: Peter Oberparleiter <oberpar@linux.ibm.com> > Cc: Heiko Carstens <heiko.carstens@de.ibm.com> > Signed-off-by: Suzuki K Poulose <suzuki.poulose@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); > Thanks Suzuki
On Mon, 3 Jun 2019, Suzuki K Poulose wrote: > 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@linux.ibm.com> > Cc: Peter Oberparleiter <oberpar@linux.ibm.com> > Cc: Heiko Carstens <heiko.carstens@de.ibm.com> > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Reviewed-by: Sebastian Ott <sebott@linux.ibm.com>
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);
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@linux.ibm.com> Cc: Peter Oberparleiter <oberpar@linux.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> --- drivers/s390/cio/ccwgroup.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) -- 2.7.4