summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgreg@kroah.com <greg@kroah.com>2003-11-12 18:08:19 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:06:23 -0700
commit8c51bbfe5f159d79b365a50a20218f616d6b67b5 (patch)
treee635b88f5cc539f8e056e6e6139eeac73e1d14f9
parent8a0c11d360a5c07f200cb421c5a4291dd00d5a09 (diff)
[PATCH] move TOPOLOGY rule to it's own function.
-rw-r--r--namedev.c91
1 files changed, 55 insertions, 36 deletions
diff --git a/namedev.c b/namedev.c
index 140d50079f..7c2db150be 100644
--- a/namedev.c
+++ b/namedev.c
@@ -566,6 +566,55 @@ static int do_callout(struct sysfs_class_device *class_dev, struct udevice *udev
return -ENODEV;
}
+static int do_topology(struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)
+{
+ struct config_device *dev;
+ struct list_head *tmp;
+ char path[SYSFS_PATH_MAX];
+ int found;
+ char *temp = NULL;
+
+ /* we have to have a sysfs device for TOPOLOGY to work */
+ if (!sysfs_device)
+ return -ENODEV;
+
+ list_for_each(tmp, &config_device_list) {
+ dev = list_entry(tmp, struct config_device, node);
+ if (dev->type != TOPOLOGY)
+ continue;
+
+ found = 0;
+ strcpy(path, sysfs_device->path);
+ temp = strrchr(path, '/');
+ dbg_parse("TOPOLOGY path = '%s'", path);
+ dbg_parse("TOPOLOGY temp = '%s' place = '%s'", temp, dev->place);
+ if (strstr(temp, dev->place) != NULL) {
+ found = 1;
+ } else {
+ *temp = 0x00;
+ temp = strrchr(path, '/');
+ dbg_parse("TOPOLOGY temp = '%s' place = '%s'", temp, dev->place);
+ if (strstr(temp, dev->place) != NULL)
+ found = 1;
+ }
+ if (!found)
+ continue;
+
+ strcpy(udev->name, dev->name);
+ if (dev->mode != 0) {
+ udev->mode = dev->mode;
+ strcpy(udev->owner, dev->owner);
+ strcpy(udev->group, dev->group);
+ }
+ dbg_parse("device at '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
+ dev->place, udev->name,
+ dev->owner, dev->group, dev->mode);
+
+ return 0;
+ }
+ return -ENODEV;
+}
+
static int do_replace(struct sysfs_class_device *class_dev, struct udevice *udev)
{
struct config_device *dev;
@@ -696,7 +745,8 @@ label_found:
found = 0;
if (!sysfs_device)
continue;
- strcpy(path, sysfs_device->path);
+ s
+ rcpy(path, sysfs_device->path);
temp = strrchr(path, '/');
dbg_parse("NUMBER path = '%s'", path);
dbg_parse("NUMBER temp = '%s' id = '%s'", temp, dev->id);
@@ -724,41 +774,6 @@ label_found:
goto done;
break;
}
- case TOPOLOGY:
- {
- char path[SYSFS_PATH_MAX];
-
- if (!sysfs_device)
- continue;
- found = 0;
- strcpy(path, sysfs_device->path);
- temp = strrchr(path, '/');
- dbg_parse("TOPOLOGY path = '%s'", path);
- dbg_parse("TOPOLOGY temp = '%s' place = '%s'", temp, dev->place);
- if (strstr(temp, dev->place) != NULL) {
- found = 1;
- } else {
- *temp = 0x00;
- temp = strrchr(path, '/');
- dbg_parse("TOPOLOGY temp = '%s' place = '%s'", temp, dev->place);
- if (strstr(temp, dev->place) != NULL)
- found = 1;
- }
- if (!found)
- continue;
-
- strcpy(udev->name, dev->name);
- if (dev->mode != 0) {
- udev->mode = dev->mode;
- strcpy(udev->owner, dev->owner);
- strcpy(udev->group, dev->group);
- }
- dbg_parse("device at '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
- dev->place, udev->name,
- dev->owner, dev->group, dev->mode);
- goto done;
- break;
- }
case KERNEL_NAME:
default:
break;
@@ -771,6 +786,10 @@ label_found:
if (retval == 0)
goto done;
+ retval = do_topology(class_dev, udev, sysfs_device);
+ if (retval == 0)
+ goto done;
+
retval = do_replace(class_dev, udev);
if (retval == 0)
goto done;