diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-10-26 20:04:07 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-10-26 20:04:07 +0000 |
commit | 91ba593b93190e28142120152050a9c19e969bf4 (patch) | |
tree | 3fbb6d374bf78244c5a79cddb72488ad6e443455 /sys/arch/hp300 | |
parent | acd437f4e835c5192c40ae9a443c11eff9b97627 (diff) |
In device_match(), match on exact device name (as obtained from struct cfdriver)
instead of `first N chars of dv_xname and checking the next char is a digit'.
Diffstat (limited to 'sys/arch/hp300')
-rw-r--r-- | sys/arch/hp300/hp300/autoconf.c | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/sys/arch/hp300/hp300/autoconf.c b/sys/arch/hp300/hp300/autoconf.c index 19f9bd4680c..c71f5920aa5 100644 --- a/sys/arch/hp300/hp300/autoconf.c +++ b/sys/arch/hp300/hp300/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.46 2009/03/15 20:40:23 miod Exp $ */ +/* $OpenBSD: autoconf.c,v 1.47 2009/10/26 20:04:06 miod Exp $ */ /* $NetBSD: autoconf.c,v 1.45 1999/04/10 17:31:02 kleink Exp $ */ /* @@ -167,7 +167,7 @@ void setbootdev(void); static struct dev_data *dev_data_lookup(struct device *); static void dev_data_insert(struct dev_data *, ddlist_t *); -static int device_match(const char *, const char *); +static int device_match(struct device *, const char *); int mainbusmatch(struct device *, void *, void *); void mainbusattach(struct device *, struct device *, void *); @@ -300,20 +300,9 @@ diskconf(void) **********************************************************************/ static int -device_match(const char *dvname, const char *template) +device_match(struct device *dv, const char *template) { - size_t len = strlen(template); - char unit; - - if (strncmp(dvname, template, len) != 0) - return (1); - - /* Check that we are immediately followed by an unit number. */ - unit = dvname[len]; - if (unit < '0' || unit > '9') - return (1); - - return (0); + return strcmp(dv->dv_cfdata->cf_driver->cd_name, template); } /* @@ -356,16 +345,16 @@ device_register(dev, aux) goto linkup; } - if (device_match(dev->dv_xname, "fhpib") == 0 || - device_match(dev->dv_xname, "nhpib") == 0 || - device_match(dev->dv_xname, "spc") == 0) { + if (device_match(dev, "fhpib") == 0 || + device_match(dev, "nhpib") == 0 || + device_match(dev, "spc") == 0) { struct dio_attach_args *da = aux; dd->dd_scode = da->da_scode; goto linkup; } - if (device_match(dev->dv_xname, "hd") == 0) { + if (device_match(dev, "hd") == 0) { struct hpibbus_attach_args *ha = aux; dd->dd_slave = ha->ha_slave; @@ -373,9 +362,9 @@ device_register(dev, aux) goto linkup; } - if (device_match(dev->dv_xname, "cd") == 0 || - device_match(dev->dv_xname, "sd") == 0 || - device_match(dev->dv_xname, "st") == 0) { + if (device_match(dev, "cd") == 0 || + device_match(dev, "sd") == 0 || + device_match(dev, "st") == 0) { struct scsi_attach_args *sa = aux; dd->dd_slave = sa->sa_sc_link->target; @@ -392,13 +381,13 @@ device_register(dev, aux) linkup: LIST_INSERT_HEAD(&dev_data_list, dd, dd_list); - if (device_match(dev->dv_xname, "fhpib") == 0 || - device_match(dev->dv_xname, "nhpib") == 0) { + if (device_match(dev, "fhpib") == 0 || + device_match(dev, "nhpib") == 0) { dev_data_insert(dd, &dev_data_list_hpib); return; } - if (device_match(dev->dv_xname, "spc") == 0) { + if (device_match(dev, "spc") == 0) { dev_data_insert(dd, &dev_data_list_scsi); return; } @@ -461,9 +450,9 @@ findbootdev() * Sanity check. */ if ((type == 0 && - device_match(bootdv->dv_xname, "ct")) || + device_match(bootdv, "ct")) || (type == 2 && - device_match(bootdv->dv_xname, "hd"))) { + device_match(bootdv, "hd"))) { printf("WARNING: boot device/type mismatch!\n"); printf("device = %s, type = %d\n", bootdv->dv_xname, type); @@ -486,9 +475,9 @@ findbootdev() /* * Sanity check. */ - if (device_match(bootdv->dv_xname, "cd") != 0 && - device_match(bootdv->dv_xname, "sd") != 0 && - device_match(bootdv->dv_xname, "st") != 0) { + if (device_match(bootdv, "cd") != 0 && + device_match(bootdv, "sd") != 0 && + device_match(bootdv, "st") != 0) { printf("WARNING: boot device/type mismatch!\n"); printf("device = %s, type = %d\n", bootdv->dv_xname, type); @@ -590,11 +579,11 @@ setbootdev() /* * Determine device type. */ - if (device_match(root_device->dv_xname, "hd") == 0) + if (device_match(root_device, "hd") == 0) type = 2; - else if (device_match(root_device->dv_xname, "cd") == 0 || - device_match(root_device->dv_xname, "sd") == 0 || - device_match(root_device->dv_xname, "st") == 0) + else if (device_match(root_device, "cd") == 0 || + device_match(root_device, "sd") == 0 || + device_match(root_device, "st") == 0) /* force scsi disk regardless of the actual device */ type = 4; else { |