summaryrefslogtreecommitdiff
path: root/udev-remove.c
diff options
context:
space:
mode:
Diffstat (limited to 'udev-remove.c')
-rw-r--r--udev-remove.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/udev-remove.c b/udev-remove.c
index 98c45d6c33..c838f15ce3 100644
--- a/udev-remove.c
+++ b/udev-remove.c
@@ -137,36 +137,24 @@ int udev_remove_device(char *path, char *subsystem)
memset(&dev, 0x00, sizeof(dev));
- dev.type = get_device_type(path, subsystem);
-
- switch (dev.type) {
- case 'b':
- case 'c':
- retval = udevdb_get_dev(path, &dev);
- if (retval) {
- dbg("'%s' not found in database, falling back on default name", path);
- temp = strrchr(path, '/');
- if (temp == NULL)
- return -ENODEV;
- strfieldcpy(dev.name, &temp[1]);
- }
-
- dbg("name='%s'", dev.name);
- udevdb_delete_dev(path);
+ retval = udevdb_get_dev(path, &dev);
+ if (retval != 0) {
+ dbg("'%s' not found in database, falling back on default name", path);
+ temp = strrchr(path, '/');
+ if (temp == NULL)
+ return -ENODEV;
+ strfieldcpy(dev.name, &temp[1]);
+ }
+ dbg("name='%s'", dev.name);
- dev_d_send(&dev, subsystem);
+ dev.type = get_device_type(path, subsystem);
+ dev_d_send(&dev, subsystem);
+ udevdb_delete_dev(path);
+ if (dev.type == 'b' || dev.type == 'c')
retval = delete_node(&dev);
- break;
-
- case 'n':
+ else if (dev.type == 'n')
retval = 0;
- break;
-
- default:
- dbg("unknown device type '%c'", dev.type);
- retval = -EINVAL;
- }
return retval;
}