Home | History | Annotate | Line # | Download | only in usb
ubsa.c revision 1.12.2.2
      1  1.12.2.2      yamt /*	$NetBSD: ubsa.c,v 1.12.2.2 2007/02/26 09:10:44 yamt Exp $	*/
      2       1.1  augustss /*-
      3       1.1  augustss  * Copyright (c) 2002, Alexander Kabaev <kan.FreeBSD.org>.
      4       1.1  augustss  * All rights reserved.
      5       1.1  augustss  *
      6       1.1  augustss  * Redistribution and use in source and binary forms, with or without
      7       1.1  augustss  * modification, are permitted provided that the following conditions
      8       1.1  augustss  * are met:
      9       1.1  augustss  * 1. Redistributions of source code must retain the above copyright
     10       1.1  augustss  *    notice, this list of conditions and the following disclaimer.
     11       1.1  augustss  * 2. Redistributions in binary form must reproduce the above copyright
     12       1.1  augustss  *    notice, this list of conditions and the following disclaimer in the
     13       1.1  augustss  *    documentation and/or other materials provided with the distribution.
     14       1.1  augustss  *
     15       1.1  augustss  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     16       1.1  augustss  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     17       1.1  augustss  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     18       1.1  augustss  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19       1.1  augustss  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20       1.1  augustss  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     21       1.1  augustss  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22       1.1  augustss  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23       1.1  augustss  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24       1.1  augustss  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25       1.1  augustss  * SUCH DAMAGE.
     26       1.1  augustss  */
     27       1.1  augustss /*
     28       1.1  augustss  * Copyright (c) 2001 The NetBSD Foundation, Inc.
     29       1.1  augustss  * All rights reserved.
     30       1.1  augustss  *
     31       1.1  augustss  * This code is derived from software contributed to The NetBSD Foundation
     32       1.1  augustss  * by Ichiro FUKUHARA (ichiro (at) ichiro.org).
     33       1.1  augustss  *
     34       1.1  augustss  * Redistribution and use in source and binary forms, with or without
     35       1.1  augustss  * modification, are permitted provided that the following conditions
     36       1.1  augustss  * are met:
     37       1.1  augustss  * 1. Redistributions of source code must retain the above copyright
     38       1.1  augustss  *    notice, this list of conditions and the following disclaimer.
     39       1.1  augustss  * 2. Redistributions in binary form must reproduce the above copyright
     40       1.1  augustss  *    notice, this list of conditions and the following disclaimer in the
     41       1.1  augustss  *    documentation and/or other materials provided with the distribution.
     42       1.1  augustss  * 3. All advertising materials mentioning features or use of this software
     43       1.1  augustss  *    must display the following acknowledgement:
     44       1.1  augustss  *        This product includes software developed by the NetBSD
     45       1.1  augustss  *        Foundation, Inc. and its contributors.
     46       1.1  augustss  * 4. Neither the name of The NetBSD Foundation nor the names of its
     47       1.1  augustss  *    contributors may be used to endorse or promote products derived
     48       1.1  augustss  *    from this software without specific prior written permission.
     49       1.1  augustss  *
     50       1.1  augustss  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     51       1.1  augustss  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     52       1.1  augustss  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     53       1.1  augustss  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     54       1.1  augustss  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     55       1.1  augustss  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     56       1.1  augustss  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     57       1.1  augustss  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     58       1.1  augustss  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     59       1.1  augustss  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     60       1.1  augustss  * POSSIBILITY OF SUCH DAMAGE.
     61       1.1  augustss  */
     62       1.1  augustss 
     63       1.1  augustss #include <sys/cdefs.h>
     64  1.12.2.2      yamt __KERNEL_RCSID(0, "$NetBSD: ubsa.c,v 1.12.2.2 2007/02/26 09:10:44 yamt Exp $");
     65       1.1  augustss 
     66       1.1  augustss #include <sys/param.h>
     67       1.1  augustss #include <sys/systm.h>
     68       1.1  augustss #include <sys/kernel.h>
     69       1.1  augustss #include <sys/malloc.h>
     70       1.1  augustss #ifdef __FreeBSD__
     71       1.1  augustss #include <sys/bus.h>
     72       1.1  augustss #endif
     73       1.1  augustss #include <sys/ioccom.h>
     74       1.1  augustss #include <sys/fcntl.h>
     75       1.1  augustss #include <sys/conf.h>
     76       1.1  augustss #include <sys/tty.h>
     77       1.1  augustss #include <sys/file.h>
     78       1.1  augustss #if __FreeBSD_version >= 500014
     79       1.1  augustss #include <sys/selinfo.h>
     80       1.1  augustss #else
     81       1.1  augustss #include <sys/select.h>
     82       1.1  augustss #endif
     83       1.1  augustss #include <sys/proc.h>
     84       1.4      fvdl #include <sys/device.h>
     85       1.1  augustss #include <sys/poll.h>
     86       1.1  augustss #include <sys/sysctl.h>
     87       1.1  augustss 
     88       1.1  augustss #include <dev/usb/usb.h>
     89       1.1  augustss #include <dev/usb/usbcdc.h>
     90       1.1  augustss 
     91       1.1  augustss #include <dev/usb/usbdi.h>
     92       1.1  augustss #include <dev/usb/usbdi_util.h>
     93       1.1  augustss #include <dev/usb/usbdevs.h>
     94       1.1  augustss #include <dev/usb/usb_quirks.h>
     95       1.1  augustss 
     96       1.1  augustss #include <dev/usb/ucomvar.h>
     97       1.1  augustss 
     98       1.1  augustss #ifdef UBSA_DEBUG
     99       1.1  augustss Static int	ubsadebug = 0;
    100       1.1  augustss #ifdef __FreeBSD__
    101       1.1  augustss SYSCTL_NODE(_hw_usb, OID_AUTO, ubsa, CTLFLAG_RW, 0, "USB ubsa");
    102       1.1  augustss SYSCTL_INT(_hw_usb_ubsa, OID_AUTO, debug, CTLFLAG_RW,
    103       1.1  augustss 	   &ubsadebug, 0, "ubsa debug level");
    104       1.1  augustss #endif
    105       1.1  augustss 
    106       1.1  augustss #define	DPRINTFN(n, x)	do { \
    107       1.1  augustss 				if (ubsadebug > (n)) \
    108       1.1  augustss 					logprintf x; \
    109       1.1  augustss 			} while (0)
    110       1.1  augustss #else
    111       1.1  augustss #define	DPRINTFN(n, x)
    112       1.1  augustss #endif
    113       1.1  augustss #define	DPRINTF(x) DPRINTFN(0, x)
    114       1.1  augustss 
    115       1.1  augustss #define	UBSA_MODVER		1	/* module version */
    116       1.1  augustss 
    117       1.1  augustss #define	UBSA_CONFIG_INDEX	1
    118       1.1  augustss #define	UBSA_IFACE_INDEX	0
    119       1.1  augustss 
    120       1.1  augustss #define	UBSA_INTR_INTERVAL	100	/* ms */
    121       1.1  augustss 
    122       1.1  augustss #define	UBSA_SET_BAUDRATE  	0x00
    123       1.1  augustss #define	UBSA_SET_STOP_BITS	0x01
    124       1.1  augustss #define	UBSA_SET_DATA_BITS	0x02
    125       1.1  augustss #define	UBSA_SET_PARITY		0x03
    126       1.1  augustss #define	UBSA_SET_DTR		0x0A
    127       1.1  augustss #define	UBSA_SET_RTS		0x0B
    128       1.1  augustss #define	UBSA_SET_BREAK		0x0C
    129       1.1  augustss #define	UBSA_SET_FLOW_CTRL	0x10
    130       1.1  augustss 
    131  1.12.2.2      yamt #define UBSA_QUADUMTS_SET_PIN   0x22
    132  1.12.2.2      yamt 
    133       1.1  augustss #define	UBSA_PARITY_NONE	0x00
    134       1.1  augustss #define	UBSA_PARITY_EVEN	0x01
    135       1.1  augustss #define	UBSA_PARITY_ODD		0x02
    136       1.1  augustss #define	UBSA_PARITY_MARK	0x03
    137       1.1  augustss #define	UBSA_PARITY_SPACE	0x04
    138       1.1  augustss 
    139       1.1  augustss #define	UBSA_FLOW_NONE		0x0000
    140       1.1  augustss #define	UBSA_FLOW_OCTS		0x0001
    141       1.1  augustss #define	UBSA_FLOW_ODSR		0x0002
    142       1.1  augustss #define	UBSA_FLOW_IDSR		0x0004
    143       1.1  augustss #define	UBSA_FLOW_IDTR		0x0008
    144       1.1  augustss #define	UBSA_FLOW_IRTS		0x0010
    145       1.1  augustss #define	UBSA_FLOW_ORTS		0x0020
    146       1.1  augustss #define	UBSA_FLOW_UNKNOWN	0x0040
    147       1.1  augustss #define	UBSA_FLOW_OXON		0x0080
    148       1.1  augustss #define	UBSA_FLOW_IXON		0x0100
    149       1.1  augustss 
    150       1.1  augustss /* line status register */
    151       1.1  augustss #define	UBSA_LSR_TSRE		0x40	/* Transmitter empty: byte sent */
    152       1.1  augustss #define	UBSA_LSR_TXRDY		0x20	/* Transmitter buffer empty */
    153       1.1  augustss #define	UBSA_LSR_BI		0x10	/* Break detected */
    154       1.1  augustss #define	UBSA_LSR_FE		0x08	/* Framing error: bad stop bit */
    155       1.1  augustss #define	UBSA_LSR_PE		0x04	/* Parity error */
    156       1.1  augustss #define	UBSA_LSR_OE		0x02	/* Overrun, lost incoming byte */
    157       1.1  augustss #define	UBSA_LSR_RXRDY		0x01	/* Byte ready in Receive Buffer */
    158       1.1  augustss #define	UBSA_LSR_RCV_MASK	0x1f	/* Mask for incoming data or error */
    159       1.1  augustss 
    160       1.1  augustss /* modem status register */
    161       1.1  augustss /* All deltas are from the last read of the MSR. */
    162       1.1  augustss #define	UBSA_MSR_DCD		0x80	/* Current Data Carrier Detect */
    163       1.1  augustss #define	UBSA_MSR_RI		0x40	/* Current Ring Indicator */
    164       1.1  augustss #define	UBSA_MSR_DSR		0x20	/* Current Data Set Ready */
    165       1.1  augustss #define	UBSA_MSR_CTS		0x10	/* Current Clear to Send */
    166       1.1  augustss #define	UBSA_MSR_DDCD		0x08	/* DCD has changed state */
    167       1.1  augustss #define	UBSA_MSR_TERI		0x04	/* RI has toggled low to high */
    168       1.1  augustss #define	UBSA_MSR_DDSR		0x02	/* DSR has changed state */
    169       1.1  augustss #define	UBSA_MSR_DCTS		0x01	/* CTS has changed state */
    170       1.1  augustss 
    171       1.1  augustss struct	ubsa_softc {
    172       1.1  augustss 	USBBASEDEVICE		sc_dev;		/* base device */
    173       1.1  augustss 	usbd_device_handle	sc_udev;	/* USB device */
    174       1.1  augustss 	usbd_interface_handle	sc_iface;	/* interface */
    175       1.1  augustss 
    176       1.1  augustss 	int			sc_iface_number;	/* interface number */
    177       1.1  augustss 
    178       1.1  augustss 	int			sc_intr_number;	/* interrupt number */
    179       1.1  augustss 	usbd_pipe_handle	sc_intr_pipe;	/* interrupt pipe */
    180       1.1  augustss 	u_char			*sc_intr_buf;	/* interrupt buffer */
    181       1.1  augustss 	int			sc_isize;
    182       1.1  augustss 
    183       1.1  augustss 	u_char			sc_dtr;		/* current DTR state */
    184       1.1  augustss 	u_char			sc_rts;		/* current RTS state */
    185       1.1  augustss 
    186       1.1  augustss 	u_char			sc_lsr;		/* Local status register */
    187       1.1  augustss 	u_char			sc_msr;		/* ubsa status register */
    188       1.3  augustss 
    189       1.1  augustss 	device_ptr_t		sc_subdev;	/* ucom device */
    190       1.1  augustss 
    191       1.1  augustss 	u_char			sc_dying;	/* disconnecting */
    192  1.12.2.2      yamt 	u_char			sc_quadumts;
    193       1.1  augustss 
    194       1.1  augustss };
    195       1.1  augustss 
    196       1.1  augustss Static	void ubsa_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
    197       1.1  augustss 
    198       1.1  augustss Static	void ubsa_get_status(void *, int, u_char *, u_char *);
    199       1.1  augustss Static	void ubsa_set(void *, int, int, int);
    200       1.1  augustss Static	int  ubsa_param(void *, int, struct termios *);
    201       1.1  augustss Static	int  ubsa_open(void *, int);
    202       1.1  augustss Static	void ubsa_close(void *, int);
    203       1.1  augustss 
    204       1.1  augustss Static  void ubsa_break(struct ubsa_softc *sc, int onoff);
    205       1.1  augustss Static	int  ubsa_request(struct ubsa_softc *, u_int8_t, u_int16_t);
    206       1.1  augustss Static	void ubsa_dtr(struct ubsa_softc *, int);
    207  1.12.2.2      yamt Static	void ubsa_quadumts_dtr(struct ubsa_softc *, int);
    208       1.1  augustss Static	void ubsa_rts(struct ubsa_softc *, int);
    209  1.12.2.2      yamt Static	void ubsa_quadumts_rts(struct ubsa_softc *, int);
    210       1.1  augustss Static	void ubsa_baudrate(struct ubsa_softc *, speed_t);
    211       1.1  augustss Static	void ubsa_parity(struct ubsa_softc *, tcflag_t);
    212       1.1  augustss Static	void ubsa_databits(struct ubsa_softc *, tcflag_t);
    213       1.1  augustss Static	void ubsa_stopbits(struct ubsa_softc *, tcflag_t);
    214       1.1  augustss Static	void ubsa_flow(struct ubsa_softc *, tcflag_t, tcflag_t);
    215       1.1  augustss 
    216       1.1  augustss struct	ucom_methods ubsa_methods = {
    217       1.1  augustss 	ubsa_get_status,
    218       1.1  augustss 	ubsa_set,
    219       1.1  augustss 	ubsa_param,
    220       1.1  augustss 	NULL,
    221       1.1  augustss 	ubsa_open,
    222       1.1  augustss 	ubsa_close,
    223       1.1  augustss 	NULL,
    224       1.1  augustss 	NULL
    225       1.1  augustss };
    226       1.1  augustss 
    227       1.1  augustss Static const struct usb_devno ubsa_devs[] = {
    228       1.1  augustss 	/* BELKIN F5U103 */
    229       1.1  augustss 	{ USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F5U103 },
    230       1.1  augustss 	/* BELKIN F5U120 */
    231       1.1  augustss 	{ USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F5U120 },
    232       1.1  augustss 	/* GoHubs GO-COM232 */
    233       1.1  augustss 	{ USB_VENDOR_ETEK, USB_PRODUCT_ETEK_1COM },
    234       1.1  augustss 	/* GoHubs GO-COM232 */
    235       1.1  augustss 	{ USB_VENDOR_GOHUBS, USB_PRODUCT_GOHUBS_GOCOM232 },
    236       1.1  augustss 	/* Peracom */
    237       1.1  augustss 	{ USB_VENDOR_PERACOM, USB_PRODUCT_PERACOM_SERIAL1 },
    238  1.12.2.2      yamt 	/* Option N.V. */
    239  1.12.2.2      yamt 	{ USB_VENDOR_OPTIONNV, USB_PRODUCT_OPTIONNV_MC3G },
    240  1.12.2.2      yamt 	{ USB_VENDOR_OPTIONNV, USB_PRODUCT_OPTIONNV_QUADUMTS2 },
    241  1.12.2.2      yamt 	{ USB_VENDOR_OPTIONNV, USB_PRODUCT_OPTIONNV_QUADUMTS },
    242  1.12.2.2      yamt 	/* AnyDATA ADU-E100H */
    243  1.12.2.2      yamt 	{ USB_VENDOR_ANYDATA, USB_PRODUCT_ANYDATA_ADU_E100H },
    244       1.1  augustss };
    245       1.1  augustss #define ubsa_lookup(v, p) usb_lookup(ubsa_devs, v, p)
    246       1.1  augustss 
    247       1.1  augustss USB_DECLARE_DRIVER(ubsa);
    248       1.1  augustss 
    249       1.1  augustss USB_MATCH(ubsa)
    250       1.1  augustss {
    251       1.1  augustss 	USB_MATCH_START(ubsa, uaa);
    252       1.1  augustss 
    253       1.1  augustss 	if (uaa->iface != NULL)
    254       1.1  augustss 		return (UMATCH_NONE);
    255       1.1  augustss 
    256       1.1  augustss 	return (ubsa_lookup(uaa->vendor, uaa->product) != NULL ?
    257       1.1  augustss 		UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
    258       1.1  augustss }
    259       1.1  augustss 
    260       1.1  augustss USB_ATTACH(ubsa)
    261       1.1  augustss {
    262       1.1  augustss 	USB_ATTACH_START(ubsa, sc, uaa);
    263       1.1  augustss 	usbd_device_handle dev = uaa->device;
    264       1.1  augustss 	usb_config_descriptor_t *cdesc;
    265       1.1  augustss 	usb_interface_descriptor_t *id;
    266       1.1  augustss 	usb_endpoint_descriptor_t *ed;
    267      1.12  augustss 	char *devinfop;
    268       1.1  augustss 	const char *devname = USBDEVNAME(sc->sc_dev);
    269       1.1  augustss 	usbd_status err;
    270       1.1  augustss 	struct ucom_attach_args uca;
    271       1.1  augustss 	int i;
    272       1.1  augustss 
    273      1.12  augustss 	devinfop = usbd_devinfo_alloc(dev, 0);
    274      1.12  augustss 	USB_ATTACH_SETUP;
    275      1.12  augustss 	printf("%s: %s\n", devname, devinfop);
    276      1.12  augustss 	usbd_devinfo_free(devinfop);
    277       1.1  augustss 
    278       1.1  augustss         sc->sc_udev = dev;
    279       1.1  augustss 
    280       1.1  augustss 	/*
    281       1.1  augustss 	 * initialize rts, dtr variables to something
    282       1.3  augustss 	 * different from boolean 0, 1
    283       1.1  augustss 	 */
    284       1.1  augustss 	sc->sc_dtr = -1;
    285       1.1  augustss 	sc->sc_rts = -1;
    286       1.1  augustss 
    287  1.12.2.2      yamt 	/*
    288  1.12.2.2      yamt 	 * Quad UMTS cards use different requests to
    289  1.12.2.2      yamt 	 * control com settings and only some.
    290  1.12.2.2      yamt 	 */
    291  1.12.2.2      yamt 	sc->sc_quadumts = 0;
    292  1.12.2.2      yamt 	if (uaa->vendor == USB_VENDOR_OPTIONNV) {
    293  1.12.2.2      yamt 		switch (uaa->product) {
    294  1.12.2.2      yamt 		case USB_PRODUCT_OPTIONNV_QUADUMTS:
    295  1.12.2.2      yamt 		case USB_PRODUCT_OPTIONNV_QUADUMTS2:
    296  1.12.2.2      yamt 			sc->sc_quadumts = 1;
    297  1.12.2.2      yamt 			break;
    298  1.12.2.2      yamt 		}
    299  1.12.2.2      yamt 	}
    300  1.12.2.2      yamt 
    301       1.1  augustss 	DPRINTF(("ubsa attach: sc = %p\n", sc));
    302       1.1  augustss 
    303       1.3  augustss 	/* initialize endpoints */
    304       1.1  augustss 	uca.bulkin = uca.bulkout = -1;
    305       1.1  augustss 	sc->sc_intr_number = -1;
    306       1.1  augustss 	sc->sc_intr_pipe = NULL;
    307       1.1  augustss 
    308       1.1  augustss 	/* Move the device into the configured state. */
    309       1.1  augustss 	err = usbd_set_config_index(dev, UBSA_CONFIG_INDEX, 1);
    310       1.1  augustss 	if (err) {
    311       1.1  augustss 		printf("%s: failed to set configuration: %s\n",
    312       1.1  augustss 		    devname, usbd_errstr(err));
    313       1.1  augustss 		sc->sc_dying = 1;
    314       1.1  augustss 		goto error;
    315       1.1  augustss 	}
    316       1.1  augustss 
    317       1.1  augustss 	/* get the config descriptor */
    318       1.1  augustss 	cdesc = usbd_get_config_descriptor(sc->sc_udev);
    319       1.1  augustss 
    320       1.1  augustss 	if (cdesc == NULL) {
    321       1.1  augustss 		printf("%s: failed to get configuration descriptor\n",
    322       1.1  augustss 		    devname);
    323       1.1  augustss 		sc->sc_dying = 1;
    324       1.1  augustss 		goto error;
    325       1.1  augustss 	}
    326       1.1  augustss 
    327       1.1  augustss 	/* get the first interface */
    328       1.1  augustss 	err = usbd_device2interface_handle(dev, UBSA_IFACE_INDEX,
    329       1.1  augustss 	    &sc->sc_iface);
    330       1.1  augustss 	if (err) {
    331       1.1  augustss 		printf("%s: failed to get interface: %s\n",
    332       1.1  augustss 			devname, usbd_errstr(err));
    333       1.1  augustss 		sc->sc_dying = 1;
    334       1.1  augustss 		goto error;
    335       1.1  augustss 	}
    336       1.1  augustss 
    337       1.1  augustss 	/* Find the endpoints */
    338       1.1  augustss 
    339       1.1  augustss 	id = usbd_get_interface_descriptor(sc->sc_iface);
    340       1.1  augustss 	sc->sc_iface_number = id->bInterfaceNumber;
    341       1.1  augustss 
    342       1.1  augustss 	for (i = 0; i < id->bNumEndpoints; i++) {
    343       1.1  augustss 		ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i);
    344       1.1  augustss 		if (ed == NULL) {
    345       1.1  augustss 			printf("%s: no endpoint descriptor for %d\n",
    346       1.1  augustss 			    USBDEVNAME(sc->sc_dev), i);
    347       1.1  augustss 			sc->sc_dying = 1;
    348       1.1  augustss 			goto error;
    349       1.1  augustss 		}
    350       1.1  augustss 
    351       1.1  augustss 		if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
    352       1.1  augustss 		    UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
    353       1.1  augustss 			sc->sc_intr_number = ed->bEndpointAddress;
    354       1.1  augustss 			sc->sc_isize = UGETW(ed->wMaxPacketSize);
    355       1.1  augustss 		} else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
    356       1.1  augustss 		    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
    357       1.1  augustss 			uca.bulkin = ed->bEndpointAddress;
    358       1.1  augustss 			uca.ibufsize = UGETW(ed->wMaxPacketSize);
    359       1.1  augustss 		} else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
    360       1.1  augustss 		    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
    361       1.1  augustss 			uca.bulkout = ed->bEndpointAddress;
    362       1.1  augustss 			uca.obufsize = UGETW(ed->wMaxPacketSize);
    363       1.1  augustss 		}
    364       1.1  augustss 	}
    365       1.1  augustss 
    366       1.1  augustss 	if (sc->sc_intr_number == -1) {
    367       1.1  augustss 		printf("%s: Could not find interrupt in\n", devname);
    368       1.1  augustss 		sc->sc_dying = 1;
    369       1.1  augustss 		goto error;
    370       1.1  augustss 	}
    371       1.1  augustss 
    372       1.1  augustss 	if (uca.bulkin == -1) {
    373       1.1  augustss 		printf("%s: Could not find data bulk in\n", devname);
    374       1.1  augustss 		sc->sc_dying = 1;
    375       1.1  augustss 		goto error;
    376       1.1  augustss 	}
    377       1.1  augustss 
    378       1.1  augustss 	if (uca.bulkout == -1) {
    379       1.1  augustss 		printf("%s: Could not find data bulk out\n", devname);
    380       1.1  augustss 		sc->sc_dying = 1;
    381       1.1  augustss 		goto error;
    382       1.1  augustss 	}
    383       1.1  augustss 
    384       1.1  augustss 	uca.portno = UCOM_UNK_PORTNO;
    385       1.1  augustss 	/* bulkin, bulkout set above */
    386       1.1  augustss 	uca.ibufsizepad = uca.ibufsize;
    387       1.1  augustss 	uca.opkthdrlen = 0;
    388       1.1  augustss 	uca.device = dev;
    389       1.1  augustss 	uca.iface = sc->sc_iface;
    390       1.1  augustss 	uca.methods = &ubsa_methods;
    391       1.1  augustss 	uca.arg = sc;
    392       1.1  augustss 	uca.info = NULL;
    393       1.1  augustss 
    394       1.1  augustss 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
    395       1.1  augustss 			   USBDEV(sc->sc_dev));
    396       1.1  augustss 
    397       1.1  augustss 	DPRINTF(("ubsa: in = 0x%x, out = 0x%x, intr = 0x%x\n",
    398  1.12.2.1      yamt 	    uca.bulkin, uca.bulkout, sc->sc_intr_number));
    399       1.1  augustss 
    400      1.10  drochner 	sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, &uca,
    401      1.10  drochner 					    ucomprint, ucomsubmatch);
    402       1.1  augustss 
    403       1.1  augustss 	USB_ATTACH_SUCCESS_RETURN;
    404       1.1  augustss 
    405       1.1  augustss error:
    406       1.1  augustss 	USB_ATTACH_ERROR_RETURN;
    407       1.1  augustss }
    408       1.1  augustss 
    409       1.1  augustss USB_DETACH(ubsa)
    410       1.1  augustss {
    411       1.1  augustss 	USB_DETACH_START(ubsa, sc);
    412       1.5      fvdl 	int rv = 0;
    413       1.1  augustss 
    414       1.1  augustss 
    415       1.1  augustss 	DPRINTF(("ubsa_detach: sc = %p\n", sc));
    416       1.1  augustss 
    417       1.1  augustss 	if (sc->sc_intr_pipe != NULL) {
    418       1.1  augustss 		usbd_abort_pipe(sc->sc_intr_pipe);
    419       1.1  augustss 		usbd_close_pipe(sc->sc_intr_pipe);
    420       1.1  augustss 		free(sc->sc_intr_buf, M_USBDEV);
    421       1.1  augustss 		sc->sc_intr_pipe = NULL;
    422       1.1  augustss 	}
    423       1.1  augustss 
    424       1.1  augustss 	sc->sc_dying = 1;
    425       1.1  augustss 	if (sc->sc_subdev != NULL) {
    426       1.1  augustss 		rv = config_detach(sc->sc_subdev, flags);
    427       1.1  augustss 		sc->sc_subdev = NULL;
    428       1.1  augustss 	}
    429       1.1  augustss 
    430       1.1  augustss 	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
    431       1.1  augustss 			   USBDEV(sc->sc_dev));
    432       1.1  augustss 
    433       1.1  augustss 	return (rv);
    434       1.1  augustss }
    435       1.1  augustss 
    436       1.2     pooka int
    437       1.1  augustss ubsa_activate(device_ptr_t self, enum devact act)
    438       1.1  augustss {
    439       1.1  augustss 	struct ubsa_softc *sc = (struct ubsa_softc *)self;
    440       1.1  augustss 	int rv = 0;
    441       1.1  augustss 
    442       1.1  augustss 	switch (act) {
    443       1.1  augustss 	case DVACT_ACTIVATE:
    444       1.1  augustss 		return (EOPNOTSUPP);
    445       1.1  augustss 
    446       1.1  augustss 	case DVACT_DEACTIVATE:
    447       1.1  augustss 		if (sc->sc_subdev != NULL)
    448       1.1  augustss 			rv = config_deactivate(sc->sc_subdev);
    449       1.1  augustss 		sc->sc_dying = 1;
    450       1.1  augustss 		break;
    451       1.1  augustss 	}
    452       1.1  augustss 	return (rv);
    453       1.1  augustss }
    454       1.1  augustss 
    455       1.1  augustss Static int
    456       1.1  augustss ubsa_request(struct ubsa_softc *sc, u_int8_t request, u_int16_t value)
    457       1.1  augustss {
    458       1.1  augustss 	usb_device_request_t req;
    459       1.1  augustss 	usbd_status err;
    460       1.1  augustss 
    461  1.12.2.2      yamt 	if (sc->sc_quadumts)
    462  1.12.2.2      yamt 		req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
    463  1.12.2.2      yamt 	else
    464  1.12.2.2      yamt 		req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
    465  1.12.2.2      yamt 
    466       1.1  augustss 	req.bRequest = request;
    467       1.1  augustss 	USETW(req.wValue, value);
    468       1.1  augustss 	USETW(req.wIndex, sc->sc_iface_number);
    469       1.1  augustss 	USETW(req.wLength, 0);
    470       1.1  augustss 
    471       1.1  augustss 	err = usbd_do_request(sc->sc_udev, &req, 0);
    472       1.1  augustss 	if (err)
    473       1.1  augustss 		printf("%s: ubsa_request: %s\n",
    474       1.1  augustss 		    USBDEVNAME(sc->sc_dev), usbd_errstr(err));
    475       1.1  augustss 	return (err);
    476       1.1  augustss }
    477       1.1  augustss 
    478       1.1  augustss Static void
    479       1.1  augustss ubsa_dtr(struct ubsa_softc *sc, int onoff)
    480       1.1  augustss {
    481       1.1  augustss 
    482       1.1  augustss 	DPRINTF(("ubsa_dtr: onoff = %d\n", onoff));
    483       1.1  augustss 
    484       1.1  augustss 	if (sc->sc_dtr == onoff)
    485       1.1  augustss 		return;
    486       1.1  augustss 	sc->sc_dtr = onoff;
    487       1.1  augustss 
    488       1.1  augustss 	ubsa_request(sc, UBSA_SET_DTR, onoff ? 1 : 0);
    489       1.1  augustss }
    490       1.1  augustss 
    491       1.1  augustss Static void
    492       1.1  augustss ubsa_rts(struct ubsa_softc *sc, int onoff)
    493       1.1  augustss {
    494       1.1  augustss 
    495       1.1  augustss 	DPRINTF(("ubsa_rts: onoff = %d\n", onoff));
    496       1.1  augustss 
    497       1.1  augustss 	if (sc->sc_rts == onoff)
    498       1.1  augustss 		return;
    499       1.1  augustss 	sc->sc_rts = onoff;
    500       1.1  augustss 
    501       1.1  augustss 	ubsa_request(sc, UBSA_SET_RTS, onoff ? 1 : 0);
    502       1.1  augustss }
    503       1.1  augustss 
    504       1.1  augustss Static void
    505  1.12.2.2      yamt ubsa_quadumts_dtr(struct ubsa_softc *sc, int onoff)
    506  1.12.2.2      yamt {
    507  1.12.2.2      yamt 
    508  1.12.2.2      yamt 	DPRINTF(("ubsa_dtr: onoff = %d\n", onoff));
    509  1.12.2.2      yamt 
    510  1.12.2.2      yamt 	if (sc->sc_dtr == onoff)
    511  1.12.2.2      yamt 		return;
    512  1.12.2.2      yamt 	sc->sc_dtr = onoff;
    513  1.12.2.2      yamt 
    514  1.12.2.2      yamt 	ubsa_request(sc, UBSA_QUADUMTS_SET_PIN, (sc->sc_rts ? 2 : 0)+(sc->sc_dtr ? 1 : 0));
    515  1.12.2.2      yamt }
    516  1.12.2.2      yamt 
    517  1.12.2.2      yamt Static void
    518  1.12.2.2      yamt ubsa_quadumts_rts(struct ubsa_softc *sc, int onoff)
    519       1.1  augustss {
    520       1.1  augustss 
    521       1.1  augustss 	DPRINTF(("ubsa_rts: onoff = %d\n", onoff));
    522       1.1  augustss 
    523  1.12.2.2      yamt 	if (sc->sc_rts == onoff)
    524  1.12.2.2      yamt 		return;
    525  1.12.2.2      yamt 	sc->sc_rts = onoff;
    526  1.12.2.2      yamt 
    527  1.12.2.2      yamt 	ubsa_request(sc, UBSA_QUADUMTS_SET_PIN, (sc->sc_rts ? 2 : 0)+(sc->sc_dtr ? 1 : 0));
    528  1.12.2.2      yamt }
    529  1.12.2.2      yamt 
    530  1.12.2.2      yamt Static void
    531  1.12.2.2      yamt ubsa_break(struct ubsa_softc *sc, int onoff)
    532  1.12.2.2      yamt {
    533  1.12.2.2      yamt 	DPRINTF(("ubsa_rts: onoff = %d\n", onoff));
    534  1.12.2.2      yamt 
    535       1.1  augustss 	ubsa_request(sc, UBSA_SET_BREAK, onoff ? 1 : 0);
    536       1.1  augustss }
    537       1.1  augustss 
    538       1.1  augustss Static void
    539       1.1  augustss ubsa_set(void *addr, int portno, int reg, int onoff)
    540       1.1  augustss {
    541       1.1  augustss 	struct ubsa_softc *sc;
    542       1.1  augustss 
    543       1.1  augustss 	sc = addr;
    544       1.1  augustss 	switch (reg) {
    545       1.1  augustss 	case UCOM_SET_DTR:
    546  1.12.2.2      yamt 		if (sc->sc_quadumts)
    547  1.12.2.2      yamt 			ubsa_quadumts_dtr(sc, onoff);
    548  1.12.2.2      yamt 		else
    549  1.12.2.2      yamt 			ubsa_dtr(sc, onoff);
    550       1.1  augustss 		break;
    551       1.1  augustss 	case UCOM_SET_RTS:
    552  1.12.2.2      yamt 		if (sc->sc_quadumts)
    553  1.12.2.2      yamt 			ubsa_quadumts_rts(sc, onoff);
    554  1.12.2.2      yamt 		else
    555  1.12.2.2      yamt 			ubsa_rts(sc, onoff);
    556       1.1  augustss 		break;
    557       1.1  augustss 	case UCOM_SET_BREAK:
    558  1.12.2.2      yamt 		if (!sc->sc_quadumts)
    559  1.12.2.2      yamt 			ubsa_break(sc, onoff);
    560       1.1  augustss 		break;
    561       1.1  augustss 	default:
    562       1.1  augustss 		break;
    563       1.1  augustss 	}
    564       1.1  augustss }
    565       1.1  augustss 
    566       1.1  augustss Static void
    567       1.1  augustss ubsa_baudrate(struct ubsa_softc *sc, speed_t speed)
    568       1.1  augustss {
    569       1.1  augustss 	u_int16_t value = 0;
    570       1.3  augustss 
    571       1.1  augustss 	DPRINTF(("ubsa_baudrate: speed = %d\n", speed));
    572       1.1  augustss 
    573       1.1  augustss 	switch(speed) {
    574       1.1  augustss 	case B0:
    575       1.1  augustss 		break;
    576       1.1  augustss 	case B300:
    577       1.1  augustss 	case B600:
    578       1.1  augustss 	case B1200:
    579       1.1  augustss 	case B2400:
    580       1.1  augustss 	case B4800:
    581       1.1  augustss 	case B9600:
    582       1.1  augustss 	case B19200:
    583       1.1  augustss 	case B38400:
    584       1.1  augustss 	case B57600:
    585       1.1  augustss 	case B115200:
    586       1.3  augustss 	case B230400:
    587       1.1  augustss 		value = B230400 / speed;
    588       1.1  augustss 		break;
    589       1.3  augustss 	default:
    590       1.1  augustss 		printf("%s: ubsa_param: unsupported baudrate, "
    591       1.1  augustss 		    "forcing default of 9600\n",
    592       1.1  augustss 		    USBDEVNAME(sc->sc_dev));
    593       1.1  augustss 		value = B230400 / B9600;
    594       1.1  augustss 		break;
    595       1.1  augustss 	};
    596       1.3  augustss 
    597       1.1  augustss 	if (speed == B0) {
    598       1.1  augustss 		ubsa_flow(sc, 0, 0);
    599       1.1  augustss 		ubsa_dtr(sc, 0);
    600       1.1  augustss 		ubsa_rts(sc, 0);
    601       1.1  augustss 	} else
    602       1.1  augustss 		ubsa_request(sc, UBSA_SET_BAUDRATE, value);
    603       1.1  augustss }
    604       1.1  augustss 
    605       1.1  augustss Static void
    606       1.1  augustss ubsa_parity(struct ubsa_softc *sc, tcflag_t cflag)
    607       1.1  augustss {
    608       1.1  augustss 	int value;
    609       1.1  augustss 
    610       1.1  augustss 	DPRINTF(("ubsa_parity: cflag = 0x%x\n", cflag));
    611       1.1  augustss 
    612       1.1  augustss 	if (cflag & PARENB)
    613       1.1  augustss 		value = (cflag & PARODD) ? UBSA_PARITY_ODD : UBSA_PARITY_EVEN;
    614       1.1  augustss 	else
    615       1.1  augustss 		value = UBSA_PARITY_NONE;
    616       1.1  augustss 
    617       1.1  augustss 	ubsa_request(sc, UBSA_SET_PARITY, value);
    618       1.1  augustss }
    619       1.1  augustss 
    620       1.1  augustss Static void
    621       1.1  augustss ubsa_databits(struct ubsa_softc *sc, tcflag_t cflag)
    622       1.1  augustss {
    623       1.1  augustss 	int value;
    624       1.1  augustss 
    625       1.1  augustss 	DPRINTF(("ubsa_databits: cflag = 0x%x\n", cflag));
    626       1.1  augustss 
    627       1.1  augustss 	switch (cflag & CSIZE) {
    628       1.1  augustss 	case CS5: value = 0; break;
    629       1.1  augustss 	case CS6: value = 1; break;
    630       1.1  augustss 	case CS7: value = 2; break;
    631       1.1  augustss 	case CS8: value = 3; break;
    632       1.3  augustss 	default:
    633       1.1  augustss 		printf("%s: ubsa_param: unsupported databits requested, "
    634       1.1  augustss 		    "forcing default of 8\n",
    635       1.1  augustss 		    USBDEVNAME(sc->sc_dev));
    636       1.1  augustss 		value = 3;
    637       1.1  augustss 	}
    638       1.1  augustss 
    639       1.1  augustss 	ubsa_request(sc, UBSA_SET_DATA_BITS, value);
    640       1.1  augustss }
    641       1.1  augustss 
    642       1.1  augustss Static void
    643       1.1  augustss ubsa_stopbits(struct ubsa_softc *sc, tcflag_t cflag)
    644       1.1  augustss {
    645       1.1  augustss 	int value;
    646       1.1  augustss 
    647       1.1  augustss 	DPRINTF(("ubsa_stopbits: cflag = 0x%x\n", cflag));
    648       1.1  augustss 
    649       1.1  augustss 	value = (cflag & CSTOPB) ? 1 : 0;
    650       1.1  augustss 
    651       1.1  augustss 	ubsa_request(sc, UBSA_SET_STOP_BITS, value);
    652       1.1  augustss }
    653       1.1  augustss 
    654       1.1  augustss Static void
    655       1.1  augustss ubsa_flow(struct ubsa_softc *sc, tcflag_t cflag, tcflag_t iflag)
    656       1.1  augustss {
    657       1.1  augustss 	int value;
    658       1.3  augustss 
    659       1.1  augustss 	DPRINTF(("ubsa_flow: cflag = 0x%x, iflag = 0x%x\n", cflag, iflag));
    660       1.1  augustss 
    661       1.1  augustss 	value = 0;
    662       1.1  augustss 	if (cflag & CRTSCTS)
    663       1.1  augustss 		value |= UBSA_FLOW_OCTS | UBSA_FLOW_IRTS;
    664       1.1  augustss 	if (iflag & (IXON|IXOFF))
    665       1.1  augustss 		value |= UBSA_FLOW_OXON | UBSA_FLOW_IXON;
    666       1.1  augustss 
    667       1.1  augustss 	ubsa_request(sc, UBSA_SET_FLOW_CTRL, value);
    668       1.1  augustss }
    669       1.1  augustss 
    670       1.1  augustss Static int
    671       1.1  augustss ubsa_param(void *addr, int portno, struct termios *ti)
    672       1.1  augustss {
    673       1.3  augustss 	struct ubsa_softc *sc = addr;
    674       1.1  augustss 
    675       1.1  augustss 	DPRINTF(("ubsa_param: sc = %p\n", sc));
    676       1.1  augustss 
    677  1.12.2.2      yamt 	if (!sc->sc_quadumts) {
    678  1.12.2.2      yamt 		ubsa_baudrate(sc, ti->c_ospeed);
    679  1.12.2.2      yamt 		ubsa_parity(sc, ti->c_cflag);
    680  1.12.2.2      yamt 		ubsa_databits(sc, ti->c_cflag);
    681  1.12.2.2      yamt 		ubsa_stopbits(sc, ti->c_cflag);
    682  1.12.2.2      yamt 		ubsa_flow(sc, ti->c_cflag, ti->c_iflag);
    683  1.12.2.2      yamt 	}
    684       1.1  augustss 
    685       1.1  augustss 	return (0);
    686       1.1  augustss }
    687       1.1  augustss 
    688       1.1  augustss Static int
    689       1.1  augustss ubsa_open(void *addr, int portno)
    690       1.1  augustss {
    691       1.3  augustss 	struct ubsa_softc *sc = addr;
    692       1.1  augustss 	int err;
    693       1.3  augustss 
    694       1.1  augustss 	if (sc->sc_dying)
    695       1.1  augustss 		return (ENXIO);
    696       1.1  augustss 
    697       1.1  augustss 	DPRINTF(("ubsa_open: sc = %p\n", sc));
    698       1.1  augustss 
    699       1.1  augustss 	if (sc->sc_intr_number != -1 && sc->sc_intr_pipe == NULL) {
    700       1.1  augustss 		sc->sc_intr_buf = malloc(sc->sc_isize, M_USBDEV, M_WAITOK);
    701      1.11  augustss 		err = usbd_open_pipe_intr(sc->sc_iface,
    702       1.1  augustss 		    sc->sc_intr_number,
    703       1.1  augustss 		    USBD_SHORT_XFER_OK,
    704       1.1  augustss 		    &sc->sc_intr_pipe,
    705       1.1  augustss 		    sc,
    706       1.1  augustss 		    sc->sc_intr_buf,
    707       1.1  augustss 		    sc->sc_isize,
    708       1.1  augustss 		    ubsa_intr,
    709       1.1  augustss 		    UBSA_INTR_INTERVAL);
    710       1.1  augustss 		if (err) {
    711       1.1  augustss 			printf("%s: cannot open interrupt pipe (addr %d)\n",
    712       1.1  augustss 			    USBDEVNAME(sc->sc_dev),
    713       1.1  augustss 			    sc->sc_intr_number);
    714       1.1  augustss 			return (EIO);
    715       1.1  augustss 		}
    716       1.1  augustss 	}
    717       1.1  augustss 
    718       1.1  augustss 	return (0);
    719       1.1  augustss }
    720       1.1  augustss 
    721       1.1  augustss Static void
    722       1.3  augustss ubsa_close(void *addr, int portno)
    723       1.1  augustss {
    724       1.3  augustss 	struct ubsa_softc *sc = addr;
    725       1.1  augustss 	int err;
    726       1.1  augustss 
    727       1.1  augustss 	if (sc->sc_dying)
    728       1.1  augustss 		return;
    729       1.1  augustss 
    730       1.1  augustss 	DPRINTF(("ubsa_close: close\n"));
    731       1.1  augustss 
    732       1.1  augustss 	if (sc->sc_intr_pipe != NULL) {
    733       1.1  augustss 		err = usbd_abort_pipe(sc->sc_intr_pipe);
    734       1.1  augustss 		if (err)
    735       1.1  augustss 			printf("%s: abort interrupt pipe failed: %s\n",
    736       1.1  augustss 			    USBDEVNAME(sc->sc_dev),
    737       1.1  augustss 			    usbd_errstr(err));
    738       1.1  augustss 		err = usbd_close_pipe(sc->sc_intr_pipe);
    739       1.1  augustss 		if (err)
    740       1.1  augustss 			printf("%s: close interrupt pipe failed: %s\n",
    741       1.1  augustss 			    USBDEVNAME(sc->sc_dev),
    742       1.1  augustss 			    usbd_errstr(err));
    743       1.1  augustss 		free(sc->sc_intr_buf, M_USBDEV);
    744       1.1  augustss 		sc->sc_intr_pipe = NULL;
    745       1.1  augustss 	}
    746       1.1  augustss }
    747       1.1  augustss 
    748       1.1  augustss Static void
    749  1.12.2.1      yamt ubsa_intr(usbd_xfer_handle xfer, usbd_private_handle priv,
    750  1.12.2.1      yamt     usbd_status status)
    751       1.1  augustss {
    752       1.3  augustss 	struct ubsa_softc *sc = priv;
    753       1.1  augustss 	u_char *buf;
    754       1.1  augustss 
    755       1.1  augustss 	buf = sc->sc_intr_buf;
    756       1.1  augustss 	if (sc->sc_dying)
    757       1.1  augustss 		return;
    758       1.1  augustss 
    759       1.1  augustss 	if (status != USBD_NORMAL_COMPLETION) {
    760       1.1  augustss 		if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
    761       1.1  augustss 			return;
    762       1.1  augustss 
    763       1.1  augustss 		DPRINTF(("%s: ubsa_intr: abnormal status: %s\n",
    764  1.12.2.1      yamt 		    USBDEVNAME(sc->sc_dev), usbd_errstr(status)));
    765       1.1  augustss 		usbd_clear_endpoint_stall_async(sc->sc_intr_pipe);
    766       1.1  augustss 		return;
    767       1.1  augustss 	}
    768       1.1  augustss 
    769       1.1  augustss 	/* incidentally, Belkin adapter status bits match UART 16550 bits */
    770       1.1  augustss 	sc->sc_lsr = buf[2];
    771       1.1  augustss 	sc->sc_msr = buf[3];
    772       1.1  augustss 
    773       1.1  augustss 	DPRINTF(("%s: ubsa lsr = 0x%02x, msr = 0x%02x\n",
    774  1.12.2.1      yamt 	    USBDEVNAME(sc->sc_dev), sc->sc_lsr, sc->sc_msr));
    775       1.1  augustss 
    776       1.1  augustss 	ucom_status_change((struct ucom_softc *)sc->sc_subdev);
    777       1.1  augustss }
    778       1.1  augustss 
    779       1.1  augustss Static void
    780       1.1  augustss ubsa_get_status(void *addr, int portno, u_char *lsr, u_char *msr)
    781       1.1  augustss {
    782       1.3  augustss 	struct ubsa_softc *sc = addr;
    783       1.1  augustss 
    784       1.1  augustss 	DPRINTF(("ubsa_get_status\n"));
    785       1.1  augustss 
    786       1.1  augustss 	if (lsr != NULL)
    787       1.1  augustss 		*lsr = sc->sc_lsr;
    788       1.1  augustss 	if (msr != NULL)
    789       1.1  augustss 		*msr = sc->sc_msr;
    790       1.1  augustss }
    791