Commit 887ab599 authored by Cornelia Huck's avatar Cornelia Huck Committed by Martin Schwidefsky

[S390] ccwgroup device unregister.

Work around the problem that a device cannot be unregistered from
driver_for_each_device() because of klist node refcounting: Get device
after device owned by the driver to be unregistered with driver_find_device()
and then unregister it. This works because driver_get_device() gets us out of
the region of the elevated klist node refcount. driver_find_device() will
always get the next device in the list after the found one has been
unregistered.
Signed-off-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 231caa1c
...@@ -404,21 +404,24 @@ ccwgroup_driver_register (struct ccwgroup_driver *cdriver) ...@@ -404,21 +404,24 @@ ccwgroup_driver_register (struct ccwgroup_driver *cdriver)
} }
static int static int
__ccwgroup_driver_unregister_device(struct device *dev, void *data) __ccwgroup_match_all(struct device *dev, void *data)
{ {
__ccwgroup_remove_symlinks(to_ccwgroupdev(dev)); return 1;
device_unregister(dev);
put_device(dev);
return 0;
} }
void void
ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver) ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver)
{ {
struct device *dev;
/* We don't want ccwgroup devices to live longer than their driver. */ /* We don't want ccwgroup devices to live longer than their driver. */
get_driver(&cdriver->driver); get_driver(&cdriver->driver);
driver_for_each_device(&cdriver->driver, NULL, NULL, while ((dev = driver_find_device(&cdriver->driver, NULL, NULL,
__ccwgroup_driver_unregister_device); __ccwgroup_match_all))) {
__ccwgroup_remove_symlinks(to_ccwgroupdev(dev));
device_unregister(dev);
put_device(dev);
}
put_driver(&cdriver->driver); put_driver(&cdriver->driver);
driver_unregister(&cdriver->driver); driver_unregister(&cdriver->driver);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment