1
0
mirror of https://github.com/systemd/systemd.git synced 2025-09-10 21:45:06 +03:00

[PATCH] move TOPOLOGY rule to it's own function.

This commit is contained in:
greg@kroah.com
2003-11-12 18:08:19 -08:00
committed by Greg KH
parent 8a0c11d360
commit 8c51bbfe5f

View File

@@ -566,6 +566,55 @@ static int do_callout(struct sysfs_class_device *class_dev, struct udevice *udev
return -ENODEV; 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) static int do_replace(struct sysfs_class_device *class_dev, struct udevice *udev)
{ {
struct config_device *dev; struct config_device *dev;
@@ -696,7 +745,8 @@ label_found:
found = 0; found = 0;
if (!sysfs_device) if (!sysfs_device)
continue; continue;
strcpy(path, sysfs_device->path); s
rcpy(path, sysfs_device->path);
temp = strrchr(path, '/'); temp = strrchr(path, '/');
dbg_parse("NUMBER path = '%s'", path); dbg_parse("NUMBER path = '%s'", path);
dbg_parse("NUMBER temp = '%s' id = '%s'", temp, dev->id); dbg_parse("NUMBER temp = '%s' id = '%s'", temp, dev->id);
@@ -724,41 +774,6 @@ label_found:
goto done; goto done;
break; 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: case KERNEL_NAME:
default: default:
break; break;
@@ -771,6 +786,10 @@ label_found:
if (retval == 0) if (retval == 0)
goto done; goto done;
retval = do_topology(class_dev, udev, sysfs_device);
if (retval == 0)
goto done;
retval = do_replace(class_dev, udev); retval = do_replace(class_dev, udev);
if (retval == 0) if (retval == 0)
goto done; goto done;