1 /* $NetBSD: ulpt.c,v 1.60 2003/10/04 21:19:50 augustss Exp $ */
4 * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net) at
9 * Carlstedt Research & Technology.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
40 #include <sys/cdefs.h>
41 __FBSDID("$FreeBSD$");
44 * Printer Class spec: http://www.usb.org/developers/data/devclass/usbprint109.PDF
47 /* XXXimp: need to migrate from devclass_get_softc */
49 #include <sys/param.h>
50 #include <sys/systm.h>
52 #include <sys/kernel.h>
53 #include <sys/fcntl.h>
54 #include <sys/ioccom.h>
55 #include <sys/module.h>
59 #include <sys/syslog.h>
60 #include <sys/sysctl.h>
62 #include <dev/usb/usb.h>
63 #include <dev/usb/usbdi.h>
64 #include <dev/usb/usbdi_util.h>
66 #include <dev/usb/usb_quirks.h>
68 #define TIMEOUT hz*16 /* wait up to 16 seconds for a ready */
71 #define LPTPRI (PZERO+8)
72 #define ULPT_BSIZE PAGE_SIZE
74 #define ULPT_READS_PER_SEC 5
75 #define ULPT_READ_TIMO 10
78 #define DPRINTF(x) if (ulptdebug) printf x
79 #define DPRINTFN(n,x) if (ulptdebug>(n)) printf x
81 SYSCTL_NODE(_hw_usb, OID_AUTO, ulpt, CTLFLAG_RW, 0, "USB ulpt");
82 SYSCTL_INT(_hw_usb_ulpt, OID_AUTO, debug, CTLFLAG_RW,
83 &ulptdebug, 0, "ulpt debug level");
89 #define UR_GET_DEVICE_ID 0
90 #define UR_GET_PORT_STATUS 1
91 #define UR_SOFT_RESET 2
93 #define LPS_NERR 0x08 /* printer no error */
94 #define LPS_SELECT 0x10 /* printer selected */
95 #define LPS_NOPAPER 0x20 /* printer out of paper */
96 #define LPS_INVERT (LPS_SELECT|LPS_NERR)
97 #define LPS_MASK (LPS_SELECT|LPS_NERR|LPS_NOPAPER)
101 usbd_device_handle sc_udev; /* device */
102 usbd_interface_handle sc_iface; /* interface */
106 usbd_pipe_handle sc_out_pipe; /* bulk out pipe */
107 usbd_xfer_handle sc_out_xfer;
111 usbd_pipe_handle sc_in_pipe; /* bulk in pipe */
112 usbd_xfer_handle sc_in_xfer;
115 struct callout sc_read_callout;
119 #define ULPT_OPEN 0x01 /* device is open */
120 #define ULPT_OBUSY 0x02 /* printer is busy doing output */
121 #define ULPT_INIT 0x04 /* waiting to initialize for open */
123 #define ULPT_NOPRIME 0x40 /* don't prime on open */
124 u_char sc_laststatus;
130 struct cdev *dev_noprime;
133 static d_open_t ulptopen;
134 static d_close_t ulptclose;
135 static d_write_t ulptwrite;
136 static d_read_t ulptread;
137 static d_ioctl_t ulptioctl;
140 static struct cdevsw ulpt_cdevsw = {
141 .d_version = D_VERSION,
142 .d_flags = D_NEEDGIANT,
144 .d_close = ulptclose,
145 .d_write = ulptwrite,
147 .d_ioctl = ulptioctl,
151 void ulpt_disco(void *);
153 int ulpt_do_write(struct ulpt_softc *, struct uio *uio, int);
154 int ulpt_do_read(struct ulpt_softc *, struct uio *uio, int);
155 int ulpt_status(struct ulpt_softc *);
156 void ulpt_reset(struct ulpt_softc *);
157 int ulpt_statusmsg(u_char, struct ulpt_softc *);
158 void ulpt_read_cb(usbd_xfer_handle xfer, usbd_private_handle priv,
160 void ulpt_tick(void *xsc);
163 void ieee1284_print_id(char *);
166 #define ULPTUNIT(s) (minor(s) & 0x1f)
167 #define ULPTFLAGS(s) (minor(s) & 0xe0)
169 static device_probe_t ulpt_match;
170 static device_attach_t ulpt_attach;
171 static device_detach_t ulpt_detach;
173 static device_method_t ulpt_methods[] = {
174 /* Device interface */
175 DEVMETHOD(device_probe, ulpt_match),
176 DEVMETHOD(device_attach, ulpt_attach),
177 DEVMETHOD(device_detach, ulpt_detach),
182 static driver_t ulpt_driver = {
185 sizeof(struct ulpt_softc)
188 static devclass_t ulpt_devclass;
190 MODULE_DEPEND(umass, usb, 1, 1, 1);
191 DRIVER_MODULE(ulpt, uhub, ulpt_driver, ulpt_devclass, usbd_driver_load, 0);
194 ulpt_match(device_t self)
196 struct usb_attach_arg *uaa = device_get_ivars(self);
197 usb_interface_descriptor_t *id;
199 DPRINTFN(10,("ulpt_match\n"));
200 if (uaa->iface == NULL)
201 return (UMATCH_NONE);
202 id = usbd_get_interface_descriptor(uaa->iface);
204 id->bInterfaceClass == UICLASS_PRINTER &&
205 id->bInterfaceSubClass == UISUBCLASS_PRINTER &&
206 (id->bInterfaceProtocol == UIPROTO_PRINTER_UNI ||
207 id->bInterfaceProtocol == UIPROTO_PRINTER_BI ||
208 id->bInterfaceProtocol == UIPROTO_PRINTER_1284))
209 return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO);
210 return (UMATCH_NONE);
214 ulpt_attach(device_t self)
216 struct ulpt_softc *sc = device_get_softc(self);
217 struct usb_attach_arg *uaa = device_get_ivars(self);
218 usbd_device_handle dev = uaa->device;
219 usbd_interface_handle iface = uaa->iface;
220 usb_interface_descriptor_t *ifcd = usbd_get_interface_descriptor(iface);
221 usb_interface_descriptor_t *id, *iend;
222 usb_config_descriptor_t *cdesc;
224 usb_endpoint_descriptor_t *ed;
228 DPRINTFN(10,("ulpt_attach: sc=%p\n", sc));
232 * Stepping through the alternate settings needs to be abstracted out.
234 cdesc = usbd_get_config_descriptor(dev);
236 printf("%s: failed to get configuration descriptor\n",
237 device_get_nameunit(sc->sc_dev));
240 iend = (usb_interface_descriptor_t *)
241 ((char *)cdesc + UGETW(cdesc->wTotalLength));
243 if (ifcd < (usb_interface_descriptor_t *)cdesc ||
245 panic("ulpt: iface desc out of range");
247 /* Step through all the descriptors looking for bidir mode */
248 for (id = ifcd, altno = 0;
250 id = (void *)((char *)id + id->bLength)) {
251 if (id->bDescriptorType == UDESC_INTERFACE &&
252 id->bInterfaceNumber == ifcd->bInterfaceNumber) {
253 if (id->bInterfaceClass == UICLASS_PRINTER &&
254 id->bInterfaceSubClass == UISUBCLASS_PRINTER &&
255 (id->bInterfaceProtocol == UIPROTO_PRINTER_BI /* ||
256 id->bInterfaceProtocol == UIPROTO_PRINTER_1284 */))
261 id = ifcd; /* not found, use original */
264 /* Found a new bidir setting */
265 DPRINTF(("ulpt_attach: set altno = %d\n", altno));
266 err = usbd_set_interface(iface, altno);
268 printf("%s: setting alternate interface failed\n",
269 device_get_nameunit(sc->sc_dev));
276 (void)usbd_endpoint_count(iface, &epcount);
280 for (i = 0; i < epcount; i++) {
281 ed = usbd_interface2endpoint_descriptor(iface, i);
283 printf("%s: couldn't get ep %d\n",
284 device_get_nameunit(sc->sc_dev), i);
287 if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
288 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
289 sc->sc_in = ed->bEndpointAddress;
290 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
291 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
292 sc->sc_out = ed->bEndpointAddress;
295 if (sc->sc_out == -1) {
296 printf("%s: could not find bulk out endpoint\n",
297 device_get_nameunit(sc->sc_dev));
302 if (usbd_get_quirks(dev)->uq_flags & UQ_BROKEN_BIDIR) {
303 /* This device doesn't handle reading properly. */
307 printf("%s: using %s-directional mode\n", device_get_nameunit(sc->sc_dev),
308 sc->sc_in >= 0 ? "bi" : "uni");
310 DPRINTFN(10, ("ulpt_attach: bulk=%d\n", sc->sc_out));
312 sc->sc_iface = iface;
313 sc->sc_ifaceno = id->bInterfaceNumber;
318 * This code is disabled because for some mysterious reason it causes
319 * printing not to work. But only sometimes, and mostly with
320 * UHCI and less often with OHCI. *sigh*
323 usb_config_descriptor_t *cd = usbd_get_config_descriptor(dev);
324 usb_device_request_t req;
327 req.bmRequestType = UT_READ_CLASS_INTERFACE;
328 req.bRequest = UR_GET_DEVICE_ID;
329 USETW(req.wValue, cd->bConfigurationValue);
330 USETW2(req.wIndex, id->bInterfaceNumber, id->bAlternateSetting);
331 USETW(req.wLength, sizeof devinfo - 1);
332 err = usbd_do_request_flags(dev, &req, devinfo, USBD_SHORT_XFER_OK,
333 &alen, USBD_DEFAULT_TIMEOUT);
335 printf("%s: cannot get device id\n", device_get_nameunit(sc->sc_dev));
336 } else if (alen <= 2) {
337 printf("%s: empty device id, no printer connected?\n",
338 device_get_nameunit(sc->sc_dev));
340 /* devinfo now contains an IEEE-1284 device ID */
341 len = ((devinfo[0] & 0xff) << 8) | (devinfo[1] & 0xff);
342 if (len > sizeof devinfo - 3)
343 len = sizeof devinfo - 3;
345 printf("%s: device id <", device_get_nameunit(sc->sc_dev));
346 ieee1284_print_id(devinfo+2);
352 sc->dev = make_dev(&ulpt_cdevsw, device_get_unit(self),
353 UID_ROOT, GID_OPERATOR, 0644, "ulpt%d", device_get_unit(self));
354 sc->dev_noprime = make_dev(&ulpt_cdevsw,
355 device_get_unit(self)|ULPT_NOPRIME,
356 UID_ROOT, GID_OPERATOR, 0644, "unlpt%d", device_get_unit(self));
358 usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev);
365 ulpt_detach(device_t self)
367 struct ulpt_softc *sc = device_get_softc(self);
370 DPRINTF(("ulpt_detach: sc=%p\n", sc));
373 if (sc->sc_out_pipe != NULL)
374 usbd_abort_pipe(sc->sc_out_pipe);
375 if (sc->sc_in_pipe != NULL)
376 usbd_abort_pipe(sc->sc_in_pipe);
379 if (--sc->sc_refcnt >= 0) {
380 /* There is noone to wake, aborting the pipe is enough */
381 /* Wait for processes to go away. */
382 usb_detach_wait(sc->sc_dev);
386 destroy_dev(sc->dev);
387 destroy_dev(sc->dev_noprime);
389 usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev);
395 ulpt_status(struct ulpt_softc *sc)
397 usb_device_request_t req;
401 req.bmRequestType = UT_READ_CLASS_INTERFACE;
402 req.bRequest = UR_GET_PORT_STATUS;
403 USETW(req.wValue, 0);
404 USETW(req.wIndex, sc->sc_ifaceno);
405 USETW(req.wLength, 1);
406 err = usbd_do_request(sc->sc_udev, &req, &status);
407 DPRINTFN(1, ("ulpt_status: status=0x%02x err=%d\n", status, err));
415 ulpt_reset(struct ulpt_softc *sc)
417 usb_device_request_t req;
419 DPRINTFN(1, ("ulpt_reset\n"));
420 req.bRequest = UR_SOFT_RESET;
421 USETW(req.wValue, 0);
422 USETW(req.wIndex, sc->sc_ifaceno);
423 USETW(req.wLength, 0);
426 * There was a mistake in the USB printer 1.0 spec that gave the
427 * request type as UT_WRITE_CLASS_OTHER; it should have been
428 * UT_WRITE_CLASS_INTERFACE. Many printers use the old one,
431 req.bmRequestType = UT_WRITE_CLASS_OTHER;
432 if (usbd_do_request(sc->sc_udev, &req, 0)) { /* 1.0 */
433 req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
434 (void)usbd_do_request(sc->sc_udev, &req, 0); /* 1.1 */
439 ulpt_input(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
441 struct ulpt_softc *sc = priv;
444 /* Don't loop on errors or 0-length input. */
445 usbd_get_xfer_status(xfer, NULL, NULL, &count, NULL);
446 if (status != USBD_NORMAL_COMPLETION || count == 0)
449 DPRINTFN(2,("ulpt_input: got some data\n"));
451 if (xfer == sc->sc_in_xfer1)
452 usbd_transfer(sc->sc_in_xfer2);
454 usbd_transfer(sc->sc_in_xfer1);
461 * Reset the printer, then wait until it's selected and not busy.
464 ulptopen(struct cdev *dev, int flag, int mode, struct thread *p)
466 u_char flags = ULPTFLAGS(dev);
467 struct ulpt_softc *sc;
471 sc = devclass_get_softc(ulpt_devclass, ULPTUNIT(dev));
475 if (sc == NULL || sc->sc_iface == NULL || sc->sc_dying)
481 sc->sc_state = ULPT_INIT;
482 sc->sc_flags = flags;
483 DPRINTF(("ulptopen: flags=0x%x\n", (unsigned)flags));
485 #if defined(USB_DEBUG)
486 /* Ignoring these flags might not be a good idea */
487 if ((flags & ~ULPT_NOPRIME) != 0)
488 printf("ulptopen: flags ignored: %b\n", flags,
489 "\20\3POS_INIT\4POS_ACK\6PRIME_OPEN\7AUTOLF\10BYPASS");
496 if ((flags & ULPT_NOPRIME) == 0) {
505 err = usbd_open_pipe(sc->sc_iface, sc->sc_out, 0, &sc->sc_out_pipe);
510 sc->sc_out_xfer = usbd_alloc_xfer(sc->sc_udev);
511 if (sc->sc_out_xfer == NULL) {
515 sc->sc_out_buf = usbd_alloc_buffer(sc->sc_out_xfer, ULPT_BSIZE);
516 if (sc->sc_out_buf == NULL) {
521 if (ulptusein && sc->sc_in != -1) {
522 DPRINTF(("ulpt_open: open input pipe\n"));
523 err = usbd_open_pipe(sc->sc_iface, sc->sc_in,0,&sc->sc_in_pipe);
528 sc->sc_in_xfer = usbd_alloc_xfer(sc->sc_udev);
529 if (sc->sc_in_xfer == NULL) {
533 sc->sc_in_buf = usbd_alloc_buffer(sc->sc_in_xfer, ULPT_BSIZE);
534 if (sc->sc_in_buf == NULL) {
539 /* If it's not opened for read the set up a reader. */
540 if (!(flag & FREAD)) {
541 DPRINTF(("ulpt_open: start read callout\n"));
542 callout_init(&sc->sc_read_callout, 0);
543 callout_reset(&sc->sc_read_callout, hz/5, ulpt_tick,
545 sc->sc_has_callout = 1;
549 sc->sc_state = ULPT_OPEN;
553 usbd_free_xfer(sc->sc_in_xfer);
554 sc->sc_in_xfer = NULL;
556 usbd_close_pipe(sc->sc_in_pipe);
557 sc->sc_in_pipe = NULL;
559 usbd_free_xfer(sc->sc_out_xfer);
560 sc->sc_out_xfer = NULL;
562 usbd_close_pipe(sc->sc_out_pipe);
563 sc->sc_out_pipe = NULL;
568 if (--sc->sc_refcnt < 0)
569 usb_detach_wakeup(sc->sc_dev);
571 DPRINTF(("ulptopen: done, error=%d\n", error));
576 ulpt_statusmsg(u_char status, struct ulpt_softc *sc)
580 status = (status ^ LPS_INVERT) & LPS_MASK;
581 new = status & ~sc->sc_laststatus;
582 sc->sc_laststatus = status;
584 if (new & LPS_SELECT)
585 log(LOG_NOTICE, "%s: offline\n", device_get_nameunit(sc->sc_dev));
586 else if (new & LPS_NOPAPER)
587 log(LOG_NOTICE, "%s: out of paper\n", device_get_nameunit(sc->sc_dev));
588 else if (new & LPS_NERR)
589 log(LOG_NOTICE, "%s: output error\n", device_get_nameunit(sc->sc_dev));
595 ulptclose(struct cdev *dev, int flag, int mode, struct thread *p)
597 struct ulpt_softc *sc;
599 sc = devclass_get_softc(ulpt_devclass, ULPTUNIT(dev));
601 if (sc->sc_state != ULPT_OPEN)
602 /* We are being forced to close before the open completed. */
605 if (sc->sc_has_callout) {
606 callout_stop(&sc->sc_read_callout);
607 sc->sc_has_callout = 0;
610 if (sc->sc_out_pipe != NULL) {
611 usbd_abort_pipe(sc->sc_out_pipe);
612 usbd_close_pipe(sc->sc_out_pipe);
613 sc->sc_out_pipe = NULL;
615 if (sc->sc_out_xfer != NULL) {
616 usbd_free_xfer(sc->sc_out_xfer);
617 sc->sc_out_xfer = NULL;
620 if (sc->sc_in_pipe != NULL) {
621 usbd_abort_pipe(sc->sc_in_pipe);
622 usbd_close_pipe(sc->sc_in_pipe);
623 sc->sc_in_pipe = NULL;
625 if (sc->sc_in_xfer != NULL) {
626 usbd_free_xfer(sc->sc_in_xfer);
627 sc->sc_in_xfer = NULL;
632 DPRINTF(("ulptclose: closed\n"));
637 ulpt_do_write(struct ulpt_softc *sc, struct uio *uio, int flags)
642 usbd_xfer_handle xfer;
645 DPRINTF(("ulptwrite\n"));
646 xfer = sc->sc_out_xfer;
647 bufp = sc->sc_out_buf;
648 while ((n = min(ULPT_BSIZE, uio->uio_resid)) != 0) {
649 ulpt_statusmsg(ulpt_status(sc), sc);
650 error = uiomove(bufp, n, uio);
653 DPRINTFN(1, ("ulptwrite: transfer %d bytes\n", n));
654 err = usbd_bulk_transfer(xfer, sc->sc_out_pipe, USBD_NO_COPY,
655 USBD_NO_TIMEOUT, bufp, &n, "ulptwr");
657 DPRINTF(("ulptwrite: error=%d\n", err));
667 ulptwrite(struct cdev *dev, struct uio *uio, int flags)
669 struct ulpt_softc *sc;
672 sc = devclass_get_softc(ulpt_devclass, ULPTUNIT(dev));
678 error = ulpt_do_write(sc, uio, flags);
679 if (--sc->sc_refcnt < 0)
680 usb_detach_wakeup(sc->sc_dev);
685 ulpt_do_read(struct ulpt_softc *sc, struct uio *uio, int flags)
690 usbd_xfer_handle xfer;
693 DPRINTF(("ulptread\n"));
695 if (sc->sc_in_pipe == NULL)
698 xfer = sc->sc_in_xfer;
699 bufp = sc->sc_in_buf;
700 while ((n = min(ULPT_BSIZE, uio->uio_resid)) != 0) {
701 DPRINTFN(1, ("ulptread: transfer %d bytes\n", n));
703 err = usbd_bulk_transfer(xfer, sc->sc_in_pipe,
704 USBD_NO_COPY | USBD_SHORT_XFER_OK,
705 USBD_NO_TIMEOUT, bufp, &n, "ulptrd");
707 DPRINTF(("ulptread: error=%d\n", err));
711 error = uiomove(bufp, n, uio);
722 ulptread(struct cdev *dev, struct uio *uio, int flags)
724 struct ulpt_softc *sc;
727 sc = devclass_get_softc(ulpt_devclass, ULPTUNIT(dev));
733 error = ulpt_do_read(sc, uio, flags);
734 if (--sc->sc_refcnt < 0)
735 usb_detach_wakeup(sc->sc_dev);
740 ulpt_read_cb(usbd_xfer_handle xfer, usbd_private_handle priv,
745 usbd_private_handle xsc;
746 struct ulpt_softc *sc;
748 usbd_get_xfer_status(xfer, &xsc, NULL, &n, &err);
751 DPRINTFN(1,("ulpt_read_cb: start sc=%p, err=%d n=%d\n", sc, err, n));
755 DPRINTF(("ulpt_tick: discarding %d bytes\n", n));
757 if (!err || err == USBD_TIMEOUT)
758 callout_reset(&sc->sc_read_callout, hz / ULPT_READS_PER_SEC,
765 struct ulpt_softc *sc = xsc;
768 if (sc == NULL || sc->sc_dying)
771 DPRINTFN(1,("ulpt_tick: start sc=%p\n", sc));
773 usbd_setup_xfer(sc->sc_in_xfer, sc->sc_in_pipe, sc, sc->sc_in_buf,
774 ULPT_BSIZE, USBD_NO_COPY | USBD_SHORT_XFER_OK,
775 ULPT_READ_TIMO, ulpt_read_cb);
776 err = usbd_transfer(sc->sc_in_xfer);
777 DPRINTFN(1,("ulpt_tick: err=%d\n", err));
781 ulptioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *p)
794 /* XXX This does not belong here. */
796 * Print select parts of an IEEE 1284 device ID.
799 ieee1284_print_id(char *str)
803 for (p = str-1; p; p = strchr(p, ';')) {
805 if (strncmp(p, "MFG:", 4) == 0 ||
806 strncmp(p, "MANUFACTURER:", 14) == 0 ||
807 strncmp(p, "MDL:", 4) == 0 ||
808 strncmp(p, "MODEL:", 6) == 0) {
811 printf("%.*s", (int)(q - p + 1), p);