diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2005-02-21 14:01:23 +0100 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 23:36:13 -0700 |
commit | 5e39f90b14ccf242618086a0242000fc11317a75 (patch) | |
tree | f505f83bddcecf5fe6ff3bc49c9bbe5230253fcf | |
parent | 8f2f6e426fc4cc1fa39b864a1792428a4269b751 (diff) |
[PATCH] trivial namedev cleanup
-rw-r--r-- | namedev.c | 44 | ||||
-rw-r--r-- | namedev.h | 6 | ||||
-rw-r--r-- | namedev_parse.c | 24 |
3 files changed, 38 insertions, 36 deletions
@@ -264,28 +264,30 @@ static void apply_format(struct udevice *udev, char *string, size_t maxsize, } break; case 's': - if (attr != NULL) { - tmpattr = find_sysfs_attribute(class_dev, sysfs_device, attr); - if (tmpattr == NULL) { - dbg("sysfa attribute '%s' not found", attr); - break; - } - /* strip trailing whitespace of matching value */ - if (isspace(tmpattr->value[strlen(tmpattr->value)-1])) { - i = len = strlen(tmpattr->value); - while (i > 0 && isspace(tmpattr->value[i-1])) - i--; - if (i < len) { - tmpattr->value[i] = '\0'; - dbg("remove %i trailing whitespace chars from '%s'", - len - i, tmpattr->value); - } - } - strfieldcatmax(string, tmpattr->value, maxsize); - dbg("substitute sysfs value '%s'", tmpattr->value); - } else { + if (!class_dev) + break; + if (attr == NULL) { dbg("missing attribute"); + break; } + tmpattr = find_sysfs_attribute(class_dev, sysfs_device, attr); + if (tmpattr == NULL) { + dbg("sysfa attribute '%s' not found", attr); + break; + } + /* strip trailing whitespace of matching value */ + if (isspace(tmpattr->value[strlen(tmpattr->value)-1])) { + i = len = strlen(tmpattr->value); + while (i > 0 && isspace(tmpattr->value[i-1])) + i--; + if (i < len) { + tmpattr->value[i] = '\0'; + dbg("remove %i trailing whitespace chars from '%s'", + len - i, tmpattr->value); + } + } + strfieldcatmax(string, tmpattr->value, maxsize); + dbg("substitute sysfs value '%s'", tmpattr->value); break; case '%': strfieldcatmax(string, "%", maxsize); @@ -535,7 +537,7 @@ static int match_sysfs_pairs(struct config_device *dev, struct sysfs_class_devic static int match_id(struct config_device *dev, struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device) { char path[SYSFS_PATH_MAX]; - char *temp = NULL; + char *temp; /* we have to have a sysfs device for ID to work */ if (!sysfs_device) @@ -68,17 +68,17 @@ struct sysfs_pair { struct config_device { struct list_head node; + char kernel[NAME_SIZE]; + char subsystem[SUBSYSTEM_SIZE]; char bus[BUS_SIZE]; char id[ID_SIZE]; char place[PLACE_SIZE]; - char kernel[NAME_SIZE]; + struct sysfs_pair sysfs_pair[MAX_SYSFS_PAIRS]; char program[PROGRAM_SIZE]; char result[PROGRAM_SIZE]; - char subsystem[SUBSYSTEM_SIZE]; char driver[DRIVER_SIZE]; char name[NAME_SIZE]; char symlink[NAME_SIZE]; - struct sysfs_pair sysfs_pair[MAX_SYSFS_PAIRS]; char owner[USER_SIZE]; char group[USER_SIZE]; diff --git a/namedev_parse.c b/namedev_parse.c index 981daa7b3b..eabd9c98bb 100644 --- a/namedev_parse.c +++ b/namedev_parse.c @@ -171,6 +171,18 @@ static int namedev_parse(const char *filename, void *data) if (retval) break; + if (strcasecmp(temp2, FIELD_KERNEL) == 0) { + strfieldcpy(dev.kernel, temp3); + valid = 1; + continue; + } + + if (strcasecmp(temp2, FIELD_SUBSYSTEM) == 0) { + strfieldcpy(dev.subsystem, temp3); + valid = 1; + continue; + } + if (strcasecmp(temp2, FIELD_BUS) == 0) { strfieldcpy(dev.bus, temp3); valid = 1; @@ -215,18 +227,6 @@ static int namedev_parse(const char *filename, void *data) continue; } - if (strcasecmp(temp2, FIELD_KERNEL) == 0) { - strfieldcpy(dev.kernel, temp3); - valid = 1; - continue; - } - - if (strcasecmp(temp2, FIELD_SUBSYSTEM) == 0) { - strfieldcpy(dev.subsystem, temp3); - valid = 1; - continue; - } - if (strcasecmp(temp2, FIELD_DRIVER) == 0) { strfieldcpy(dev.driver, temp3); valid = 1; |