Commit 6a1bd126 authored by Kieran Morrissey's avatar Kieran Morrissey Committed by Linus Torvalds

[PATCH] PCI: name length change

- Changes gen-devlist.c to truncate long device names rather than reject
  the database
- Changes PCI_NAME_SIZE to 96 (and PCI_NAME_HALF to 43) to allow all
  current pci.ids names to fit
- Modifies gen-devlist.c to truncate at 89 characters rather than 79 -
  allows for two digit instance numbers to be added to the name as well
  while staying within the 96 characters allocated. No names in the
  current pci.ids are any longer than this.
- Modifies names.c to no longer limit device name length when displaying
  both vendor and device name; the truncation is done by gen-devlist.c.
parent b323e1df
...@@ -7,12 +7,13 @@ ...@@ -7,12 +7,13 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#define MAX_NAME_SIZE 79 #define MAX_NAME_SIZE 89
static void static void
pq(FILE *f, const char *c) pq(FILE *f, const char *c, int len)
{ {
while (*c) { int i = 1;
while (*c && i != len) {
if (*c == '"') if (*c == '"')
fprintf(f, "\\\""); fprintf(f, "\\\"");
else { else {
...@@ -23,6 +24,7 @@ pq(FILE *f, const char *c) ...@@ -23,6 +24,7 @@ pq(FILE *f, const char *c)
} }
} }
c++; c++;
i++;
} }
} }
...@@ -72,13 +74,13 @@ main(void) ...@@ -72,13 +74,13 @@ main(void)
if (bra && bra > c && bra[-1] == ' ') if (bra && bra > c && bra[-1] == ' ')
bra[-1] = 0; bra[-1] = 0;
if (vendor_len + strlen(c) + 1 > MAX_NAME_SIZE) { if (vendor_len + strlen(c) + 1 > MAX_NAME_SIZE) {
fprintf(stderr, "Line %d: Device name too long\n", lino); fprintf(stderr, "Line %d: Device name too long. Name truncated.\n", lino);
fprintf(stderr, "%s\n", c); fprintf(stderr, "%s\n", c);
return 1; /*return 1;*/
} }
} }
fprintf(devf, "\tDEVICE(%s,%s,\"", vend, line+1); fprintf(devf, "\tDEVICE(%s,%s,\"", vend, line+1);
pq(devf, c); pq(devf, c, MAX_NAME_SIZE - vendor_len - 1);
fputs("\")\n", devf); fputs("\")\n", devf);
} else goto err; } else goto err;
break; break;
...@@ -107,7 +109,7 @@ main(void) ...@@ -107,7 +109,7 @@ main(void)
return 1; return 1;
} }
fprintf(devf, "VENDOR(%s,\"", vend); fprintf(devf, "VENDOR(%s,\"", vend);
pq(devf, c); pq(devf, c, 0);
fputs("\")\n", devf); fputs("\")\n", devf);
mode = 1; mode = 1;
} else { } else {
......
...@@ -86,8 +86,7 @@ void __devinit pci_name_device(struct pci_dev *dev) ...@@ -86,8 +86,7 @@ void __devinit pci_name_device(struct pci_dev *dev)
/* Full match */ /* Full match */
match_device: { match_device: {
char *n = name + sprintf(name, "%." PCI_NAME_HALF char *n = name + sprintf(name, "%s %s",
"s %." PCI_NAME_HALF "s",
vendor_p->name, device_p->name); vendor_p->name, device_p->name);
int nr = device_p->seen + 1; int nr = device_p->seen + 1;
device_p->seen = nr; device_p->seen = nr;
......
...@@ -425,8 +425,8 @@ struct pci_dev { ...@@ -425,8 +425,8 @@ struct pci_dev {
unsigned int transparent:1; /* Transparent PCI bridge */ unsigned int transparent:1; /* Transparent PCI bridge */
unsigned int multifunction:1;/* Part of multi-function device */ unsigned int multifunction:1;/* Part of multi-function device */
#ifdef CONFIG_PCI_NAMES #ifdef CONFIG_PCI_NAMES
#define PCI_NAME_SIZE 50 #define PCI_NAME_SIZE 96
#define PCI_NAME_HALF __stringify(20) /* less than half to handle slop */ #define PCI_NAME_HALF __stringify(43) /* less than half to handle slop */
char pretty_name[PCI_NAME_SIZE]; /* pretty name for users to see */ char pretty_name[PCI_NAME_SIZE]; /* pretty name for users to see */
#endif #endif
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment