[PATCH] get the major/minor number before we name the device.

Will come in handy later...
This commit is contained in:
greg@kroah.com 2003-11-13 20:08:10 -08:00 committed by Greg KH
parent c521693b54
commit 30defadd3f
1 changed files with 12 additions and 16 deletions

View File

@ -44,7 +44,7 @@
* mm is the minor * mm is the minor
* The value is in decimal. * 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; 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); dbg("dev = %s", dev);
if (sscanf(dev, "%u:%u", major, minor) != 2) if (sscanf(dev, "%u:%u", &udev->major, &udev->minor) != 2)
goto exit; goto exit;
dbg("found major = %d, minor = %d", *major, *minor); dbg("found major = %d, minor = %d", udev->major, udev->minor);
retval = 0; retval = 0;
exit: exit:
@ -219,7 +219,7 @@ exit:
int udev_add_device(char *path, char *subsystem) int udev_add_device(char *path, char *subsystem)
{ {
struct sysfs_class_device *class_dev; struct sysfs_class_device *class_dev = NULL;
struct udevice dev; struct udevice dev;
int retval = -EINVAL; int retval = -EINVAL;
@ -237,32 +237,28 @@ int udev_add_device(char *path, char *subsystem)
if (class_dev == NULL) if (class_dev == NULL)
goto exit; goto exit;
retval = namedev_name_device(class_dev, &dev); retval = get_major_minor(class_dev, &dev);
if (retval)
return retval;
retval = get_major_minor(class_dev, &dev.major, &dev.minor);
if (retval) { if (retval) {
dbg("get_major_minor failed"); dbg("get_major_minor failed");
goto exit; goto exit;
} }
// strcpy(dev.name, attr.name); retval = namedev_name_device(class_dev, &dev);
// strcpy(dev.owner, attr.owner); if (retval)
// strcpy(dev.group, attr.group); goto exit;
// dev.mode = attr.mode;
retval = udevdb_add_dev(path, &dev); retval = udevdb_add_dev(path, &dev);
if (retval != 0) if (retval != 0)
dbg("udevdb_add_dev failed, but we are going to try to create the node anyway. " 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."); "But remove might not work properly for this device.");
sysfs_close_class_device(class_dev);
dbg("name = %s", dev.name); dbg("name = %s", dev.name);
retval = create_node(&dev); retval = create_node(&dev);
exit: exit:
if (class_dev)
sysfs_close_class_device(class_dev);
return retval; return retval;
} }