From owner-svn-src-head@FreeBSD.ORG Wed Apr 15 19:58:42 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 107B5106564A; Wed, 15 Apr 2009 19:58:42 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E89198FC13; Wed, 15 Apr 2009 19:58:41 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3FJwflh052983; Wed, 15 Apr 2009 19:58:41 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3FJwfqD052982; Wed, 15 Apr 2009 19:58:41 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200904151958.n3FJwfqD052982@svn.freebsd.org> From: Ed Schouten Date: Wed, 15 Apr 2009 19:58:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191114 - head/sys/pc98/cbus X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Apr 2009 19:58:42 -0000 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 */