diff options
author | imp <imp@FreeBSD.org> | 2004-08-16 15:57:18 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2004-08-16 15:57:18 +0000 |
commit | 96605b4a64c6cf9b8715b73d25968d68a3445283 (patch) | |
tree | e3f6081dac88d699436192efbbb001c636d091a9 /sys/dev/pccard | |
parent | 9cbc7c3e683b465bb1f6fda8b4dba4658a206355 (diff) | |
download | FreeBSD-src-96605b4a64c6cf9b8715b73d25968d68a3445283.zip FreeBSD-src-96605b4a64c6cf9b8715b73d25968d68a3445283.tar.gz |
Some cards don't have the info entries in the CIS, so vendorstr and/or
prodstr may be NULL when fetched. For the default device description,
guard against this and return the numeric IDs instead when this
happens. For the matching routines, and consider NULL to not match
those entries that aren't NULL w/o calling strcmp.
Early patches by: Anders Hanssen
Diffstat (limited to 'sys/dev/pccard')
-rw-r--r-- | sys/dev/pccard/pccard.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c index 55679b1..3509a8c 100644 --- a/sys/dev/pccard/pccard.c +++ b/sys/dev/pccard/pccard.c @@ -152,17 +152,29 @@ static int pccard_set_default_descr(device_t dev) { const char *vendorstr, *prodstr; + uint32_t vendor, prod; char *str; if (pccard_get_vendor_str(dev, &vendorstr)) return (0); if (pccard_get_product_str(dev, &prodstr)) return (0); - str = malloc(strlen(vendorstr) + strlen(prodstr) + 2, M_DEVBUF, - M_WAITOK); - sprintf(str, "%s %s", vendorstr, prodstr); - device_set_desc_copy(dev, str); - free(str, M_DEVBUF); + if (vendorstr != NULL && prodstr != NULL) { + str = malloc(strlen(vendorstr) + strlen(prodstr) + 2, M_DEVBUF, + M_WAITOK); + sprintf(str, "%s %s", vendorstr, prodstr); + device_set_desc_copy(dev, str); + free(str, M_DEVBUF); + } else { + if (pccard_get_vendor(dev, &vendor)) + return (0); + if (pccard_get_product(dev, &prod)) + return (0); + str = malloc(100, M_DEVBUF, M_WAITOK); + snprintf(str, 100, "vendor=0x%x product=0x%x", vendor, prod); + device_set_desc_copy(dev, str); + free(str, M_DEVBUF); + } return (0); } @@ -366,10 +378,12 @@ pccard_do_product_lookup(device_t bus, device_t dev, if (matches && fcn != ent->pp_expfunc) matches = 0; if (matches && ent->pp_cis[0] && - strcmp(ent->pp_cis[0], vendorstr) != 0) + (vendorstr == NULL || + strcmp(ent->pp_cis[0], vendorstr) != 0)) matches = 0; if (matches && ent->pp_cis[1] && - strcmp(ent->pp_cis[1], prodstr) != 0) + (prodstr == NULL || + strcmp(ent->pp_cis[1], prodstr) != 0)) matches = 0; /* XXX need to match cis[2] and cis[3] also XXX */ if (matchfn != NULL) |