Date: Wed, 15 Apr 2009 19:58:41 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r191114 - head/sys/pc98/cbus Message-ID: <200904151958.n3FJwfqD052982@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Wed Apr 15 19:58:41 2009 New Revision: 191114 URL: http://svn.freebsd.org/changeset/base/191114 Log: Migrate the olpt(4) driver to si_drv1 instead of using dev2unit(). Approved by: nyan Modified: head/sys/pc98/cbus/olpt.c Modified: head/sys/pc98/cbus/olpt.c ============================================================================== --- head/sys/pc98/cbus/olpt.c Wed Apr 15 19:10:37 2009 (r191113) +++ head/sys/pc98/cbus/olpt.c Wed Apr 15 19:58:41 2009 (r191114) @@ -136,9 +136,6 @@ static int volatile lptflag = 1; #endif -#define LPTUNIT(s) ((s)&0x03) -#define LPTFLAGS(s) ((s)&0xfc) - struct lpt_softc { struct resource *res_port; struct resource *res_irq; @@ -318,6 +315,7 @@ lpt_attach(device_t dev) { int rid, unit; struct lpt_softc *sc; + struct cdev *cdev; unit = device_get_unit(dev); sc = device_get_softc(dev); @@ -360,10 +358,12 @@ lpt_attach(device_t dev) device_printf(dev, "Interrupt-driven port"); } - /* XXX what to do about the flags in the minor number? */ - make_dev(&lpt_cdevsw, unit, UID_ROOT, GID_WHEEL, 0600, "lpt%d", unit); - make_dev(&lpt_cdevsw, unit | LP_BYPASS, + cdev = make_dev(&lpt_cdevsw, 0, + UID_ROOT, GID_WHEEL, 0600, "lpt%d", unit); + cdev->si_drv1 = sc; + cdev = make_dev(&lpt_cdevsw, LP_BYPASS, UID_ROOT, GID_WHEEL, 0600, "lpctl%d", unit); + cdev->si_drv1 = sc; return 0; } @@ -377,11 +377,10 @@ lpt_attach(device_t dev) static int lptopen (struct cdev *dev, int flags, int fmt, struct thread *td) { - struct lpt_softc *sc; + struct lpt_softc *sc = dev->si_drv1; int s; int port; - sc = devclass_get_softc(olpt_devclass, LPTUNIT(dev2unit(dev))); if (sc->sc_port == 0) return (ENXIO); @@ -391,7 +390,7 @@ lptopen (struct cdev *dev, int flags, in } else sc->sc_state |= INIT; - sc->sc_flags = LPTFLAGS(dev2unit(dev)); + sc->sc_flags = dev2unit(dev); /* Check for open with BYPASS flag set. */ if (sc->sc_flags & LP_BYPASS) { @@ -467,9 +466,8 @@ lptout (void *arg) static int lptclose(struct cdev *dev, int flags, int fmt, struct thread *td) { - struct lpt_softc *sc; + struct lpt_softc *sc = dev->si_drv1; - sc = devclass_get_softc(olpt_devclass, LPTUNIT(dev2unit(dev))); if(sc->sc_flags & LP_BYPASS) goto end_close; @@ -556,9 +554,8 @@ lptwrite(struct cdev *dev, struct uio * { register unsigned n; int pl, err; - struct lpt_softc *sc; + struct lpt_softc *sc = dev->si_drv1; - sc = devclass_get_softc(olpt_devclass, LPTUNIT(dev2unit(dev))); if(sc->sc_flags & LP_BYPASS) { /* we can't do writes in bypass mode */ return(EPERM); @@ -613,12 +610,9 @@ static int lptioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td) { int error = 0; - struct lpt_softc *sc; - u_int unit = LPTUNIT(dev2unit(dev)); + struct lpt_softc *sc = dev->si_drv1; u_char old_sc_irq; /* old printer IRQ status */ - sc = devclass_get_softc(olpt_devclass, unit); - switch (cmd) { case LPT_IRQ : if(sc->sc_irq & LP_HAS_IRQ) { @@ -637,8 +631,8 @@ lptioctl(struct cdev *dev, u_long cmd, c else sc->sc_irq |= LP_ENABLE_IRQ; if (old_sc_irq != sc->sc_irq ) - log(LOG_NOTICE, "lpt%c switched to %s mode\n", - (char)unit+'0', + log(LOG_NOTICE, "%s switched to %s mode\n", + devtoname(dev), (sc->sc_irq & LP_ENABLE_IRQ)? "interrupt-driven":"polled"); } else /* polled port */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904151958.n3FJwfqD052982>