From 30defadd3fbef99628a16dcd7c4a2964982deac2 Mon Sep 17 00:00:00 2001 From: "greg@kroah.com" Date: Thu, 13 Nov 2003 20:08:10 -0800 Subject: [PATCH] [PATCH] get the major/minor number before we name the device. Will come in handy later... --- udev-add.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/udev-add.c b/udev-add.c index d20e96ee..6f0e3bf1 100644 --- a/udev-add.c +++ b/udev-add.c @@ -44,7 +44,7 @@ * mm is the minor * The value is in decimal. */ -static int get_major_minor(struct sysfs_class_device *class_dev, int *major, int *minor) +static int get_major_minor(struct sysfs_class_device *class_dev, struct udevice *udev) { int retval = -ENODEV; @@ -56,10 +56,10 @@ static int get_major_minor(struct sysfs_class_device *class_dev, int *major, int dbg("dev = %s", dev); - if (sscanf(dev, "%u:%u", major, minor) != 2) + if (sscanf(dev, "%u:%u", &udev->major, &udev->minor) != 2) goto exit; - dbg("found major = %d, minor = %d", *major, *minor); + dbg("found major = %d, minor = %d", udev->major, udev->minor); retval = 0; exit: @@ -219,7 +219,7 @@ exit: int udev_add_device(char *path, char *subsystem) { - struct sysfs_class_device *class_dev; + struct sysfs_class_device *class_dev = NULL; struct udevice dev; int retval = -EINVAL; @@ -237,32 +237,28 @@ int udev_add_device(char *path, char *subsystem) if (class_dev == NULL) goto exit; - retval = namedev_name_device(class_dev, &dev); - if (retval) - return retval; - - retval = get_major_minor(class_dev, &dev.major, &dev.minor); + retval = get_major_minor(class_dev, &dev); if (retval) { dbg("get_major_minor failed"); goto exit; } -// strcpy(dev.name, attr.name); -// strcpy(dev.owner, attr.owner); -// strcpy(dev.group, attr.group); -// dev.mode = attr.mode; - + retval = namedev_name_device(class_dev, &dev); + if (retval) + goto exit; + retval = udevdb_add_dev(path, &dev); if (retval != 0) dbg("udevdb_add_dev failed, but we are going to try to create the node anyway. " "But remove might not work properly for this device."); - sysfs_close_class_device(class_dev); - dbg("name = %s", dev.name); retval = create_node(&dev); exit: + if (class_dev) + sysfs_close_class_device(class_dev); + return retval; } -- 2.39.5