lsusb: 2.6.32 compat

Signed-off-by: Souf Oued <souf_oued@yahoo.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Souf Oued 2010-03-23 05:06:37 +01:00 committed by Denys Vlasenko
parent e283413395
commit 1c3f117ca4

View File

@ -15,37 +15,41 @@ static int FAST_FUNC fileAction(
int depth UNUSED_PARAM) int depth UNUSED_PARAM)
{ {
parser_t *parser; parser_t *parser;
char *tokens[6]; char *tokens[4];
char *bus = NULL, *device = NULL; char *busnum = NULL, *devnum = NULL;
int product_vid = 0, product_did = 0; int product_vid = 0, product_did = 0;
char *uevent_filename = concat_path_file(fileName, "/uevent"); char *uevent_filename = concat_path_file(fileName, "/uevent");
parser = config_open2(uevent_filename, fopen_for_read); parser = config_open2(uevent_filename, fopen_for_read);
free(uevent_filename); free(uevent_filename);
while (config_read(parser, tokens, 6, 1, "\\/=", PARSE_NORMAL)) { while (config_read(parser, tokens, 4, 2, "\\/=", PARSE_NORMAL)) {
if ((parser->lineno == 1) && strcmp(tokens[0], "DEVTYPE") == 0) { if ((parser->lineno == 1) && strcmp(tokens[0], "DEVTYPE") == 0) {
break; break;
} }
if (strcmp(tokens[0], "DEVICE") == 0) {
bus = xstrdup(tokens[4]);
device = xstrdup(tokens[5]);
continue;
}
if (strcmp(tokens[0], "PRODUCT") == 0) { if (strcmp(tokens[0], "PRODUCT") == 0) {
product_vid = xstrtou(tokens[1], 16); product_vid = xstrtou(tokens[1], 16);
product_did = xstrtou(tokens[2], 16); product_did = xstrtou(tokens[2], 16);
continue; continue;
} }
if (strcmp(tokens[0], "BUSNUM") == 0) {
busnum = xstrdup(tokens[1]);
continue;
}
if (strcmp(tokens[0], "DEVNUM") == 0) {
devnum = xstrdup(tokens[1]);
continue;
}
} }
config_close(parser); config_close(parser);
if (bus) { if (busnum) {
printf("Bus %s Device %s: ID %04x:%04x\n", bus, device, product_vid, product_did); printf("Bus %s Device %s: ID %04x:%04x\n", busnum, devnum, product_vid, product_did);
free(bus); free(busnum);
free(device); free(devnum);
} }
return TRUE; return TRUE;