Date: Fri, 23 Jan 2009 15:50:23 +0000 From: "Bruce M. Simpson" <bms@FreeBSD.org> To: John Baldwin <jhb@freebsd.org> Cc: current@freebsd.org Subject: Re: [PATCH] ppbus/ppc locking Message-ID: <4979E73F.6000306@FreeBSD.org> In-Reply-To: <4979DB00.10503@FreeBSD.org> References: <200811191503.02192.jhb@freebsd.org> <200901211536.08297.jhb@freebsd.org> <4979BF48.7010704@FreeBSD.org> <200901230838.35340.jhb@freebsd.org> <4979D2C3.1050103@FreeBSD.org> <4979DB00.10503@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------040409010905030409070600 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Here's a diff with my edits. With these changes, the printer keeps being reported as busy, although I seem to be able to write to the /dev/lpt0 device, and it is seen. As Ed Schouten pointed out on IRC probably this unit2minor stuff needs to go back in. Back to work for this machine... --------------040409010905030409070600 Content-Type: text/plain; name="lpt.c.mine.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="lpt.c.mine.diff" --- lpt.c.jhb 2009-01-23 14:31:43.000000000 +0000 +++ lpt.c 2009-01-23 15:21:08.000000000 +0000 @@ -140,6 +140,7 @@ static timeout_t lptout; static int lpt_port_test(device_t dev, u_char data, u_char mask); +static int lpt_detach(device_t dev); static int lpt_detect(device_t dev); #define DEVTOSOFTC(dev) \ @@ -408,12 +409,22 @@ sc->sc_inbuf = malloc(BUFSIZE, M_DEVBUF, M_WAITOK); sc->sc_statbuf = malloc(BUFSTATSIZE, M_DEVBUF, M_WAITOK); sc->sc_dev = dev; - sc->sc_cdev = make_dev(&lpt_cdevsw, unit, + sc->sc_cdev = make_dev(&lpt_cdevsw, unit * 2, UID_ROOT, GID_WHEEL, 0600, LPT_NAME "%d", unit); + if (sc->sc_cdev == NULL) { + device_printf(dev, "Unable to create data device node\n"); + (void)lpt_detach(dev); + return (ENXIO); + } sc->sc_cdev->si_drv1 = sc; sc->sc_cdev->si_drv2 = 0; - sc->sc_cdev_bypass = make_dev(&lpt_cdevsw, unit, + sc->sc_cdev_bypass = make_dev(&lpt_cdevsw, (unit * 2) + 1, UID_ROOT, GID_WHEEL, 0600, LPT_NAME "%d.ctl", unit); + if (sc->sc_cdev_bypass == NULL) { + device_printf(dev, "Unable to create control device node\n"); + (void)lpt_detach(dev); + return (ENXIO); + } sc->sc_cdev_bypass->si_drv1 = sc; sc->sc_cdev_bypass->si_drv2 = (void *)LP_BYPASS; return (0); @@ -425,8 +436,10 @@ struct lpt_data *sc = DEVTOSOFTC(dev); device_t ppbus = device_get_parent(dev); - destroy_dev(sc->sc_cdev); - destroy_dev(sc->sc_cdev_bypass); + if (sc->sc_cdev) + destroy_dev(sc->sc_cdev); + if (sc->sc_cdev_bypass) + destroy_dev(sc->sc_cdev_bypass); ppb_lock(ppbus); lpt_release_ppbus(dev); ppb_unlock(ppbus); --------------040409010905030409070600--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4979E73F.6000306>