mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-12 09:17:44 +03:00
[PATCH] remove PLACE key match
ID should do the same, cause we walk up the chain of devices on the physical device and can match for the name of every device there with the ID key.
This commit is contained in:
parent
783272f045
commit
882af735ec
36
namedev.c
36
namedev.c
@ -531,28 +531,6 @@ static int match_id(struct config_device *dev, struct sysfs_device *sysfs_device
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int match_place(struct config_device *dev, struct sysfs_device *sysfs_device)
|
||||
{
|
||||
char path[PATH_SIZE];
|
||||
char *temp;
|
||||
|
||||
strlcpy(path, sysfs_device->path, sizeof(path));
|
||||
temp = strrchr(path, '/');
|
||||
dbg("search '%s' in '%s', path='%s'", dev->place, temp, path);
|
||||
if (strstr(temp, dev->place) != NULL)
|
||||
return 0;
|
||||
|
||||
/* try the parent */
|
||||
temp[0] = '\0';
|
||||
temp = strrchr(path, '/');
|
||||
dbg("search '%s' in '%s', path='%s'", dev->place, temp, path);
|
||||
if (strstr(temp, dev->place) == NULL)
|
||||
return 0;
|
||||
|
||||
dbg("place doesn't match");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static int match_rule(struct udevice *udev, struct config_device *dev,
|
||||
struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device)
|
||||
{
|
||||
@ -622,20 +600,6 @@ static int match_rule(struct udevice *udev, struct config_device *dev,
|
||||
dbg(FIELD_ID " matches");
|
||||
}
|
||||
|
||||
/* check for matching place of device */
|
||||
if (dev->place[0] != '\0') {
|
||||
if (sysfs_device == NULL) {
|
||||
dbg("device has no sysfs_device");
|
||||
goto try_parent;
|
||||
}
|
||||
dbg("check " FIELD_PLACE);
|
||||
if (match_place(dev, sysfs_device) != 0) {
|
||||
dbg(FIELD_PLACE " is not matching");
|
||||
goto try_parent;
|
||||
}
|
||||
dbg(FIELD_PLACE " matches");
|
||||
}
|
||||
|
||||
/* check for matching sysfs pairs */
|
||||
if (dev->sysfs_pair[0].file[0] != '\0') {
|
||||
dbg("check " FIELD_SYSFS " pairs");
|
||||
|
@ -33,7 +33,6 @@ struct sysfs_class_device;
|
||||
#define FIELD_BUS "BUS"
|
||||
#define FIELD_SYSFS "SYSFS"
|
||||
#define FIELD_ID "ID"
|
||||
#define FIELD_PLACE "PLACE"
|
||||
#define FIELD_PROGRAM "PROGRAM"
|
||||
#define FIELD_RESULT "RESULT"
|
||||
#define FIELD_DRIVER "DRIVER"
|
||||
@ -64,7 +63,6 @@ struct config_device {
|
||||
char subsystem[NAME_SIZE];
|
||||
char bus[NAME_SIZE];
|
||||
char id[NAME_SIZE];
|
||||
char place[NAME_SIZE];
|
||||
struct sysfs_pair sysfs_pair[MAX_SYSFS_PAIRS];
|
||||
char program[PATH_SIZE];
|
||||
char result[PATH_SIZE];
|
||||
|
@ -59,11 +59,11 @@ static int add_config_dev(struct config_device *new_dev)
|
||||
|
||||
void dump_config_dev(struct config_device *dev)
|
||||
{
|
||||
dbg_parse("name='%s', symlink='%s', bus='%s', place='%s', id='%s', "
|
||||
dbg_parse("name='%s', symlink='%s', bus='%s', id='%s', "
|
||||
"sysfs_file[0]='%s', sysfs_value[0]='%s', "
|
||||
"kernel='%s', program='%s', result='%s'"
|
||||
"owner='%s', group='%s', mode=%#o",
|
||||
dev->name, dev->symlink, dev->bus, dev->place, dev->id,
|
||||
dev->name, dev->symlink, dev->bus, dev->id,
|
||||
dev->sysfs_pair[0].file, dev->sysfs_pair[0].value,
|
||||
dev->kernel, dev->program, dev->result,
|
||||
dev->owner, dev->group, dev->mode);
|
||||
@ -196,12 +196,6 @@ static int namedev_parse(struct udevice *udev, const char *filename)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcasecmp(temp2, FIELD_PLACE) == 0) {
|
||||
strlcpy(dev.place, temp3, sizeof(dev.place));
|
||||
valid = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncasecmp(temp2, FIELD_SYSFS, sizeof(FIELD_SYSFS)-1) == 0) {
|
||||
struct sysfs_pair *pair = &dev.sysfs_pair[0];
|
||||
int sysfs_pair_num = 0;
|
||||
|
@ -237,7 +237,7 @@ EOF
|
||||
devpath => "/block/sda/sda3",
|
||||
exp_name => "first_disk3" ,
|
||||
conf => <<EOF
|
||||
BUS="scsi", PLACE="0:0:0:0", NAME="first_disk%n"
|
||||
BUS="scsi", ID="0:0:0:0", NAME="first_disk%n"
|
||||
EOF
|
||||
},
|
||||
{
|
||||
@ -246,7 +246,7 @@ EOF
|
||||
devpath => "/block/sda/sda3",
|
||||
exp_name => "Major:8:minor:3:kernelnumber:3:bus:0:0:0:0" ,
|
||||
conf => <<EOF
|
||||
BUS="scsi", PLACE="0:0:0:0", NAME="Major:%M:minor:%m:kernelnumber:%n:bus:%b"
|
||||
BUS="scsi", ID="0:0:0:0", NAME="Major:%M:minor:%m:kernelnumber:%n:bus:%b"
|
||||
EOF
|
||||
},
|
||||
{
|
||||
@ -255,7 +255,7 @@ EOF
|
||||
devpath => "/block/sda/sda3",
|
||||
exp_name => "M8-m3-n3-b0:0-sIBM" ,
|
||||
conf => <<EOF
|
||||
BUS="scsi", PLACE="0:0:0:0", NAME="M%M-m%m-n%n-b%3b-s%3s{vendor}"
|
||||
BUS="scsi", ID="0:0:0:0", NAME="M%M-m%m-n%n-b%3b-s%3s{vendor}"
|
||||
EOF
|
||||
},
|
||||
{
|
||||
|
@ -114,9 +114,6 @@ Match the kernel driver name.
|
||||
.B ID
|
||||
Match the device number on the bus, like PCI bus id.
|
||||
.TP
|
||||
.B PLACE
|
||||
Match the topological position on bus, like physical port of USB device
|
||||
.TP
|
||||
.BI SYSFS{ filename }
|
||||
Match sysfs device attribute like label, vendor, USB serial number, SCSI UUID
|
||||
or file system label. Up to 5 different sysfs files can be checked, with
|
||||
@ -255,7 +252,7 @@ BUS="scsi", SYSFS{vendor}="IBM", SYSFS{model}="ST336", NAME="boot%n"
|
||||
BUS="pci", ID="00:0b.0", NAME="dsp"
|
||||
|
||||
# USB mouse at third port of the second hub to be called mouse1
|
||||
BUS="usb", PLACE="2.3", NAME="mouse1"
|
||||
BUS="usb", ID="2.3", NAME="mouse1"
|
||||
|
||||
# ttyUSB1 should always be called pda with two additional symlinks
|
||||
KERNEL="ttyUSB1", NAME="pda", SYMLINK="palmtop handheld"
|
||||
|
Loading…
Reference in New Issue
Block a user