diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2011-09-02 01:19:13 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2011-09-02 01:19:13 +0000 |
commit | 8b11c9a828b777a53679e37fa57bd12a004da435 (patch) | |
tree | 55e6a9f8e2e55e301bb8e5ca33e0fd9eb697fbc7 /sys/scsi | |
parent | 1811dfc3f3cf35f2eb8eb41a808ed8bd186f6485 (diff) |
generate a devid from vpd page 80 if vpd page 83 doesnt exist or work.
ok krw@
Diffstat (limited to 'sys/scsi')
-rw-r--r-- | sys/scsi/scsiconf.c | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 925387ee15e..824e6968491 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.180 2011/07/17 22:46:48 matthew Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.181 2011/09/02 01:19:12 dlg Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -75,6 +75,7 @@ int scsi_probedev(struct scsibus_softc *, int, int); void scsi_devid(struct scsi_link *); +int scsi_devid_pg80(struct scsi_link *); int scsi_devid_pg83(struct scsi_link *); int scsibusmatch(struct device *, void *, void *); @@ -1152,10 +1153,8 @@ scsi_devid(struct scsi_link *link) if (pg83 && scsi_devid_pg83(link) == 0) goto done; -#ifdef notyet if (pg80 && scsi_devid_pg80(link) == 0) goto done; -#endif } done: dma_free(pg, sizeof(*pg)); @@ -1256,6 +1255,56 @@ done: return (rv); } +int +scsi_devid_pg80(struct scsi_link *link) +{ + struct scsi_vpd_hdr *hdr = NULL; + u_int8_t *pg = NULL; + char *id; + int pglen, len; + int rv; + + hdr = dma_alloc(sizeof(*hdr), PR_WAITOK | PR_ZERO); + + rv = scsi_inquire_vpd(link, hdr, sizeof(*hdr), SI_PG_SERIAL, + scsi_autoconf); + if (rv != 0) + goto freehdr; + + len = _2btol(hdr->page_length); + if (len == 0) { + rv = EINVAL; + goto freehdr; + } + + pglen = sizeof(*hdr) + len; + pg = dma_alloc(pglen, PR_WAITOK | PR_ZERO); + + rv = scsi_inquire_vpd(link, pg, pglen, SI_PG_SERIAL, scsi_autoconf); + if (rv != 0) + goto free; + + id = malloc(sizeof(link->inqdata.vendor) + + sizeof(link->inqdata.product) + len, M_WAITOK, M_TEMP); + memcpy(id, link->inqdata.vendor, sizeof(link->inqdata.vendor)); + memcpy(id + sizeof(link->inqdata.vendor), link->inqdata.product, + sizeof(link->inqdata.product)); + memcpy(id + sizeof(link->inqdata.vendor) + + sizeof(link->inqdata.product), pg + sizeof(*hdr), len); + + link->id = devid_alloc(DEVID_SERIAL, DEVID_F_PRINT, + sizeof(link->inqdata.vendor) + sizeof(link->inqdata.product) + len, + id); + + free(id, M_TEMP); + +free: + dma_free(pg, pglen); +freehdr: + dma_free(hdr, sizeof(*hdr)); + return (rv); +} + /* * scsi_minphys member of struct scsi_adapter for drivers which don't * need any specific routine. |