--- //depot/vendor/freebsd/src/sys/dev/ppbus/if_plip.c 2008/09/15 22:30:14 +++ //depot/user/jhb/acpipci/dev/ppbus/if_plip.c 2008/09/30 13:09:25 @@ -147,6 +147,7 @@ struct lp_data { struct ifnet *sc_ifp; + device_t sc_dev; u_char *sc_ifbuf; int sc_iferrs; @@ -173,8 +174,6 @@ #define DEVTOSOFTC(dev) \ ((struct lp_data *)device_get_softc(dev)) -#define UNITODEVICE(unit) \ - (devclass_get_device(lp_devclass, (unit))) static devclass_t lp_devclass; @@ -206,6 +205,8 @@ struct ifnet *ifp; int rid = 0; + lp->sc_dev = dev; + /* * Reserve the interrupt resource. If we don't have one, the * attach fails. @@ -284,9 +285,9 @@ static int lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data) { - device_t dev = UNITODEVICE(ifp->if_dunit); + struct lp_data *sc = ifp->if_softc; + device_t dev = sc->sc_dev; device_t ppbus = device_get_parent(dev); - struct lp_data *sc = DEVTOSOFTC(dev); struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; u_char *ptr; @@ -560,7 +561,7 @@ * so stop wasting our time */ if (sc->sc_iferrs > LPMAXERRS) { - printf("lp%d: Too many errors, Going off-line.\n", device_get_unit(dev)); + if_printf(sc->sc_ifp, "Too many errors, Going off-line.\n"); ppb_wctr(ppbus, 0x00); sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sc->sc_iferrs=0; @@ -589,7 +590,8 @@ lpoutput (struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct rtentry *rt) { - device_t dev = UNITODEVICE(ifp->if_dunit); + struct lp_data *sc = ifp->if_softc; + device_t dev = sc->sc_dev; device_t ppbus = device_get_parent(dev); int s, err; struct mbuf *mm; --- //depot/vendor/freebsd/src/sys/dev/ppbus/immio.c 2005/12/21 00:10:55 +++ //depot/user/jhb/acpipci/dev/ppbus/immio.c 2008/09/30 13:09:25 @@ -298,8 +298,9 @@ if ((s1 != (char)0xb8 || s2 != (char)0x18 || s3 != (char)0x38)) { if (bootverbose) - printf("imm%d: (disconnect) s1=0x%x s2=0x%x, s3=0x%x\n", - vpo->vpo_unit, s1 & 0xff, s2 & 0xff, s3 & 0xff); + device_printf(vpo->vpo_dev, + "(disconnect) s1=0x%x s2=0x%x, s3=0x%x\n", + s1 & 0xff, s2 & 0xff, s3 & 0xff); if (connected) *connected = VP0_ECONNECT; } @@ -351,8 +352,9 @@ if ((s1 != (char)0xb8 || s2 != (char)0x18 || s3 != (char)0x30)) { if (bootverbose) - printf("imm%d: (connect) s1=0x%x s2=0x%x, s3=0x%x\n", - vpo->vpo_unit, s1 & 0xff, s2 & 0xff, s3 & 0xff); + device_printf(vpo->vpo_dev, + "(connect) s1=0x%x s2=0x%x, s3=0x%x\n", + s1 & 0xff, s2 & 0xff, s3 & 0xff); if (disconnected) *disconnected = VP0_ECONNECT; } @@ -397,7 +399,8 @@ goto error; vpo->vpo_mode_found = VP0_MODE_NIBBLE; } else { - printf("imm%d: NIBBLE mode unavailable!\n", vpo->vpo_unit); + device_printf(vpo->vpo_dev, + "NIBBLE mode unavailable!\n"); goto error; } } else { @@ -418,8 +421,8 @@ if (error) { if (bootverbose) - printf("imm%d: can't disconnect from the drive\n", - vpo->vpo_unit); + device_printf(vpo->vpo_dev, + "can't disconnect from the drive\n"); goto error; } @@ -611,17 +614,17 @@ case VP0_MODE_EPP: ppb_MS_GET_init(ppbus, vpo->vpo_dev, epp17_instr); ppb_MS_PUT_init(ppbus, vpo->vpo_dev, epp17_outstr); - printf("imm%d: EPP mode\n", vpo->vpo_unit); + device_printf(vpo->vpo_dev, "EPP mode\n"); break; case VP0_MODE_PS2: ppb_MS_GET_init(ppbus, vpo->vpo_dev, ps2_inbyte_submicroseq); ppb_MS_PUT_init(ppbus, vpo->vpo_dev, spp_outbyte_submicroseq); - printf("imm%d: PS2 mode\n", vpo->vpo_unit); + device_printf(vpo->vpo_dev, "PS2 mode\n"); break; case VP0_MODE_NIBBLE: ppb_MS_GET_init(ppbus, vpo->vpo_dev, vpo->vpo_nibble_inbyte_msq); ppb_MS_PUT_init(ppbus, vpo->vpo_dev, spp_outbyte_submicroseq); - printf("imm%d: NIBBLE mode\n", vpo->vpo_unit); + device_printf(vpo->vpo_dev, "NIBBLE mode\n"); break; default: panic("imm: unknown mode %d", vpo->vpo_mode_found); --- //depot/vendor/freebsd/src/sys/dev/ppbus/lpbb.c 2008/08/04 20:50:14 +++ //depot/user/jhb/acpipci/dev/ppbus/lpbb.c 2008/09/30 13:09:25 @@ -62,7 +62,7 @@ device_t dev; - dev = device_find_child(parent, "lpbb", 0); + dev = device_find_child(parent, "lpbb", -1); if (!dev) BUS_ADD_CHILD(parent, 0, "lpbb", -1); } --- //depot/vendor/freebsd/src/sys/dev/ppbus/lpt.c 2008/09/27 08:55:22 +++ //depot/user/jhb/acpipci/dev/ppbus/lpt.c 2008/09/30 15:22:31 @@ -104,11 +104,10 @@ #define BUFSIZE 1024 #define BUFSTATSIZE 32 -#define LPTUNIT(s) ((s)&0x03) -#define LPTFLAGS(s) ((s)&0xfc) - struct lpt_data { - + device_t dev; + struct cdev *cdev; + struct cdev *cdev_bypass; short sc_state; /* default case: negative prime, negative ack, handshake strobe, prime once */ @@ -145,10 +144,6 @@ #define DEVTOSOFTC(dev) \ ((struct lpt_data *)device_get_softc(dev)) -#define UNITOSOFTC(unit) \ - ((struct lpt_data *)devclass_get_softc(lpt_devclass, (unit))) -#define UNITODEVICE(unit) \ - (devclass_get_device(lpt_devclass, (unit))) static void lptintr(device_t dev); static void lpt_intr(void *arg); /* without spls */ @@ -396,10 +391,15 @@ lpt_release_ppbus(dev); - make_dev(&lpt_cdevsw, unit, + sc->dev = dev; + sc->cdev = make_dev(&lpt_cdevsw, unit, UID_ROOT, GID_WHEEL, 0600, LPT_NAME "%d", unit); - make_dev(&lpt_cdevsw, unit | LP_BYPASS, + sc->cdev->si_drv1 = sc; + sc->cdev->si_drv2 = 0; + sc->cdev_bypass = make_dev(&lpt_cdevsw, unit, UID_ROOT, GID_WHEEL, 0600, LPT_NAME "%d.ctl", unit); + sc->cdev_bypass->si_drv1 = sc; + sc->cdev_bypass->si_drv2 = LP_BYPASS; return (0); } @@ -408,6 +408,8 @@ { struct lpt_data *sc = DEVTOSOFTC(dev); + destroy_dev(sc->cdev); + destroy_dev(sc->cdev_bypass); lpt_release_ppbus(dev); if (sc->intr_resource != 0) { BUS_TEARDOWN_INTR(device_get_parent(dev), dev, @@ -461,9 +463,8 @@ { int s; int trys, err; - u_int unit = LPTUNIT(dev2unit(dev)); - struct lpt_data *sc = UNITOSOFTC(unit); - device_t lptdev = UNITODEVICE(unit); + struct lpt_data *sc = dev->si_drv1; + device_t lptdev = sc->dev; device_t ppbus = device_get_parent(lptdev); if (!sc) @@ -475,7 +476,7 @@ } else sc->sc_state |= LPTINIT; - sc->sc_flags = LPTFLAGS(dev2unit(dev)); + sc->sc_flags = dev->si_drv2; /* Check for open with BYPASS flag set. */ if (sc->sc_flags & LP_BYPASS) { @@ -579,13 +580,12 @@ static int lptclose(struct cdev *dev, int flags, int fmt, struct thread *td) { - u_int unit = LPTUNIT(dev2unit(dev)); - struct lpt_data *sc = UNITOSOFTC(unit); - device_t lptdev = UNITODEVICE(unit); + struct lpt_data *sc = dev->si_drv1; + device_t lptdev = sc->dev; device_t ppbus = device_get_parent(lptdev); int err; - if(sc->sc_flags & LP_BYPASS) + if (sc->sc_flags & LP_BYPASS) goto end_close; if ((err = lpt_request_ppbus(lptdev, PPB_WAIT|PPB_INTR)) != 0) @@ -688,9 +688,8 @@ static int lptread(struct cdev *dev, struct uio *uio, int ioflag) { - u_int unit = LPTUNIT(dev2unit(dev)); - struct lpt_data *sc = UNITOSOFTC(unit); - device_t lptdev = UNITODEVICE(unit); + struct lpt_data *sc = dev->si_drv1; + device_t lptdev = sc->dev; device_t ppbus = device_get_parent(lptdev); int error = 0, len; @@ -735,9 +734,8 @@ { register unsigned n; int err; - u_int unit = LPTUNIT(dev2unit(dev)); - struct lpt_data *sc = UNITOSOFTC(unit); - device_t lptdev = UNITODEVICE(unit); + struct lpt_data *sc = dev->si_drv1; + device_t lptdev = sc->dev; device_t ppbus = device_get_parent(lptdev); if(sc->sc_flags & LP_BYPASS) { @@ -783,7 +781,9 @@ return(err); case EINVAL: /* advanced mode not avail */ - log(LOG_NOTICE, LPT_NAME "%d: advanced mode not avail, polling\n", unit); + log(LOG_NOTICE, + "%s: advanced mode not avail, polling\n", + device_get_nameunit(sc->dev)); break; default: return(err); @@ -902,8 +902,7 @@ lptioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td) { int error = 0; - u_int unit = LPTUNIT(dev2unit(dev)); - struct lpt_data *sc = UNITOSOFTC(unit); + struct lpt_data *sc = dev->si_drv1; u_char old_sc_irq; /* old printer IRQ status */ switch (cmd) { @@ -942,8 +941,8 @@ } if (old_sc_irq != sc->sc_irq ) - log(LOG_NOTICE, LPT_NAME "%d: switched to %s %s mode\n", - unit, + log(LOG_NOTICE, "%s: switched to %s %s mode\n", + device_get_nameunit(sc->dev), (sc->sc_irq & LP_ENABLE_IRQ)? "interrupt-driven":"polled", (sc->sc_irq & LP_ENABLE_EXT)? --- //depot/vendor/freebsd/src/sys/dev/ppbus/pcfclock.c 2008/09/27 08:55:22 +++ //depot/user/jhb/acpipci/dev/ppbus/pcfclock.c 2008/09/30 15:22:31 @@ -52,16 +52,11 @@ #define PCFCLOCK_NAME "pcfclock" struct pcfclock_data { + device_t dev; + struct cdev *cdev; int count; }; -#define DEVTOSOFTC(dev) \ - ((struct pcfclock_data *)device_get_softc(dev)) -#define UNITOSOFTC(unit) \ - ((struct pcfclock_data *)devclass_get_softc(pcfclock_devclass, (unit))) -#define UNITODEVICE(unit) \ - (devclass_get_device(pcfclock_devclass, (unit))) - static devclass_t pcfclock_devclass; static d_open_t pcfclock_open; @@ -120,7 +115,7 @@ device_t dev; - dev = device_find_child(parent, PCFCLOCK_NAME, 0); + dev = device_find_child(parent, PCFCLOCK_NAME, -1); if (!dev) BUS_ADD_CHILD(parent, 0, PCFCLOCK_NAME, -1); } @@ -128,24 +123,27 @@ static int pcfclock_probe(device_t dev) { - struct pcfclock_data *sc; device_set_desc(dev, "PCF-1.0"); - - sc = DEVTOSOFTC(dev); - return (0); } static int pcfclock_attach(device_t dev) { + struct pcfclock_data *sc = device_get_softc(dev); int unit; unit = device_get_unit(dev); - make_dev(&pcfclock_cdevsw, unit, + sc->dev = dev; + sc->cdev = make_dev(&pcfclock_cdevsw, unit, UID_ROOT, GID_WHEEL, 0400, PCFCLOCK_NAME "%d", unit); + if (sc->cdev == NULL) { + device_printf(dev, "Failed to create character device\n"); + return (ENXIO); + } + sc->cdev->si_drv1 = sc; return (0); } @@ -153,9 +151,8 @@ static int pcfclock_open(struct cdev *dev, int flag, int fms, struct thread *td) { - u_int unit = dev2unit(dev); - struct pcfclock_data *sc = UNITOSOFTC(unit); - device_t pcfclockdev = UNITODEVICE(unit); + struct pcfclock_data *sc = dev->si_drv1; + device_t pcfclockdev = sc->dev; device_t ppbus = device_get_parent(pcfclockdev); int res; @@ -174,9 +171,8 @@ static int pcfclock_close(struct cdev *dev, int flags, int fmt, struct thread *td) { - u_int unit = dev2unit(dev); - struct pcfclock_data *sc = UNITOSOFTC(unit); - device_t pcfclockdev = UNITODEVICE(unit); + struct pcfclock_data *sc = dev->si_drv1; + device_t pcfclockdev = sc->dev; device_t ppbus = device_get_parent(pcfclockdev); sc->count--; @@ -189,9 +185,9 @@ static void pcfclock_write_cmd(struct cdev *dev, unsigned char command) { - u_int unit = dev2unit(dev); - device_t ppidev = UNITODEVICE(unit); - device_t ppbus = device_get_parent(ppidev); + struct pcfclock_data *sc = dev->si_drv1; + device_t pcfclockdev = sc->dev; + device_t ppbus = device_get_parent(pcfclockdev); unsigned char ctr = 14; char i; @@ -209,7 +205,7 @@ static void pcfclock_display_data(struct cdev *dev, char buf[18]) { - u_int unit = dev2unit(dev); + struct pcfclock_data *sc = dev->si_drv1; #ifdef PCFCLOCK_VERBOSE int year; @@ -217,25 +213,23 @@ if (year < 70) year += 100; - printf(PCFCLOCK_NAME "%d: %02d.%02d.%4d %02d:%02d:%02d, " + device_printf(sc->dev, "%02d.%02d.%4d %02d:%02d:%02d, " "battery status: %s\n", - unit, NR(buf, 10), NR(buf, 12), 1900 + year, NR(buf, 6), NR(buf, 4), NR(buf, 2), PCFCLOCK_BATTERY_STATUS_LOW(buf) ? "LOW" : "ok"); #else if (PCFCLOCK_BATTERY_STATUS_LOW(buf)) - printf(PCFCLOCK_NAME "%d: BATTERY STATUS LOW ON\n", - unit); + device_printf(sc->dev, "BATTERY STATUS LOW ON\n"); #endif } static int pcfclock_read_data(struct cdev *dev, char *buf, ssize_t bits) { - u_int unit = dev2unit(dev); - device_t ppidev = UNITODEVICE(unit); - device_t ppbus = device_get_parent(ppidev); + struct pcfclock_data *sc = dev->si_drv1; + device_t pcfclockdev = sc->dev; + device_t ppbus = device_get_parent(pcfclockdev); int i; char waitfor; int offset; @@ -272,9 +266,9 @@ static int pcfclock_read_dev(struct cdev *dev, char *buf, int maxretries) { - u_int unit = dev2unit(dev); - device_t ppidev = UNITODEVICE(unit); - device_t ppbus = device_get_parent(ppidev); + struct pcfclock_data *sc = dev->si_drv1; + device_t pcfclockdev = sc->dev; + device_t ppbus = device_get_parent(pcfclockdev); int error = 0; ppb_set_mode(ppbus, PPB_COMPATIBLE); @@ -302,7 +296,7 @@ static int pcfclock_read(struct cdev *dev, struct uio *uio, int ioflag) { - u_int unit = dev2unit(dev); + struct pcfclock_data *sc = dev->si_drv1; char buf[18]; int error = 0; @@ -312,7 +306,7 @@ error = pcfclock_read_dev(dev, buf, PCFCLOCK_MAX_RETRIES); if (error) { - printf(PCFCLOCK_NAME "%d: no PCF found\n", unit); + device_printf(sc->dev, "no PCF found\n"); } else { pcfclock_display_data(dev, buf); --- //depot/vendor/freebsd/src/sys/dev/ppbus/ppb_base.c 2003/08/24 17:56:35 +++ //depot/user/jhb/acpipci/dev/ppbus/ppb_base.c 2008/09/30 13:09:25 @@ -75,7 +75,7 @@ switch (how) { case PPB_NOINTR: /* wait 10 ms */ - tsleep((caddr_t)bus, PPBPRI, "ppbpoll", hz/100); + pause("ppbpoll", hz/100); break; case PPB_INTR: --- //depot/vendor/freebsd/src/sys/dev/ppbus/ppb_msq.c 2003/08/24 17:56:35 +++ //depot/user/jhb/acpipci/dev/ppbus/ppb_msq.c 2008/09/30 13:49:36 @@ -55,7 +55,7 @@ static struct ppb_xfer * mode2xfer(device_t bus, struct ppb_device *ppbdev, int opcode) { - int index, epp; + int index, epp, mode; struct ppb_xfer *table; switch (opcode) { @@ -72,7 +72,8 @@ } /* retrieve the device operating mode */ - switch (ppb_get_mode(bus)) { + mode = ppb_get_mode(bus); + switch (mode) { case PPB_COMPATIBLE: index = COMPAT_MSQ; break; @@ -99,7 +100,7 @@ index = ECP_MSQ; break; default: - panic("%s: unknown mode (%d)", __func__, ppbdev->mode); + panic("%s: unknown mode (%d)", __func__, mode); } return (&table[index]); --- //depot/vendor/freebsd/src/sys/dev/ppbus/ppbconf.c 2008/09/15 22:30:14 +++ //depot/user/jhb/acpipci/dev/ppbus/ppbconf.c 2008/09/30 13:49:36 @@ -54,21 +56,22 @@ * Device methods */ -static void +static int ppbus_print_child(device_t bus, device_t dev) { struct ppb_device *ppbdev; + int retval; - bus_print_child_header(bus, dev); + retval = bus_print_child_header(bus, dev); ppbdev = (struct ppb_device *)device_get_ivars(dev); if (ppbdev->flags != 0) - printf(" flags 0x%x", ppbdev->flags); + retval += printf(" flags 0x%x", ppbdev->flags); - printf(" on %s%d\n", device_get_name(bus), device_get_unit(bus)); + retval += bus_print_child_footer(bus, dev); - return; + return (retval); } static int @@ -110,16 +113,11 @@ static int ppbus_read_ivar(device_t bus, device_t dev, int index, uintptr_t* val) { - struct ppb_device *ppbdev = (struct ppb_device *)device_get_ivars(dev); switch (index) { case PPBUS_IVAR_MODE: /* XXX yet device mode = ppbus mode = chipset mode */ *val = (u_long)ppb_get_mode(bus); - ppbdev->mode = (u_short)*val; - break; - case PPBUS_IVAR_AVM: - *val = (u_long)ppbdev->avm; break; default: return (ENOENT); @@ -131,13 +129,11 @@ static int ppbus_write_ivar(device_t bus, device_t dev, int index, u_long val) { - struct ppb_device *ppbdev = (struct ppb_device *)device_get_ivars(dev); switch (index) { case PPBUS_IVAR_MODE: /* XXX yet device mode = ppbus mode = chipset mode */ - ppb_set_mode(bus,val); - ppbdev->mode = ppb_get_mode(bus); + ppb_set_mode(bus, val); break; default: return (ENOENT); @@ -212,16 +208,15 @@ int i, len, error; int class_id = -1; char str[PPB_PnP_STRING_SIZE+1]; - int unit = device_get_unit(bus); - printf("Probing for PnP devices on ppbus%d:\n", unit); + device_printf(bus, "Probing for PnP devices:\n"); if ((error = ppb_1284_read_id(bus, PPB_NIBBLE, str, PPB_PnP_STRING_SIZE, &len))) goto end_detect; #ifdef DEBUG_1284 - printf("ppb: %d characters: ", len); + device_printf(bus, " %d characters: ", len); for (i = 0; i < len; i++) printf("%c(0x%x) ", str[i], str[i]); printf("\n"); @@ -233,10 +228,10 @@ if ((token = search_token(str, len, "MFG")) != NULL || (token = search_token(str, len, "MANUFACTURER")) != NULL) - printf("ppbus%d: <%s", unit, + device_printf(bus, "<%s", search_token(token, UNKNOWN_LENGTH, ":") + 1); else - printf("ppbus%d: ppb->ppb_link->base) #define ppb_get_epp_protocol(dev) ((dev)->ppb->ppb_link->epp_protocol) -#define ppb_get_irq(dev) ((dev)->ppb->ppb_link->id_irq) */ #endif --- //depot/vendor/freebsd/src/sys/dev/ppbus/ppi.c 2008/09/27 08:55:22 +++ //depot/user/jhb/acpipci/dev/ppbus/ppi.c 2008/09/30 15:22:31 @@ -59,8 +59,8 @@ #define BUFSIZE 512 struct ppi_data { - - int ppi_unit; + device_t ppi_device; + struct cdev *ppi_cdev; int ppi_flags; #define HAVE_PPBUS (1<<0) #define HAD_PPBUS (1<<1) @@ -77,10 +77,6 @@ #define DEVTOSOFTC(dev) \ ((struct ppi_data *)device_get_softc(dev)) -#define UNITOSOFTC(unit) \ - ((struct ppi_data *)devclass_get_softc(ppi_devclass, (unit))) -#define UNITODEVICE(unit) \ - (devclass_get_device(ppi_devclass, (unit))) static devclass_t ppi_devclass; @@ -162,18 +158,24 @@ static int ppi_attach(device_t dev) { + struct ppi_data *ppi = DEVTOSOFTC(dev); #ifdef PERIPH_1284 int rid = 0; - struct ppi_data *ppi = DEVTOSOFTC(dev); /* declare our interrupt handler */ ppi->intr_resource = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); #endif /* PERIPH_1284 */ - make_dev(&ppi_cdevsw, device_get_unit(dev), /* XXX cleanup */ + ppi->ppi_cdev = make_dev(&ppi_cdevsw, device_get_unit(dev), UID_ROOT, GID_WHEEL, 0600, "ppi%d", device_get_unit(dev)); + if (ppi->ppi_cdev == NULL) { + device_printf("Failed to create character device\n"); + return (ENXIO); + } + ppi->ppi_cdev->si_drv1 = ppi; + ppi->ppi_device = dev; return (0); } @@ -252,15 +254,11 @@ static int ppiopen(struct cdev *dev, int flags, int fmt, struct thread *td) { - u_int unit = dev2unit(dev); - struct ppi_data *ppi = UNITOSOFTC(unit); - device_t ppidev = UNITODEVICE(unit); + struct ppi_data *ppi = dev->si_drv1; + device_t ppidev = ppi->ppi_device; device_t ppbus = device_get_parent(ppidev); int res; - if (!ppi) - return (ENXIO); - if (!(ppi->ppi_flags & HAVE_PPBUS)) { if ((res = ppb_request_bus(ppbus, ppidev, (flags & O_NONBLOCK) ? PPB_DONTWAIT : @@ -286,9 +284,8 @@ static int ppiclose(struct cdev *dev, int flags, int fmt, struct thread *td) { - u_int unit = dev2unit(dev); - struct ppi_data *ppi = UNITOSOFTC(unit); - device_t ppidev = UNITODEVICE(unit); + struct ppi_data *ppi = dev->si_drv1; + device_t ppidev = ppi->ppi_device; device_t ppbus = device_get_parent(ppidev); ppi->ppi_count --; @@ -329,9 +326,8 @@ ppiread(struct cdev *dev, struct uio *uio, int ioflag) { #ifdef PERIPH_1284 - u_int unit = dev2unit(dev); - struct ppi_data *ppi = UNITOSOFTC(unit); - device_t ppidev = UNITODEVICE(unit); + struct ppi_data *ppi = dev->si_drv1; + device_t ppidev = ppi->ppi_device; device_t ppbus = device_get_parent(ppidev); int len, error = 0; @@ -413,9 +409,8 @@ ppiwrite(struct cdev *dev, struct uio *uio, int ioflag) { #ifdef PERIPH_1284 - u_int unit = dev2unit(dev); - struct ppi_data *ppi = UNITOSOFTC(unit); - device_t ppidev = UNITODEVICE(unit); + struct ppi_data *ppi = dev->si_drv1; + device_t ppidev = ppi->ppi_device; device_t ppbus = device_get_parent(ppidev); int len, error = 0, sent; @@ -499,9 +494,8 @@ static int ppiioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td) { - u_int unit = dev2unit(dev); - device_t ppidev = UNITODEVICE(unit); - device_t ppbus = device_get_parent(ppidev); + struct ppi_data *ppi = dev->si_drv1; + device_t ppidev = ppi->ppi_device; int error = 0; u_int8_t *val = (u_int8_t *)data; --- //depot/vendor/freebsd/src/sys/dev/ppbus/pps.c 2008/09/15 22:30:14 +++ //depot/user/jhb/acpipci/dev/ppbus/pps.c 2008/09/30 13:09:25 @@ -77,7 +77,7 @@ device_t dev; - dev = device_find_child(parent, PPS_NAME, 0); + dev = device_find_child(parent, PPS_NAME, -1); if (!dev) BUS_ADD_CHILD(parent, 0, PPS_NAME, -1); } --- //depot/vendor/freebsd/src/sys/dev/ppbus/vpo.c 2007/06/17 05:59:18 +++ //depot/user/jhb/acpipci/dev/ppbus/vpo.c 2008/09/30 13:09:25 @@ -63,8 +63,7 @@ }; struct vpo_data { - unsigned short vpo_unit; - + device_t vpo_dev; int vpo_stat; int vpo_count; int vpo_error; @@ -94,7 +93,7 @@ device_t dev; - dev = device_find_child(parent, "vpo", 0); + dev = device_find_child(parent, "vpo", -1); if (!dev) BUS_ADD_CHILD(parent, 0, "vpo", -1); } @@ -109,13 +108,8 @@ int error; vpo = DEVTOSOFTC(dev); - - /* vpo dependent initialisation */ - vpo->vpo_unit = device_get_unit(dev); + vpo->vpo_dev = dev; - /* low level probe */ - vpoio_set_unit(&vpo->vpo_io, vpo->vpo_unit); - /* check ZIP before ZIP+ or imm_probe() will send controls to * the printer or whatelse connected to the port */ if ((error = vpoio_probe(dev, &vpo->vpo_io)) == 0) { @@ -257,8 +251,8 @@ /* if a timeout occured, no sense */ if (vpo->vpo_error) { if (vpo->vpo_error != VP0_ESELECT_TIMEOUT) - printf("vpo%d: VP0 error/timeout (%d)\n", - vpo->vpo_unit, vpo->vpo_error); + device_printf(vpo->vpo_dev, "VP0 error/timeout (%d)\n", + vpo->vpo_error); csio->ccb_h.status = CAM_CMD_TIMEOUT; goto error; @@ -348,8 +342,8 @@ csio = &ccb->csio; #ifdef VP0_DEBUG - printf("vpo%d: XPT_SCSI_IO (0x%x) request\n", - vpo->vpo_unit, csio->cdb_io.cdb_bytes[0]); + device_printf(vpo->vpo_dev, "XPT_SCSI_IO (0x%x) request\n", + csio->cdb_io.cdb_bytes[0]); #endif vpo_intr(vpo, csio); @@ -365,8 +359,7 @@ ccg = &ccb->ccg; #ifdef VP0_DEBUG - printf("vpo%d: XPT_CALC_GEOMETRY (bs=%d,vs=%jd,c=%d,h=%d,spt=%d) request\n", - vpo->vpo_unit, + device_printf(vpo->vpo_dev, "XPT_CALC_GEOMETRY (bs=%d,vs=%jd,c=%d,h=%d,spt=%d) request\n", ccg->block_size, (intmax_t)ccg->volume_size, ccg->cylinders, @@ -387,7 +380,7 @@ { #ifdef VP0_DEBUG - printf("vpo%d: XPT_RESET_BUS request\n", vpo->vpo_unit); + device_printf(vpo->vpo_dev, "XPT_RESET_BUS request\n"); #endif if (vpo->vpo_isplus) { @@ -413,7 +406,7 @@ struct ccb_pathinq *cpi = &ccb->cpi; #ifdef VP0_DEBUG - printf("vpo%d: XPT_PATH_INQ request\n", vpo->vpo_unit); + device_printf(vpo->vpo_dev, "XPT_PATH_INQ request\n"); #endif cpi->version_num = 1; /* XXX??? */ cpi->hba_inquiry = 0; --- //depot/vendor/freebsd/src/sys/dev/ppbus/vpoio.c 2006/05/16 14:41:44 +++ //depot/user/jhb/acpipci/dev/ppbus/vpoio.c 2008/09/30 13:09:25 @@ -399,8 +399,8 @@ if (!vpoio_in_disk_mode(vpo)) { vpo->vpo_mode_found = VP0_MODE_UNDEFINED; if (bootverbose) - printf("vpo%d: can't connect to the drive\n", - vpo->vpo_unit); + device_printf(vpo->vpo_dev, + "can't connect to the drive\n"); /* disconnect and release the bus */ ppb_MS_microseq(ppbus, vpo->vpo_dev, disconnect_microseq, @@ -420,8 +420,8 @@ * may cause serious problem to the disk */ if (vpoio_in_disk_mode(vpo)) { if (bootverbose) - printf("vpo%d: can't disconnect from the drive\n", - vpo->vpo_unit); + device_printf(vpo->vpo_dev, + "can't disconnect from the drive\n"); goto error; } @@ -617,17 +617,17 @@ case VP0_MODE_EPP: ppb_MS_GET_init(ppbus, vpo->vpo_dev, epp17_instr_body); ppb_MS_PUT_init(ppbus, vpo->vpo_dev, epp17_outstr_body); - printf("vpo%d: EPP mode\n", vpo->vpo_unit); + device_printf(vpo->vpo_dev, "EPP mode\n"); break; case VP0_MODE_PS2: ppb_MS_GET_init(ppbus, vpo->vpo_dev, ps2_inbyte_submicroseq); ppb_MS_PUT_init(ppbus, vpo->vpo_dev, spp_outbyte_submicroseq); - printf("vpo%d: PS2 mode\n", vpo->vpo_unit); + device_printf(vpo->vpo_dev, "PS2 mode\n"); break; case VP0_MODE_NIBBLE: ppb_MS_GET_init(ppbus, vpo->vpo_dev, vpo->vpo_nibble_inbyte_msq); ppb_MS_PUT_init(ppbus, vpo->vpo_dev, spp_outbyte_submicroseq); - printf("vpo%d: NIBBLE mode\n", vpo->vpo_unit); + device_printf(vpo->vpo_dev, "NIBBLE mode\n"); break; default: panic("vpo: unknown mode %d", vpo->vpo_mode_found); --- //depot/vendor/freebsd/src/sys/dev/ppbus/vpoio.h 2001/07/17 07:20:42 +++ //depot/user/jhb/acpipci/dev/ppbus/vpoio.h 2008/09/30 13:09:25 @@ -66,7 +66,6 @@ #define VP0_MODE_EPP 0x3 struct vpoio_data { - unsigned short int vpo_unit; int vpo_mode_found; /* Mode found during init */ struct vpo_nibble vpo_nibble; @@ -77,8 +76,6 @@ device_t vpo_dev; }; -#define vpoio_set_unit(vpo,unit) ((vpo)->vpo_unit = unit) - int vpoio_probe(device_t dev, struct vpoio_data *vpo); int vpoio_attach(struct vpoio_data *vpo); --- //depot/vendor/freebsd/src/sys/dev/ppc/ppc.c 2008/09/15 22:30:14 +++ //depot/user/jhb/acpipci/dev/ppc/ppc.c 2008/09/30 14:04:26 @@ -133,8 +133,7 @@ DELAY(100); } - printf("ppc%d: ECP sync failed as data still " \ - "present in FIFO.\n", ppc->ppc_unit); + device_printf(dev, "ECP sync failed as data still present in FIFO.\n"); return; } @@ -752,8 +751,7 @@ if (bootverbose) { outb(csr, 0x1); - printf("ppc%d: SMC registers CR1=0x%x", ppc->ppc_unit, - inb(cio) & 0xff); + device_printf(dev, "SMC registers CR1=0x%x", inb(cio) & 0xff); outb(csr, 0x4); printf(" CR4=0x%x", inb(cio) & 0xff); @@ -1046,7 +1044,7 @@ if (bootverbose) { /* dump of registers */ - printf("ppc%d: 0x%x - ", ppc->ppc_unit, w83877f_keys[i]); + device_printf(dev, "0x%x - ", w83877f_keys[i]); for (i = 0; i <= 0xd; i ++) { outb(efir, i); printf("0x%x ", inb(efdr)); @@ -1062,7 +1060,6 @@ printf("0x%x ", inb(efdr)); } printf("\n"); - printf("ppc%d:", ppc->ppc_unit); } ppc->ppc_type = PPC_TYPE_GENERIC; @@ -1081,8 +1078,7 @@ switch (r) { case WINB_W83757: if (bootverbose) - printf("ppc%d: W83757 compatible mode\n", - ppc->ppc_unit); + device_printf(dev, "W83757 compatible mode\n"); return (-1); /* generic or SMC-like */ case WINB_EXTFDC: @@ -1090,19 +1086,20 @@ case WINB_EXT2FDD: case WINB_JOYSTICK: if (bootverbose) - printf(" not in parallel port mode\n"); + device_printf(dev, + "not in parallel port mode\n"); return (-1); case (WINB_PARALLEL | WINB_EPP_SPP): ppc->ppc_avm |= PPB_EPP | PPB_SPP; if (bootverbose) - printf(" EPP SPP"); + device_printf(dev, "EPP SPP\n"); break; case (WINB_PARALLEL | WINB_ECP): ppc->ppc_avm |= PPB_ECP | PPB_SPP; if (bootverbose) - printf(" ECP SPP"); + device_printf(dev, "ECP SPP\n"); break; case (WINB_PARALLEL | WINB_ECP_EPP): @@ -1110,7 +1107,7 @@ ppc->ppc_type = PPC_TYPE_SMCLIKE; if (bootverbose) - printf(" ECP+EPP SPP"); + device_printf(dev, "ECP+EPP SPP\n"); break; default: printf("%s: unknown case (0x%x)!\n", __func__, r); @@ -1131,27 +1128,24 @@ if (chipset_mode & PPB_EPP) { outb(efdr, inb(efdr) | WINB_ECP_EPP); if (bootverbose) - printf(" ECP+EPP"); + device_printf(dev, "ECP+EPP\n"); ppc->ppc_type = PPC_TYPE_SMCLIKE; } else { outb(efdr, inb(efdr) | WINB_ECP); if (bootverbose) - printf(" ECP"); + device_printf(dev, "ECP\n"); } } else { /* select EPP_SPP otherwise */ outb(efdr, inb(efdr) | WINB_EPP_SPP); if (bootverbose) - printf(" EPP SPP"); + device_printf(dev, "EPP SPP\n"); } ppc->ppc_avm = chipset_mode; } - if (bootverbose) - printf("\n"); - /* exit configuration mode */ outb(efer, 0xaa); @@ -1178,14 +1172,14 @@ ppc->ppc_type = PPC_TYPE_GENERIC; if (bootverbose) - printf("ppc%d:", ppc->ppc_unit); + device_printf(ppc->ppc_dev, "SPP"); /* first, check for ECP */ w_ecr(ppc, PPC_ECR_PS2); if ((r_ecr(ppc) & 0xe0) == PPC_ECR_PS2) { ppc->ppc_dtm |= PPB_ECP | PPB_SPP; if (bootverbose) - printf(" ECP SPP"); + printf(" ECP "); /* search for SMC style ECP+EPP mode */ w_ecr(ppc, PPC_ECR_EPP); @@ -1214,9 +1208,6 @@ /* XXX try to detect NIBBLE and PS2 modes */ ppc->ppc_dtm |= PPB_NIBBLE; - if (bootverbose) - printf(" SPP"); - if (chipset_mode) ppc->ppc_avm = chipset_mode; else @@ -1737,7 +1728,7 @@ if (ppc->res_drq) ppc->ppc_dmachan = rman_get_start(ppc->res_drq); - ppc->ppc_unit = device_get_unit(dev); + ppc->ppc_dev = dev; ppc->ppc_model = GENERIC; ppc->ppc_mode = PPB_COMPATIBLE; --- //depot/vendor/freebsd/src/sys/dev/ppc/ppcreg.h 2008/09/15 22:30:14 +++ //depot/user/jhb/acpipci/dev/ppc/ppcreg.h 2008/09/30 13:58:40 @@ -56,8 +56,7 @@ * Generic structure to hold parallel port chipset info. */ struct ppc_data { - - int ppc_unit; + device_t ppc_dev; int ppc_model; /* chipset model if detected */ int ppc_type; /* generic or smclike chipset type */