summaryrefslogtreecommitdiffstats
path: root/commands/devunbind.c
diff options
context:
space:
mode:
Diffstat (limited to 'commands/devunbind.c')
-rw-r--r--commands/devunbind.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/commands/devunbind.c b/commands/devunbind.c
index 3f9cd7b849..d30193b285 100644
--- a/commands/devunbind.c
+++ b/commands/devunbind.c
@@ -10,7 +10,7 @@
static int do_devunbind(int argc, char *argv[])
{
bool unregister = false;
- struct device_d *dev;
+ struct device *dev;
int ret = COMMAND_SUCCESS, i, opt;
while ((opt = getopt(argc, argv, "fl")) > 0) {
@@ -20,9 +20,14 @@ static int do_devunbind(int argc, char *argv[])
break;
case 'l':
list_for_each_entry(dev, &active_device_list, active) {
+ void *rm_dev;
+
BUG_ON(!dev->driver);
- if (dev->bus->remove)
- printf("%pS(%s, %s)\n", dev->bus->remove,
+
+ rm_dev = dev->bus->remove ?: dev->driver->remove;
+
+ if (rm_dev)
+ printf("%pS(%s, %s)\n", rm_dev,
dev->driver->name, dev_name(dev));
}
return 0;
@@ -47,13 +52,12 @@ static int do_devunbind(int argc, char *argv[])
continue;
}
- if (!dev->driver || !dev->bus->remove) {
- printf("skipping unbound %s\n", argv[i]);
+ if (!device_remove(dev)) {
+ printf("no remove callback registered for %s\n", argv[i]);
ret = COMMAND_ERROR;
continue;
}
- dev->bus->remove(dev);
dev->driver = NULL;
list_del(&dev->active);
}