static int pcii_attach(device_t dev) { struct pcii_softc *sc; u_long start, count; int unit; int rid; int error = 0; unit = device_get_unit(dev); sc = device_get_softc(dev); memset(sc, 0, sizeof *sc); device_set_desc(dev, "PCII IEEE-4888 controller"); if (bus_get_resource(dev, SYS_RES_IRQ, 0, &start, &count) != 0) { printf("pcii_attach: cannot obtain IRQ number\n"); return ENXIO; } error = bus_alloc_resources(dev, pcii_res_spec, sc->res); if (error) return (error); error = bus_setup_intr(dev, sc->res[0], INTR_TYPE_MISC | INTR_MPSAFE, NULL, upd7210intr, &sc->upd7210, &sc->intr_handler); if (error) { bus_release_resources(dev, pcii_res_spec, sc->res); return (error); } for (rid = 0; rid < 8; rid++) { sc->upd7210.reg_res[rid] = sc->res[2 + rid]; sc->upd7210.reg_offset[rid] = 0; } sc->upd7210.irq_clear_res = sc->res[10]; sc->upd7210.use_fifo = 0; if (sc->res[1] == NULL) sc->upd7210.dmachan = -1; else sc->upd7210.dmachan = rman_get_start(sc->res[1]); upd7210attach(&sc->upd7210); device_printf(dev, "attached gpib%d\n", sc->upd7210.unit); return (0); }
static int pcii_attach(device_t dev) { struct pcii_softc *sc; int unit; int rid; int error = 0; unit = device_get_unit(dev); sc = device_get_softc(dev); memset(sc, 0, sizeof *sc); device_set_desc(dev, "PCII IEEE-4888 controller"); error = bus_alloc_resources(dev, pcii_res_spec, sc->res); if (error) return (error); error = bus_setup_intr(dev, sc->res[0], INTR_TYPE_MISC | INTR_MPSAFE, NULL, upd7210intr, &sc->upd7210, &sc->intr_handler); if (error) { bus_release_resources(dev, pcii_res_spec, sc->res); return (error); } for (rid = 0; rid < 8; rid++) { sc->upd7210.reg_res[rid] = sc->res[2]; sc->upd7210.reg_offset[rid] = 0x400 * rid; } if (sc->res[1] == NULL) sc->upd7210.dmachan = -1; else sc->upd7210.dmachan = rman_get_start(sc->res[1]); upd7210attach(&sc->upd7210); return (error); }