void wdprobe(void) { struct wd_softc *wd = wd_devs; u_int chan, drive, unit = 0; for (chan = 0; chan < PCIIDE_NUM_CHANNELS; chan++) { if (wdc_init(wd, chan) != 0) continue; for (drive = 0; drive < wd->sc_channel.ndrives; drive++) { wd->sc_unit = unit; wd->sc_drive = drive; if (wd_get_params(wd) != 0) continue; DPRINTF(("wd%d: channel %d drive %d\n", unit, chan, drive)); unit++; wd++; } } wd_ndevs = unit; }
/* * Open device (read drive parameters and disklabel) */ int wdopen(struct open_file *f, ...) { int error; va_list ap; u_int unit, part; struct wd_softc *wd; va_start(ap, f); unit = va_arg(ap, u_int); part = va_arg(ap, u_int); va_end(ap); DPRINTF(("wdopen: %d:%d\n", unit, part)); wd = alloc(sizeof(struct wd_softc)); if (wd == NULL) return ENOMEM; memset(wd, 0, sizeof(struct wd_softc)); if (wdc_init(wd, &unit) != 0) return (ENXIO); wd->sc_part = part; wd->sc_unit = unit; if ((error = wd_get_params(wd)) != 0) return error; if ((error = wdgetdisklabel(wd)) != 0) return error; f->f_devdata = wd; return 0; }