Home | History | Annotate | Line # | Download | only in usb
ulpt.c revision 1.41.2.9
      1  1.41.2.6   nathanw /*	$NetBSD: ulpt.c,v 1.41.2.9 2002/10/18 02:44:34 nathanw Exp $	*/
      2      1.30  augustss /*	$FreeBSD: src/sys/dev/usb/ulpt.c,v 1.24 1999/11/17 22:33:44 n_hibma Exp $	*/
      3       1.1  augustss 
      4       1.1  augustss /*
      5       1.1  augustss  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      6       1.1  augustss  * All rights reserved.
      7       1.1  augustss  *
      8       1.3  augustss  * This code is derived from software contributed to The NetBSD Foundation
      9      1.37  augustss  * by Lennart Augustsson (lennart (at) augustsson.net) at
     10       1.3  augustss  * Carlstedt Research & Technology.
     11       1.1  augustss  *
     12       1.1  augustss  * Redistribution and use in source and binary forms, with or without
     13       1.1  augustss  * modification, are permitted provided that the following conditions
     14       1.1  augustss  * are met:
     15       1.1  augustss  * 1. Redistributions of source code must retain the above copyright
     16       1.1  augustss  *    notice, this list of conditions and the following disclaimer.
     17       1.1  augustss  * 2. Redistributions in binary form must reproduce the above copyright
     18       1.1  augustss  *    notice, this list of conditions and the following disclaimer in the
     19       1.1  augustss  *    documentation and/or other materials provided with the distribution.
     20       1.1  augustss  * 3. All advertising materials mentioning features or use of this software
     21       1.1  augustss  *    must display the following acknowledgement:
     22       1.1  augustss  *        This product includes software developed by the NetBSD
     23       1.1  augustss  *        Foundation, Inc. and its contributors.
     24       1.1  augustss  * 4. Neither the name of The NetBSD Foundation nor the names of its
     25       1.1  augustss  *    contributors may be used to endorse or promote products derived
     26       1.1  augustss  *    from this software without specific prior written permission.
     27       1.1  augustss  *
     28       1.1  augustss  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     29       1.1  augustss  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     30       1.1  augustss  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     31       1.1  augustss  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     32       1.1  augustss  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     33       1.1  augustss  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     34       1.1  augustss  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     35       1.1  augustss  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     36       1.1  augustss  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     37       1.1  augustss  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     38       1.1  augustss  * POSSIBILITY OF SUCH DAMAGE.
     39      1.11  augustss  */
     40      1.11  augustss 
     41      1.11  augustss /*
     42      1.40  augustss  * Printer Class spec: http://www.usb.org/developers/data/devclass/usbprint109.PDF
     43       1.1  augustss  */
     44  1.41.2.3   nathanw 
     45  1.41.2.3   nathanw #include <sys/cdefs.h>
     46  1.41.2.6   nathanw __KERNEL_RCSID(0, "$NetBSD: ulpt.c,v 1.41.2.9 2002/10/18 02:44:34 nathanw Exp $");
     47      1.27  augustss 
     48       1.1  augustss #include <sys/param.h>
     49       1.1  augustss #include <sys/systm.h>
     50       1.1  augustss #include <sys/proc.h>
     51       1.1  augustss #include <sys/kernel.h>
     52      1.35  augustss #if defined(__NetBSD__) || defined(__OpenBSD__)
     53       1.8  augustss #include <sys/device.h>
     54       1.1  augustss #include <sys/ioctl.h>
     55       1.8  augustss #elif defined(__FreeBSD__)
     56       1.8  augustss #include <sys/ioccom.h>
     57       1.8  augustss #include <sys/module.h>
     58       1.8  augustss #include <sys/bus.h>
     59       1.8  augustss #endif
     60       1.1  augustss #include <sys/uio.h>
     61       1.1  augustss #include <sys/conf.h>
     62      1.12  augustss #include <sys/vnode.h>
     63       1.1  augustss #include <sys/syslog.h>
     64       1.1  augustss 
     65       1.1  augustss #include <dev/usb/usb.h>
     66       1.1  augustss #include <dev/usb/usbdi.h>
     67       1.1  augustss #include <dev/usb/usbdi_util.h>
     68       1.1  augustss #include <dev/usb/usbdevs.h>
     69       1.1  augustss #include <dev/usb/usb_quirks.h>
     70       1.1  augustss 
     71       1.1  augustss #define	TIMEOUT		hz*16	/* wait up to 16 seconds for a ready */
     72       1.1  augustss #define	STEP		hz/4
     73       1.1  augustss 
     74       1.1  augustss #define	LPTPRI		(PZERO+8)
     75      1.25  augustss #define	ULPT_BSIZE	16384
     76       1.1  augustss 
     77      1.27  augustss #ifdef ULPT_DEBUG
     78      1.14  augustss #define DPRINTF(x)	if (ulptdebug) logprintf x
     79      1.14  augustss #define DPRINTFN(n,x)	if (ulptdebug>(n)) logprintf x
     80       1.1  augustss int	ulptdebug = 0;
     81       1.1  augustss #else
     82       1.1  augustss #define DPRINTF(x)
     83       1.1  augustss #define DPRINTFN(n,x)
     84       1.1  augustss #endif
     85       1.1  augustss 
     86       1.1  augustss #define UR_GET_DEVICE_ID 0
     87       1.1  augustss #define UR_GET_PORT_STATUS 1
     88       1.1  augustss #define UR_SOFT_RESET 2
     89       1.1  augustss 
     90       1.1  augustss #define	LPS_NERR		0x08	/* printer no error */
     91       1.1  augustss #define	LPS_SELECT		0x10	/* printer selected */
     92       1.1  augustss #define	LPS_NOPAPER		0x20	/* printer out of paper */
     93       1.1  augustss #define LPS_INVERT      (LPS_SELECT|LPS_NERR)
     94       1.1  augustss #define LPS_MASK        (LPS_SELECT|LPS_NERR|LPS_NOPAPER)
     95       1.1  augustss 
     96       1.1  augustss struct ulpt_softc {
     97      1.20  augustss 	USBBASEDEVICE sc_dev;
     98       1.1  augustss 	usbd_device_handle sc_udev;	/* device */
     99       1.1  augustss 	usbd_interface_handle sc_iface;	/* interface */
    100       1.1  augustss 	int sc_ifaceno;
    101  1.41.2.1   nathanw 
    102  1.41.2.1   nathanw 	int sc_out;
    103  1.41.2.1   nathanw 	usbd_pipe_handle sc_out_pipe;	/* bulk out pipe */
    104  1.41.2.1   nathanw 
    105  1.41.2.1   nathanw 	int sc_in;
    106  1.41.2.1   nathanw 	usbd_pipe_handle sc_in_pipe;	/* bulk in pipe */
    107  1.41.2.1   nathanw 	usbd_xfer_handle sc_in_xfer1;
    108  1.41.2.1   nathanw 	usbd_xfer_handle sc_in_xfer2;
    109  1.41.2.1   nathanw 	u_char sc_junk[64];	/* somewhere to dump input */
    110       1.1  augustss 
    111       1.1  augustss 	u_char sc_state;
    112       1.1  augustss #define	ULPT_OPEN	0x01	/* device is open */
    113       1.1  augustss #define	ULPT_OBUSY	0x02	/* printer is busy doing output */
    114       1.1  augustss #define	ULPT_INIT	0x04	/* waiting to initialize for open */
    115       1.1  augustss 	u_char sc_flags;
    116       1.1  augustss #define	ULPT_NOPRIME	0x40	/* don't prime on open */
    117       1.1  augustss 	u_char sc_laststatus;
    118      1.12  augustss 
    119      1.12  augustss 	int sc_refcnt;
    120      1.12  augustss 	u_char sc_dying;
    121      1.27  augustss 
    122      1.27  augustss #if defined(__FreeBSD__)
    123      1.27  augustss 	dev_t dev;
    124      1.27  augustss 	dev_t dev_noprime;
    125      1.27  augustss #endif
    126       1.1  augustss };
    127       1.1  augustss 
    128  1.41.2.8   nathanw #if defined(__NetBSD__)
    129  1.41.2.8   nathanw dev_type_open(ulptopen);
    130  1.41.2.8   nathanw dev_type_close(ulptclose);
    131  1.41.2.8   nathanw dev_type_write(ulptwrite);
    132  1.41.2.8   nathanw dev_type_ioctl(ulptioctl);
    133  1.41.2.8   nathanw 
    134  1.41.2.8   nathanw const struct cdevsw ulpt_cdevsw = {
    135  1.41.2.8   nathanw 	ulptopen, ulptclose, noread, ulptwrite, ulptioctl,
    136  1.41.2.8   nathanw 	nostop, notty, nopoll, nommap,
    137  1.41.2.8   nathanw };
    138  1.41.2.8   nathanw #elif defined(__OpenBSD__)
    139      1.28  augustss cdev_decl(ulpt);
    140      1.27  augustss #elif defined(__FreeBSD__)
    141      1.34  augustss Static d_open_t ulptopen;
    142      1.34  augustss Static d_close_t ulptclose;
    143      1.34  augustss Static d_write_t ulptwrite;
    144      1.34  augustss Static d_ioctl_t ulptioctl;
    145      1.27  augustss 
    146      1.27  augustss #define ULPT_CDEV_MAJOR 113
    147      1.27  augustss 
    148      1.34  augustss Static struct cdevsw ulpt_cdevsw = {
    149      1.27  augustss 	/* open */	ulptopen,
    150      1.27  augustss 	/* close */	ulptclose,
    151      1.27  augustss 	/* read */	noread,
    152      1.27  augustss 	/* write */	ulptwrite,
    153      1.27  augustss 	/* ioctl */	ulptioctl,
    154      1.27  augustss 	/* poll */	nopoll,
    155      1.27  augustss 	/* mmap */	nommap,
    156      1.27  augustss 	/* strategy */	nostrategy,
    157      1.27  augustss 	/* name */	"ulpt",
    158      1.27  augustss 	/* maj */	ULPT_CDEV_MAJOR,
    159      1.27  augustss 	/* dump */	nodump,
    160      1.27  augustss 	/* psize */	nopsize,
    161      1.27  augustss 	/* flags */	0,
    162  1.41.2.5   nathanw #if !defined(__FreeBSD__) || (__FreeBSD__ < 5)
    163      1.27  augustss 	/* bmaj */	-1
    164  1.41.2.5   nathanw #endif
    165      1.27  augustss };
    166      1.27  augustss #endif
    167      1.27  augustss 
    168      1.38  augustss void ulpt_disco(void *);
    169       1.1  augustss 
    170      1.38  augustss int ulpt_do_write(struct ulpt_softc *, struct uio *uio, int);
    171      1.38  augustss int ulpt_status(struct ulpt_softc *);
    172      1.38  augustss void ulpt_reset(struct ulpt_softc *);
    173      1.38  augustss int ulpt_statusmsg(u_char, struct ulpt_softc *);
    174       1.1  augustss 
    175  1.41.2.1   nathanw #if 0
    176      1.38  augustss void ieee1284_print_id(char *);
    177  1.41.2.1   nathanw #endif
    178      1.16  augustss 
    179       1.1  augustss #define	ULPTUNIT(s)	(minor(s) & 0x1f)
    180       1.1  augustss #define	ULPTFLAGS(s)	(minor(s) & 0xe0)
    181       1.1  augustss 
    182      1.27  augustss 
    183       1.8  augustss USB_DECLARE_DRIVER(ulpt);
    184       1.1  augustss 
    185       1.8  augustss USB_MATCH(ulpt)
    186       1.1  augustss {
    187       1.8  augustss 	USB_MATCH_START(ulpt, uaa);
    188       1.1  augustss 	usb_interface_descriptor_t *id;
    189  1.41.2.6   nathanw 
    190       1.1  augustss 	DPRINTFN(10,("ulpt_match\n"));
    191      1.28  augustss 	if (uaa->iface == NULL)
    192       1.1  augustss 		return (UMATCH_NONE);
    193       1.1  augustss 	id = usbd_get_interface_descriptor(uaa->iface);
    194      1.28  augustss 	if (id != NULL &&
    195      1.32  augustss 	    id->bInterfaceClass == UICLASS_PRINTER &&
    196      1.32  augustss 	    id->bInterfaceSubClass == UISUBCLASS_PRINTER &&
    197      1.32  augustss 	    (id->bInterfaceProtocol == UIPROTO_PRINTER_UNI ||
    198  1.41.2.2   nathanw 	     id->bInterfaceProtocol == UIPROTO_PRINTER_BI ||
    199  1.41.2.2   nathanw 	     id->bInterfaceProtocol == UIPROTO_PRINTER_1284))
    200       1.1  augustss 		return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO);
    201       1.1  augustss 	return (UMATCH_NONE);
    202       1.1  augustss }
    203       1.1  augustss 
    204       1.8  augustss USB_ATTACH(ulpt)
    205       1.1  augustss {
    206       1.8  augustss 	USB_ATTACH_START(ulpt, sc, uaa);
    207       1.1  augustss 	usbd_device_handle dev = uaa->device;
    208       1.1  augustss 	usbd_interface_handle iface = uaa->iface;
    209  1.41.2.1   nathanw 	usb_interface_descriptor_t *ifcd = usbd_get_interface_descriptor(iface);
    210  1.41.2.1   nathanw 	usb_interface_descriptor_t *id, *iend;
    211  1.41.2.1   nathanw 	usb_config_descriptor_t *cdesc;
    212  1.41.2.1   nathanw 	usbd_status err;
    213       1.1  augustss 	char devinfo[1024];
    214       1.1  augustss 	usb_endpoint_descriptor_t *ed;
    215  1.41.2.1   nathanw 	u_int8_t epcount;
    216  1.41.2.1   nathanw 	int i, altno;
    217  1.41.2.6   nathanw 
    218       1.8  augustss 	DPRINTFN(10,("ulpt_attach: sc=%p\n", sc));
    219       1.2  augustss 	usbd_devinfo(dev, 0, devinfo);
    220       1.8  augustss 	USB_ATTACH_SETUP;
    221       1.8  augustss 	printf("%s: %s, iclass %d/%d\n", USBDEVNAME(sc->sc_dev),
    222  1.41.2.1   nathanw 	       devinfo, ifcd->bInterfaceClass, ifcd->bInterfaceSubClass);
    223       1.1  augustss 
    224  1.41.2.6   nathanw 	/* XXX
    225  1.41.2.1   nathanw 	 * Stepping through the alternate settings needs to be abstracted out.
    226  1.41.2.1   nathanw 	 */
    227  1.41.2.1   nathanw 	cdesc = usbd_get_config_descriptor(dev);
    228  1.41.2.1   nathanw 	if (cdesc == NULL) {
    229  1.41.2.1   nathanw 		printf("%s: failed to get configuration descriptor\n",
    230  1.41.2.1   nathanw 		       USBDEVNAME(sc->sc_dev));
    231  1.41.2.1   nathanw 		USB_ATTACH_ERROR_RETURN;
    232  1.41.2.1   nathanw 	}
    233  1.41.2.1   nathanw 	iend = (usb_interface_descriptor_t *)
    234  1.41.2.1   nathanw 		   ((char *)cdesc + UGETW(cdesc->wTotalLength));
    235  1.41.2.1   nathanw #ifdef DIAGNOSTIC
    236  1.41.2.1   nathanw 	if (ifcd < (usb_interface_descriptor_t *)cdesc ||
    237  1.41.2.1   nathanw 	    ifcd >= iend)
    238  1.41.2.9   nathanw 		panic("ulpt: iface desc out of range");
    239  1.41.2.1   nathanw #endif
    240  1.41.2.1   nathanw 	/* Step through all the descriptors looking for bidir mode */
    241  1.41.2.1   nathanw 	for (id = ifcd, altno = 0;
    242  1.41.2.1   nathanw 	     id < iend;
    243  1.41.2.1   nathanw 	     id = (void *)((char *)id + id->bLength)) {
    244  1.41.2.1   nathanw 		if (id->bDescriptorType == UDESC_INTERFACE &&
    245  1.41.2.1   nathanw 		    id->bInterfaceNumber == ifcd->bInterfaceNumber) {
    246  1.41.2.1   nathanw 			if (id->bInterfaceClass == UICLASS_PRINTER &&
    247  1.41.2.1   nathanw 			    id->bInterfaceSubClass == UISUBCLASS_PRINTER &&
    248  1.41.2.2   nathanw 			    (id->bInterfaceProtocol == UIPROTO_PRINTER_BI ||
    249  1.41.2.2   nathanw 			     id->bInterfaceProtocol == UIPROTO_PRINTER_1284))
    250  1.41.2.1   nathanw 				goto found;
    251  1.41.2.1   nathanw 			altno++;
    252  1.41.2.1   nathanw 		}
    253  1.41.2.1   nathanw 	}
    254  1.41.2.1   nathanw 	id = ifcd;		/* not found, use original */
    255  1.41.2.1   nathanw  found:
    256  1.41.2.1   nathanw 	if (id != ifcd) {
    257  1.41.2.1   nathanw 		/* Found a new bidir setting */
    258  1.41.2.1   nathanw 		DPRINTF(("ulpt_attach: set altno = %d\n", altno));
    259  1.41.2.1   nathanw 		err = usbd_set_interface(iface, altno);
    260  1.41.2.1   nathanw 		if (err) {
    261  1.41.2.1   nathanw 			printf("%s: setting alternate interface failed\n",
    262  1.41.2.1   nathanw 			       USBDEVNAME(sc->sc_dev));
    263  1.41.2.1   nathanw 			sc->sc_dying = 1;
    264  1.41.2.1   nathanw 			USB_ATTACH_ERROR_RETURN;
    265  1.41.2.1   nathanw 		}
    266       1.1  augustss 	}
    267       1.1  augustss 
    268  1.41.2.1   nathanw 	epcount = 0;
    269  1.41.2.1   nathanw 	(void)usbd_endpoint_count(iface, &epcount);
    270  1.41.2.1   nathanw 
    271  1.41.2.1   nathanw 	sc->sc_in = -1;
    272  1.41.2.1   nathanw 	sc->sc_out = -1;
    273  1.41.2.1   nathanw 	for (i = 0; i < epcount; i++) {
    274  1.41.2.1   nathanw 		ed = usbd_interface2endpoint_descriptor(iface, i);
    275  1.41.2.1   nathanw 		if (ed == NULL) {
    276  1.41.2.1   nathanw 			printf("%s: couldn't get ep %d\n",
    277  1.41.2.1   nathanw 			    USBDEVNAME(sc->sc_dev), i);
    278  1.41.2.1   nathanw 			USB_ATTACH_ERROR_RETURN;
    279  1.41.2.1   nathanw 		}
    280  1.41.2.1   nathanw 		if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
    281  1.41.2.1   nathanw 		    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
    282  1.41.2.1   nathanw 			sc->sc_in = ed->bEndpointAddress;
    283  1.41.2.1   nathanw 		} else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
    284  1.41.2.1   nathanw 			   UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
    285  1.41.2.1   nathanw 			sc->sc_out = ed->bEndpointAddress;
    286  1.41.2.1   nathanw 		}
    287  1.41.2.1   nathanw 	}
    288  1.41.2.1   nathanw 	if (sc->sc_out == -1) {
    289  1.41.2.7   nathanw 		printf("%s: could not find bulk out endpoint\n",
    290  1.41.2.1   nathanw 		    USBDEVNAME(sc->sc_dev));
    291      1.12  augustss 		sc->sc_dying = 1;
    292       1.8  augustss 		USB_ATTACH_ERROR_RETURN;
    293      1.12  augustss 	}
    294  1.41.2.1   nathanw 
    295  1.41.2.1   nathanw 	if (usbd_get_quirks(dev)->uq_flags & UQ_BROKEN_BIDIR) {
    296  1.41.2.1   nathanw 		/* This device doesn't handle reading properly. */
    297  1.41.2.1   nathanw 		sc->sc_in = -1;
    298  1.41.2.1   nathanw 	}
    299  1.41.2.7   nathanw 
    300  1.41.2.7   nathanw 	printf("%s: using %s-directional mode\n", USBDEVNAME(sc->sc_dev),
    301  1.41.2.7   nathanw 	       sc->sc_in >= 0 ? "bi" : "uni");
    302  1.41.2.1   nathanw 
    303  1.41.2.1   nathanw 	DPRINTFN(10, ("ulpt_attach: bulk=%d\n", sc->sc_out));
    304  1.41.2.1   nathanw 
    305  1.41.2.1   nathanw 	sc->sc_iface = iface;
    306       1.1  augustss 	sc->sc_ifaceno = id->bInterfaceNumber;
    307  1.41.2.1   nathanw 	sc->sc_udev = dev;
    308       1.1  augustss 
    309      1.22  augustss #if 0
    310      1.22  augustss /*
    311      1.36  augustss  * This code is disabled because for some mysterious reason it causes
    312      1.22  augustss  * printing not to work.  But only sometimes, and mostly with
    313      1.22  augustss  * UHCI and less often with OHCI.  *sigh*
    314      1.22  augustss  */
    315      1.22  augustss 	{
    316      1.22  augustss 	usb_config_descriptor_t *cd = usbd_get_config_descriptor(dev);
    317      1.22  augustss 	usb_device_request_t req;
    318      1.22  augustss 	int len, alen;
    319      1.22  augustss 
    320       1.1  augustss 	req.bmRequestType = UT_READ_CLASS_INTERFACE;
    321       1.1  augustss 	req.bRequest = UR_GET_DEVICE_ID;
    322       1.1  augustss 	USETW(req.wValue, cd->bConfigurationValue);
    323       1.1  augustss 	USETW2(req.wIndex, id->bInterfaceNumber, id->bAlternateSetting);
    324       1.1  augustss 	USETW(req.wLength, sizeof devinfo - 1);
    325  1.41.2.5   nathanw 	err = usbd_do_request_flags(dev, &req, devinfo, USBD_SHORT_XFER_OK,
    326  1.41.2.5   nathanw 		  &alen, USBD_DEFAULT_TIMEOUT);
    327      1.28  augustss 	if (err) {
    328      1.16  augustss 		printf("%s: cannot get device id\n", USBDEVNAME(sc->sc_dev));
    329      1.16  augustss 	} else if (alen <= 2) {
    330      1.16  augustss 		printf("%s: empty device id, no printer connected?\n",
    331      1.16  augustss 		       USBDEVNAME(sc->sc_dev));
    332      1.16  augustss 	} else {
    333       1.1  augustss 		/* devinfo now contains an IEEE-1284 device ID */
    334      1.16  augustss 		len = ((devinfo[0] & 0xff) << 8) | (devinfo[1] & 0xff);
    335      1.16  augustss 		if (len > sizeof devinfo - 3)
    336      1.16  augustss 			len = sizeof devinfo - 3;
    337      1.16  augustss 		devinfo[len] = 0;
    338      1.16  augustss 		printf("%s: device id <", USBDEVNAME(sc->sc_dev));
    339      1.16  augustss 		ieee1284_print_id(devinfo+2);
    340      1.16  augustss 		printf(">\n");
    341       1.1  augustss 	}
    342      1.22  augustss 	}
    343      1.22  augustss #endif
    344       1.1  augustss 
    345      1.27  augustss #if defined(__FreeBSD__)
    346      1.27  augustss 	sc->dev = make_dev(&ulpt_cdevsw, device_get_unit(self),
    347      1.27  augustss 		UID_ROOT, GID_OPERATOR, 0644, "ulpt%d", device_get_unit(self));
    348      1.27  augustss 	sc->dev_noprime = make_dev(&ulpt_cdevsw,
    349      1.27  augustss 		device_get_unit(self)|ULPT_NOPRIME,
    350      1.27  augustss 		UID_ROOT, GID_OPERATOR, 0644, "unlpt%d", device_get_unit(self));
    351      1.27  augustss #endif
    352      1.27  augustss 
    353      1.31  augustss 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
    354      1.31  augustss 			   USBDEV(sc->sc_dev));
    355      1.31  augustss 
    356       1.8  augustss 	USB_ATTACH_SUCCESS_RETURN;
    357       1.1  augustss }
    358       1.1  augustss 
    359      1.27  augustss #if defined(__NetBSD__) || defined(__OpenBSD__)
    360       1.1  augustss int
    361      1.38  augustss ulpt_activate(device_ptr_t self, enum devact act)
    362      1.12  augustss {
    363      1.17  augustss 	struct ulpt_softc *sc = (struct ulpt_softc *)self;
    364      1.17  augustss 
    365      1.17  augustss 	switch (act) {
    366      1.17  augustss 	case DVACT_ACTIVATE:
    367      1.17  augustss 		return (EOPNOTSUPP);
    368      1.17  augustss 
    369      1.17  augustss 	case DVACT_DEACTIVATE:
    370      1.17  augustss 		sc->sc_dying = 1;
    371      1.17  augustss 		break;
    372      1.17  augustss 	}
    373      1.12  augustss 	return (0);
    374      1.12  augustss }
    375      1.27  augustss #endif
    376      1.12  augustss 
    377      1.27  augustss USB_DETACH(ulpt)
    378      1.12  augustss {
    379      1.27  augustss 	USB_DETACH_START(ulpt, sc);
    380      1.27  augustss 	int s;
    381      1.27  augustss #if defined(__NetBSD__) || defined(__OpenBSD__)
    382      1.12  augustss 	int maj, mn;
    383      1.27  augustss #elif defined(__FreeBSD__)
    384  1.41.2.5   nathanw 	struct vnode *vp;
    385      1.27  augustss #endif
    386      1.12  augustss 
    387  1.41.2.5   nathanw 	DPRINTF(("ulpt_detach: sc=%p\n", sc));
    388  1.41.2.5   nathanw 
    389      1.12  augustss 	sc->sc_dying = 1;
    390  1.41.2.1   nathanw 	if (sc->sc_out_pipe != NULL)
    391  1.41.2.1   nathanw 		usbd_abort_pipe(sc->sc_out_pipe);
    392  1.41.2.1   nathanw 	if (sc->sc_in_pipe != NULL)
    393  1.41.2.1   nathanw 		usbd_abort_pipe(sc->sc_in_pipe);
    394      1.12  augustss 
    395      1.12  augustss 	s = splusb();
    396      1.12  augustss 	if (--sc->sc_refcnt >= 0) {
    397      1.12  augustss 		/* There is noone to wake, aborting the pipe is enough */
    398      1.12  augustss 		/* Wait for processes to go away. */
    399      1.20  augustss 		usb_detach_wait(USBDEV(sc->sc_dev));
    400      1.12  augustss 	}
    401      1.12  augustss 	splx(s);
    402      1.12  augustss 
    403      1.27  augustss #if defined(__NetBSD__) || defined(__OpenBSD__)
    404      1.12  augustss 	/* locate the major number */
    405  1.41.2.8   nathanw #if defined(__NetBSD__)
    406  1.41.2.8   nathanw 	maj = cdevsw_lookup_major(&ulpt_cdevsw);
    407  1.41.2.8   nathanw #elif defined(__OpenBSD__)
    408      1.12  augustss 	for (maj = 0; maj < nchrdev; maj++)
    409      1.12  augustss 		if (cdevsw[maj].d_open == ulptopen)
    410      1.12  augustss 			break;
    411  1.41.2.8   nathanw #endif
    412      1.12  augustss 
    413      1.12  augustss 	/* Nuke the vnodes for any open instances (calls close). */
    414      1.12  augustss 	mn = self->dv_unit;
    415      1.12  augustss 	vdevgone(maj, mn, mn, VCHR);
    416      1.27  augustss #elif defined(__FreeBSD__)
    417  1.41.2.5   nathanw 	vp = SLIST_FIRST(&sc->dev->si_hlist);
    418  1.41.2.5   nathanw 	if (vp)
    419  1.41.2.5   nathanw 		VOP_REVOKE(vp, REVOKEALL);
    420  1.41.2.5   nathanw 	vp = SLIST_FIRST(&sc->dev_noprime->si_hlist);
    421  1.41.2.5   nathanw 	if (vp)
    422  1.41.2.5   nathanw 		VOP_REVOKE(vp, REVOKEALL);
    423      1.27  augustss 
    424      1.30  augustss 	destroy_dev(sc->dev);
    425      1.30  augustss 	destroy_dev(sc->dev_noprime);
    426      1.27  augustss #endif
    427      1.31  augustss 
    428      1.31  augustss 	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
    429      1.31  augustss 			   USBDEV(sc->sc_dev));
    430      1.12  augustss 
    431      1.12  augustss 	return (0);
    432      1.12  augustss }
    433      1.12  augustss 
    434      1.12  augustss int
    435      1.38  augustss ulpt_status(struct ulpt_softc *sc)
    436       1.1  augustss {
    437       1.1  augustss 	usb_device_request_t req;
    438      1.28  augustss 	usbd_status err;
    439       1.1  augustss 	u_char status;
    440       1.1  augustss 
    441       1.1  augustss 	req.bmRequestType = UT_READ_CLASS_INTERFACE;
    442       1.1  augustss 	req.bRequest = UR_GET_PORT_STATUS;
    443       1.1  augustss 	USETW(req.wValue, 0);
    444       1.1  augustss 	USETW(req.wIndex, sc->sc_ifaceno);
    445       1.1  augustss 	USETW(req.wLength, 1);
    446      1.28  augustss 	err = usbd_do_request(sc->sc_udev, &req, &status);
    447      1.30  augustss 	DPRINTFN(1, ("ulpt_status: status=0x%02x err=%d\n", status, err));
    448      1.28  augustss 	if (!err)
    449       1.1  augustss 		return (status);
    450       1.1  augustss 	else
    451       1.1  augustss 		return (0);
    452       1.1  augustss }
    453       1.1  augustss 
    454       1.1  augustss void
    455      1.38  augustss ulpt_reset(struct ulpt_softc *sc)
    456       1.1  augustss {
    457       1.1  augustss 	usb_device_request_t req;
    458       1.1  augustss 
    459       1.1  augustss 	DPRINTFN(1, ("ulpt_reset\n"));
    460       1.1  augustss 	req.bRequest = UR_SOFT_RESET;
    461       1.1  augustss 	USETW(req.wValue, 0);
    462       1.1  augustss 	USETW(req.wIndex, sc->sc_ifaceno);
    463       1.1  augustss 	USETW(req.wLength, 0);
    464      1.41  augustss 
    465      1.41  augustss 	/*
    466      1.41  augustss 	 * There was a mistake in the USB printer 1.0 spec that gave the
    467  1.41.2.1   nathanw 	 * request type as UT_WRITE_CLASS_OTHER; it should have been
    468      1.41  augustss 	 * UT_WRITE_CLASS_INTERFACE.  Many printers use the old one,
    469      1.41  augustss 	 * so we try both.
    470      1.41  augustss 	 */
    471  1.41.2.5   nathanw 	req.bmRequestType = UT_WRITE_CLASS_OTHER;
    472  1.41.2.1   nathanw 	if (usbd_do_request(sc->sc_udev, &req, 0)) {	/* 1.0 */
    473      1.41  augustss 		req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
    474  1.41.2.1   nathanw 		(void)usbd_do_request(sc->sc_udev, &req, 0); /* 1.1 */
    475      1.41  augustss 	}
    476       1.1  augustss }
    477       1.1  augustss 
    478  1.41.2.1   nathanw static void
    479  1.41.2.1   nathanw ulpt_input(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
    480  1.41.2.1   nathanw {
    481  1.41.2.1   nathanw 	struct ulpt_softc *sc = priv;
    482  1.41.2.1   nathanw 
    483  1.41.2.1   nathanw 	DPRINTFN(2,("ulpt_input: got some data\n"));
    484  1.41.2.1   nathanw 	/* Do it again. */
    485  1.41.2.1   nathanw 	if (xfer == sc->sc_in_xfer1)
    486  1.41.2.1   nathanw 		usbd_transfer(sc->sc_in_xfer2);
    487  1.41.2.1   nathanw 	else
    488  1.41.2.1   nathanw 		usbd_transfer(sc->sc_in_xfer1);
    489  1.41.2.1   nathanw }
    490  1.41.2.1   nathanw 
    491  1.41.2.1   nathanw int ulptusein = 1;
    492  1.41.2.1   nathanw 
    493       1.1  augustss /*
    494       1.1  augustss  * Reset the printer, then wait until it's selected and not busy.
    495       1.1  augustss  */
    496       1.1  augustss int
    497  1.41.2.4   nathanw ulptopen(dev_t dev, int flag, int mode, usb_proc_ptr p)
    498       1.1  augustss {
    499       1.1  augustss 	u_char flags = ULPTFLAGS(dev);
    500      1.26  augustss 	struct ulpt_softc *sc;
    501      1.28  augustss 	usbd_status err;
    502       1.1  augustss 	int spin, error;
    503      1.26  augustss 
    504       1.8  augustss 	USB_GET_SC_OPEN(ulpt, ULPTUNIT(dev), sc);
    505       1.1  augustss 
    506      1.30  augustss 	if (sc == NULL || sc->sc_iface == NULL || sc->sc_dying)
    507      1.13  augustss 		return (ENXIO);
    508       1.1  augustss 
    509       1.1  augustss 	if (sc->sc_state)
    510      1.13  augustss 		return (EBUSY);
    511       1.1  augustss 
    512       1.1  augustss 	sc->sc_state = ULPT_INIT;
    513       1.1  augustss 	sc->sc_flags = flags;
    514       1.1  augustss 	DPRINTF(("ulptopen: flags=0x%x\n", (unsigned)flags));
    515       1.1  augustss 
    516      1.27  augustss #if defined(ULPT_DEBUG) && defined(__FreeBSD__)
    517      1.27  augustss 	/* Ignoring these flags might not be a good idea */
    518      1.27  augustss 	if ((flags & ~ULPT_NOPRIME) != 0)
    519      1.27  augustss 		printf("ulptopen: flags ignored: %b\n", flags,
    520      1.27  augustss 			"\20\3POS_INIT\4POS_ACK\6PRIME_OPEN\7AUTOLF\10BYPASS");
    521      1.27  augustss #endif
    522      1.27  augustss 
    523      1.27  augustss 
    524      1.39  augustss 	error = 0;
    525      1.39  augustss 	sc->sc_refcnt++;
    526      1.39  augustss 
    527       1.1  augustss 	if ((flags & ULPT_NOPRIME) == 0)
    528       1.1  augustss 		ulpt_reset(sc);
    529       1.1  augustss 
    530       1.1  augustss 	for (spin = 0; (ulpt_status(sc) & LPS_SELECT) == 0; spin += STEP) {
    531  1.41.2.1   nathanw 		DPRINTF(("ulpt_open: waiting a while\n"));
    532       1.1  augustss 		if (spin >= TIMEOUT) {
    533      1.39  augustss 			error = EBUSY;
    534       1.1  augustss 			sc->sc_state = 0;
    535      1.39  augustss 			goto done;
    536       1.1  augustss 		}
    537       1.1  augustss 
    538       1.1  augustss 		/* wait 1/4 second, give up if we get a signal */
    539       1.1  augustss 		error = tsleep((caddr_t)sc, LPTPRI | PCATCH, "ulptop", STEP);
    540       1.1  augustss 		if (error != EWOULDBLOCK) {
    541       1.1  augustss 			sc->sc_state = 0;
    542      1.39  augustss 			goto done;
    543      1.39  augustss 		}
    544      1.39  augustss 
    545      1.39  augustss 		if (sc->sc_dying) {
    546      1.39  augustss 			error = ENXIO;
    547      1.39  augustss 			sc->sc_state = 0;
    548      1.39  augustss 			goto done;
    549       1.1  augustss 		}
    550       1.1  augustss 	}
    551       1.1  augustss 
    552  1.41.2.1   nathanw 	err = usbd_open_pipe(sc->sc_iface, sc->sc_out, 0, &sc->sc_out_pipe);
    553      1.28  augustss 	if (err) {
    554       1.1  augustss 		sc->sc_state = 0;
    555      1.39  augustss 		error = EIO;
    556      1.39  augustss 		goto done;
    557       1.1  augustss 	}
    558  1.41.2.1   nathanw 	if (ulptusein && sc->sc_in != -1) {
    559  1.41.2.1   nathanw 		DPRINTF(("ulpt_open: open input pipe\n"));
    560  1.41.2.1   nathanw 		err = usbd_open_pipe(sc->sc_iface, sc->sc_in,0,&sc->sc_in_pipe);
    561  1.41.2.1   nathanw 		if (err) {
    562  1.41.2.1   nathanw 			error = EIO;
    563  1.41.2.1   nathanw 			usbd_close_pipe(sc->sc_out_pipe);
    564  1.41.2.1   nathanw 			sc->sc_out_pipe = NULL;
    565  1.41.2.1   nathanw 			sc->sc_state = 0;
    566  1.41.2.1   nathanw 			goto done;
    567  1.41.2.1   nathanw 		}
    568  1.41.2.1   nathanw 		sc->sc_in_xfer1 = usbd_alloc_xfer(sc->sc_udev);
    569  1.41.2.1   nathanw 		sc->sc_in_xfer2 = usbd_alloc_xfer(sc->sc_udev);
    570  1.41.2.1   nathanw 		if (sc->sc_in_xfer1 == NULL || sc->sc_in_xfer2 == NULL) {
    571  1.41.2.1   nathanw 			error = ENOMEM;
    572  1.41.2.4   nathanw 			if (sc->sc_in_xfer1 != NULL) {
    573  1.41.2.4   nathanw 				usbd_free_xfer(sc->sc_in_xfer1);
    574  1.41.2.4   nathanw 				sc->sc_in_xfer1 = NULL;
    575  1.41.2.4   nathanw 			}
    576  1.41.2.4   nathanw 			if (sc->sc_in_xfer2 != NULL) {
    577  1.41.2.4   nathanw 				usbd_free_xfer(sc->sc_in_xfer2);
    578  1.41.2.4   nathanw 				sc->sc_in_xfer2 = NULL;
    579  1.41.2.4   nathanw 			}
    580  1.41.2.1   nathanw 			usbd_close_pipe(sc->sc_out_pipe);
    581  1.41.2.1   nathanw 			sc->sc_out_pipe = NULL;
    582  1.41.2.4   nathanw 			usbd_close_pipe(sc->sc_in_pipe);
    583  1.41.2.4   nathanw 			sc->sc_in_pipe = NULL;
    584  1.41.2.1   nathanw 			sc->sc_state = 0;
    585  1.41.2.1   nathanw 			goto done;
    586  1.41.2.1   nathanw 		}
    587  1.41.2.1   nathanw 		usbd_setup_xfer(sc->sc_in_xfer1, sc->sc_in_pipe, sc,
    588  1.41.2.1   nathanw 		    sc->sc_junk, sizeof sc->sc_junk, USBD_SHORT_XFER_OK,
    589  1.41.2.1   nathanw 		    USBD_NO_TIMEOUT, ulpt_input);
    590  1.41.2.1   nathanw 		usbd_setup_xfer(sc->sc_in_xfer2, sc->sc_in_pipe, sc,
    591  1.41.2.1   nathanw 		    sc->sc_junk, sizeof sc->sc_junk, USBD_SHORT_XFER_OK,
    592  1.41.2.1   nathanw 		    USBD_NO_TIMEOUT, ulpt_input);
    593  1.41.2.1   nathanw 		usbd_transfer(sc->sc_in_xfer1); /* ignore failed start */
    594  1.41.2.1   nathanw 	}
    595       1.1  augustss 
    596       1.1  augustss 	sc->sc_state = ULPT_OPEN;
    597       1.1  augustss 
    598      1.39  augustss  done:
    599      1.39  augustss 	if (--sc->sc_refcnt < 0)
    600      1.39  augustss 		usb_detach_wakeup(USBDEV(sc->sc_dev));
    601      1.39  augustss 
    602      1.39  augustss 	DPRINTF(("ulptopen: done, error=%d\n", error));
    603      1.39  augustss 	return (error);
    604       1.1  augustss }
    605       1.1  augustss 
    606       1.1  augustss int
    607      1.38  augustss ulpt_statusmsg(u_char status, struct ulpt_softc *sc)
    608       1.1  augustss {
    609       1.1  augustss 	u_char new;
    610       1.1  augustss 
    611       1.1  augustss 	status = (status ^ LPS_INVERT) & LPS_MASK;
    612       1.1  augustss 	new = status & ~sc->sc_laststatus;
    613       1.1  augustss 	sc->sc_laststatus = status;
    614       1.1  augustss 
    615       1.1  augustss 	if (new & LPS_SELECT)
    616       1.8  augustss 		log(LOG_NOTICE, "%s: offline\n", USBDEVNAME(sc->sc_dev));
    617       1.1  augustss 	else if (new & LPS_NOPAPER)
    618       1.8  augustss 		log(LOG_NOTICE, "%s: out of paper\n", USBDEVNAME(sc->sc_dev));
    619       1.1  augustss 	else if (new & LPS_NERR)
    620       1.8  augustss 		log(LOG_NOTICE, "%s: output error\n", USBDEVNAME(sc->sc_dev));
    621       1.1  augustss 
    622      1.13  augustss 	return (status);
    623       1.1  augustss }
    624       1.1  augustss 
    625       1.1  augustss int
    626  1.41.2.4   nathanw ulptclose(dev_t dev, int flag, int mode, usb_proc_ptr p)
    627       1.1  augustss {
    628      1.26  augustss 	struct ulpt_softc *sc;
    629      1.26  augustss 
    630       1.8  augustss 	USB_GET_SC(ulpt, ULPTUNIT(dev), sc);
    631      1.13  augustss 
    632      1.13  augustss 	if (sc->sc_state != ULPT_OPEN)
    633      1.13  augustss 		/* We are being forced to close before the open completed. */
    634      1.13  augustss 		return (0);
    635       1.1  augustss 
    636  1.41.2.1   nathanw 	if (sc->sc_out_pipe != NULL) {
    637  1.41.2.1   nathanw 		usbd_close_pipe(sc->sc_out_pipe);
    638  1.41.2.1   nathanw 		sc->sc_out_pipe = NULL;
    639  1.41.2.1   nathanw 	}
    640  1.41.2.1   nathanw 	if (sc->sc_in_pipe != NULL) {
    641  1.41.2.1   nathanw 		usbd_abort_pipe(sc->sc_in_pipe);
    642  1.41.2.1   nathanw 		usbd_close_pipe(sc->sc_in_pipe);
    643  1.41.2.1   nathanw 		sc->sc_in_pipe = NULL;
    644  1.41.2.1   nathanw 		if (sc->sc_in_xfer1 != NULL) {
    645  1.41.2.1   nathanw 			usbd_free_xfer(sc->sc_in_xfer1);
    646  1.41.2.1   nathanw 			sc->sc_in_xfer1 = NULL;
    647  1.41.2.1   nathanw 		}
    648  1.41.2.1   nathanw 		if (sc->sc_in_xfer2 != NULL) {
    649  1.41.2.1   nathanw 			usbd_free_xfer(sc->sc_in_xfer2);
    650  1.41.2.1   nathanw 			sc->sc_in_xfer2 = NULL;
    651  1.41.2.1   nathanw 		}
    652  1.41.2.1   nathanw 	}
    653       1.1  augustss 
    654       1.1  augustss 	sc->sc_state = 0;
    655       1.1  augustss 
    656       1.1  augustss 	DPRINTF(("ulptclose: closed\n"));
    657       1.1  augustss 	return (0);
    658       1.1  augustss }
    659       1.1  augustss 
    660       1.1  augustss int
    661      1.38  augustss ulpt_do_write(struct ulpt_softc *sc, struct uio *uio, int flags)
    662       1.1  augustss {
    663      1.15  augustss 	u_int32_t n;
    664       1.1  augustss 	int error = 0;
    665      1.23  augustss 	void *bufp;
    666      1.28  augustss 	usbd_xfer_handle xfer;
    667      1.28  augustss 	usbd_status err;
    668       1.1  augustss 
    669       1.1  augustss 	DPRINTF(("ulptwrite\n"));
    670      1.29  augustss 	xfer = usbd_alloc_xfer(sc->sc_udev);
    671      1.28  augustss 	if (xfer == NULL)
    672       1.6  augustss 		return (ENOMEM);
    673      1.28  augustss 	bufp = usbd_alloc_buffer(xfer, ULPT_BSIZE);
    674      1.28  augustss 	if (bufp == NULL) {
    675      1.29  augustss 		usbd_free_xfer(xfer);
    676      1.23  augustss 		return (ENOMEM);
    677      1.23  augustss 	}
    678       1.1  augustss 	while ((n = min(ULPT_BSIZE, uio->uio_resid)) != 0) {
    679       1.1  augustss 		ulpt_statusmsg(ulpt_status(sc), sc);
    680      1.23  augustss 		error = uiomove(bufp, n, uio);
    681       1.6  augustss 		if (error)
    682       1.6  augustss 			break;
    683       1.1  augustss 		DPRINTFN(1, ("ulptwrite: transfer %d bytes\n", n));
    684  1.41.2.6   nathanw 		err = usbd_bulk_transfer(xfer, sc->sc_out_pipe, USBD_NO_COPY,
    685      1.28  augustss 			  USBD_NO_TIMEOUT, bufp, &n, "ulptwr");
    686      1.28  augustss 		if (err) {
    687      1.28  augustss 			DPRINTF(("ulptwrite: error=%d\n", err));
    688       1.1  augustss 			error = EIO;
    689       1.1  augustss 			break;
    690       1.1  augustss 		}
    691       1.1  augustss 	}
    692      1.29  augustss 	usbd_free_xfer(xfer);
    693      1.12  augustss 
    694      1.12  augustss 	return (error);
    695      1.12  augustss }
    696      1.12  augustss 
    697      1.12  augustss int
    698      1.38  augustss ulptwrite(dev_t dev, struct uio *uio, int flags)
    699      1.12  augustss {
    700      1.26  augustss 	struct ulpt_softc *sc;
    701      1.26  augustss 	int error;
    702      1.26  augustss 
    703      1.12  augustss 	USB_GET_SC(ulpt, ULPTUNIT(dev), sc);
    704      1.21  augustss 
    705      1.21  augustss 	if (sc->sc_dying)
    706      1.21  augustss 		return (EIO);
    707      1.12  augustss 
    708      1.12  augustss 	sc->sc_refcnt++;
    709      1.12  augustss 	error = ulpt_do_write(sc, uio, flags);
    710      1.12  augustss 	if (--sc->sc_refcnt < 0)
    711      1.20  augustss 		usb_detach_wakeup(USBDEV(sc->sc_dev));
    712       1.1  augustss 	return (error);
    713       1.1  augustss }
    714       1.1  augustss 
    715       1.1  augustss int
    716  1.41.2.4   nathanw ulptioctl(dev_t dev, u_long cmd, caddr_t data, int flag, usb_proc_ptr p)
    717       1.1  augustss {
    718       1.1  augustss 	int error = 0;
    719       1.1  augustss 
    720       1.1  augustss 	switch (cmd) {
    721       1.1  augustss 	default:
    722       1.1  augustss 		error = ENODEV;
    723       1.1  augustss 	}
    724       1.1  augustss 
    725      1.17  augustss 	return (error);
    726      1.16  augustss }
    727      1.16  augustss 
    728      1.22  augustss #if 0
    729      1.16  augustss /* XXX This does not belong here. */
    730      1.16  augustss /*
    731      1.17  augustss  * Print select parts of a IEEE 1284 device ID.
    732      1.16  augustss  */
    733      1.16  augustss void
    734      1.38  augustss ieee1284_print_id(char *str)
    735      1.16  augustss {
    736      1.16  augustss 	char *p, *q;
    737      1.16  augustss 
    738      1.16  augustss 	for (p = str-1; p; p = strchr(p, ';')) {
    739      1.16  augustss 		p++;		/* skip ';' */
    740      1.16  augustss 		if (strncmp(p, "MFG:", 4) == 0 ||
    741      1.16  augustss 		    strncmp(p, "MANUFACTURER:", 14) == 0 ||
    742      1.16  augustss 		    strncmp(p, "MDL:", 4) == 0 ||
    743      1.16  augustss 		    strncmp(p, "MODEL:", 6) == 0) {
    744      1.16  augustss 			q = strchr(p, ';');
    745      1.16  augustss 			if (q)
    746      1.16  augustss 				printf("%.*s", (int)(q - p + 1), p);
    747      1.16  augustss 		}
    748      1.16  augustss 	}
    749       1.1  augustss }
    750      1.22  augustss #endif
    751       1.8  augustss 
    752       1.8  augustss #if defined(__FreeBSD__)
    753      1.30  augustss DRIVER_MODULE(ulpt, uhub, ulpt_driver, ulpt_devclass, usbd_driver_load, 0);
    754       1.8  augustss #endif
    755