summaryrefslogtreecommitdiff
path: root/udev_remove.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-10-18 19:11:51 -0700
committerGreg KH <gregkh@suse.de>2005-04-26 22:02:46 -0700
commit7a947ce51586fd4212447643df90580542777ab9 (patch)
treed9d30236cf65e489b9bc2c5003ef9e1fa838f53e /udev_remove.c
parent8e0871196c916be60a9d0327ce8483c4f9763c17 (diff)
[PATCH] big cleanup of internal udev api
Here is the first patch to cleanup the internal processing of the various stages of an udev event. It should not change any behavior, but if your system depends on udev, please always test it before reboot :) We pass only one generic structure around between add, remove, namedev, db and dev_d handling and make all relevant data available to all internal stages. All udev structures are renamed to "udev". We replace the fake parameter by a flag in the udev structure. We open the class device in the main binaries and not in udev_add, to make it possible to use libsysfs for udevstart directory crawling. The last sleep parameters are removed.
Diffstat (limited to 'udev_remove.c')
-rw-r--r--udev_remove.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/udev_remove.c b/udev_remove.c
index d4be8bd6f9..d97a2411f4 100644
--- a/udev_remove.c
+++ b/udev_remove.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
+#include <stddef.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
@@ -161,35 +162,37 @@ static int delete_node(struct udevice *dev)
}
/*
- * Look up the sysfs path in the database to see if we have named this device
- * something different from the kernel name. If we have, us it. If not, use
- * the default kernel name for lack of anything else to know to do.
+ * look up the sysfs path in the database to get the node name to remove
+ * If we can't find it, use kernel name for lack of anything else to know to do
*/
-int udev_remove_device(const char *path, const char *subsystem)
+int udev_remove_device(struct udevice *udev)
{
- struct udevice dev;
+ struct udevice db_dev;
char *temp;
int retval;
- memset(&dev, 0x00, sizeof(dev));
+ memset(&db_dev, 0x00, sizeof(struct udevice));
- retval = udevdb_get_dev(path, &dev);
- if (retval != 0) {
- dbg("'%s' not found in database, falling back on default name", path);
- temp = strrchr(path, '/');
+ retval = udevdb_get_dev(udev->devpath, &db_dev);
+ if (retval == 0) {
+ /* get stored values in our device */
+ memcpy(udev, &db_dev, UDEVICE_DB_LEN);
+ } else {
+ /* fall back to kernel name */
+ temp = strrchr(udev->devpath, '/');
if (temp == NULL)
return -ENODEV;
- strfieldcpy(dev.name, &temp[1]);
+ strfieldcpy(udev->name, &temp[1]);
+ dbg("'%s' not found in database, falling back on default name", udev->name);
}
- dbg("name='%s'", dev.name);
+ dbg("remove name='%s'", udev->name);
- dev.type = get_device_type(path, subsystem);
- dev_d_send(&dev, subsystem, path);
- udevdb_delete_dev(path);
+ dev_d_send(udev);
+ udevdb_delete_dev(udev->devpath);
- if (dev.type == 'b' || dev.type == 'c')
- retval = delete_node(&dev);
- else if (dev.type == 'n')
+ if (udev->type == 'b' || udev->type == 'c')
+ retval = delete_node(udev);
+ else
retval = 0;
return retval;