Home | History | Annotate | Line # | Download | only in usb
ubsa.c revision 1.18.2.1
      1  1.18.2.1      yamt /*	$NetBSD: ubsa.c,v 1.18.2.1 2007/03/24 14:55:49 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.18.2.1      yamt __KERNEL_RCSID(0, "$NetBSD: ubsa.c,v 1.18.2.1 2007/03/24 14:55:49 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.17   mlelstv #define UBSA_QUADUMTS_SET_PIN   0x22
    132      1.17   mlelstv 
    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.17   mlelstv 	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.17   mlelstv Static	void ubsa_quadumts_dtr(struct ubsa_softc *, int);
    208       1.1  augustss Static	void ubsa_rts(struct ubsa_softc *, int);
    209      1.17   mlelstv 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.17   mlelstv 	/* Option N.V. */
    239      1.17   mlelstv 	{ USB_VENDOR_OPTIONNV, USB_PRODUCT_OPTIONNV_MC3G },
    240      1.17   mlelstv 	{ USB_VENDOR_OPTIONNV, USB_PRODUCT_OPTIONNV_QUADUMTS2 },
    241      1.17   mlelstv 	{ USB_VENDOR_OPTIONNV, USB_PRODUCT_OPTIONNV_QUADUMTS },
    242      1.18      salo 	/* AnyDATA ADU-E100H */
    243      1.18      salo 	{ 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 	return (ubsa_lookup(uaa->vendor, uaa->product) != NULL ?
    254       1.1  augustss 		UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
    255       1.1  augustss }
    256       1.1  augustss 
    257       1.1  augustss USB_ATTACH(ubsa)
    258       1.1  augustss {
    259       1.1  augustss 	USB_ATTACH_START(ubsa, sc, uaa);
    260       1.1  augustss 	usbd_device_handle dev = uaa->device;
    261       1.1  augustss 	usb_config_descriptor_t *cdesc;
    262       1.1  augustss 	usb_interface_descriptor_t *id;
    263       1.1  augustss 	usb_endpoint_descriptor_t *ed;
    264      1.12  augustss 	char *devinfop;
    265       1.1  augustss 	const char *devname = USBDEVNAME(sc->sc_dev);
    266       1.1  augustss 	usbd_status err;
    267       1.1  augustss 	struct ucom_attach_args uca;
    268       1.1  augustss 	int i;
    269       1.1  augustss 
    270      1.12  augustss 	devinfop = usbd_devinfo_alloc(dev, 0);
    271      1.12  augustss 	USB_ATTACH_SETUP;
    272      1.12  augustss 	printf("%s: %s\n", devname, devinfop);
    273      1.12  augustss 	usbd_devinfo_free(devinfop);
    274       1.1  augustss 
    275       1.1  augustss         sc->sc_udev = dev;
    276       1.1  augustss 
    277       1.1  augustss 	/*
    278       1.1  augustss 	 * initialize rts, dtr variables to something
    279       1.3  augustss 	 * different from boolean 0, 1
    280       1.1  augustss 	 */
    281       1.1  augustss 	sc->sc_dtr = -1;
    282       1.1  augustss 	sc->sc_rts = -1;
    283       1.1  augustss 
    284      1.17   mlelstv 	/*
    285      1.17   mlelstv 	 * Quad UMTS cards use different requests to
    286      1.17   mlelstv 	 * control com settings and only some.
    287      1.17   mlelstv 	 */
    288      1.17   mlelstv 	sc->sc_quadumts = 0;
    289      1.17   mlelstv 	if (uaa->vendor == USB_VENDOR_OPTIONNV) {
    290      1.17   mlelstv 		switch (uaa->product) {
    291      1.17   mlelstv 		case USB_PRODUCT_OPTIONNV_QUADUMTS:
    292      1.17   mlelstv 		case USB_PRODUCT_OPTIONNV_QUADUMTS2:
    293      1.17   mlelstv 			sc->sc_quadumts = 1;
    294      1.17   mlelstv 			break;
    295      1.17   mlelstv 		}
    296      1.17   mlelstv 	}
    297      1.17   mlelstv 
    298       1.1  augustss 	DPRINTF(("ubsa attach: sc = %p\n", sc));
    299       1.1  augustss 
    300       1.3  augustss 	/* initialize endpoints */
    301       1.1  augustss 	uca.bulkin = uca.bulkout = -1;
    302       1.1  augustss 	sc->sc_intr_number = -1;
    303       1.1  augustss 	sc->sc_intr_pipe = NULL;
    304       1.1  augustss 
    305       1.1  augustss 	/* Move the device into the configured state. */
    306       1.1  augustss 	err = usbd_set_config_index(dev, UBSA_CONFIG_INDEX, 1);
    307       1.1  augustss 	if (err) {
    308       1.1  augustss 		printf("%s: failed to set configuration: %s\n",
    309       1.1  augustss 		    devname, usbd_errstr(err));
    310       1.1  augustss 		sc->sc_dying = 1;
    311       1.1  augustss 		goto error;
    312       1.1  augustss 	}
    313       1.1  augustss 
    314       1.1  augustss 	/* get the config descriptor */
    315       1.1  augustss 	cdesc = usbd_get_config_descriptor(sc->sc_udev);
    316       1.1  augustss 
    317       1.1  augustss 	if (cdesc == NULL) {
    318       1.1  augustss 		printf("%s: failed to get configuration descriptor\n",
    319       1.1  augustss 		    devname);
    320       1.1  augustss 		sc->sc_dying = 1;
    321       1.1  augustss 		goto error;
    322       1.1  augustss 	}
    323       1.1  augustss 
    324       1.1  augustss 	/* get the first interface */
    325       1.1  augustss 	err = usbd_device2interface_handle(dev, UBSA_IFACE_INDEX,
    326       1.1  augustss 	    &sc->sc_iface);
    327       1.1  augustss 	if (err) {
    328       1.1  augustss 		printf("%s: failed to get interface: %s\n",
    329       1.1  augustss 			devname, usbd_errstr(err));
    330       1.1  augustss 		sc->sc_dying = 1;
    331       1.1  augustss 		goto error;
    332       1.1  augustss 	}
    333       1.1  augustss 
    334       1.1  augustss 	/* Find the endpoints */
    335       1.1  augustss 
    336       1.1  augustss 	id = usbd_get_interface_descriptor(sc->sc_iface);
    337       1.1  augustss 	sc->sc_iface_number = id->bInterfaceNumber;
    338       1.1  augustss 
    339       1.1  augustss 	for (i = 0; i < id->bNumEndpoints; i++) {
    340       1.1  augustss 		ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i);
    341       1.1  augustss 		if (ed == NULL) {
    342       1.1  augustss 			printf("%s: no endpoint descriptor for %d\n",
    343       1.1  augustss 			    USBDEVNAME(sc->sc_dev), i);
    344       1.1  augustss 			sc->sc_dying = 1;
    345       1.1  augustss 			goto error;
    346       1.1  augustss 		}
    347       1.1  augustss 
    348       1.1  augustss 		if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
    349       1.1  augustss 		    UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
    350       1.1  augustss 			sc->sc_intr_number = ed->bEndpointAddress;
    351       1.1  augustss 			sc->sc_isize = UGETW(ed->wMaxPacketSize);
    352       1.1  augustss 		} else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
    353       1.1  augustss 		    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
    354       1.1  augustss 			uca.bulkin = ed->bEndpointAddress;
    355       1.1  augustss 			uca.ibufsize = UGETW(ed->wMaxPacketSize);
    356       1.1  augustss 		} else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
    357       1.1  augustss 		    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
    358       1.1  augustss 			uca.bulkout = ed->bEndpointAddress;
    359       1.1  augustss 			uca.obufsize = UGETW(ed->wMaxPacketSize);
    360       1.1  augustss 		}
    361       1.1  augustss 	}
    362       1.1  augustss 
    363       1.1  augustss 	if (sc->sc_intr_number == -1) {
    364       1.1  augustss 		printf("%s: Could not find interrupt in\n", devname);
    365       1.1  augustss 		sc->sc_dying = 1;
    366       1.1  augustss 		goto error;
    367       1.1  augustss 	}
    368       1.1  augustss 
    369       1.1  augustss 	if (uca.bulkin == -1) {
    370       1.1  augustss 		printf("%s: Could not find data bulk in\n", devname);
    371       1.1  augustss 		sc->sc_dying = 1;
    372       1.1  augustss 		goto error;
    373       1.1  augustss 	}
    374       1.1  augustss 
    375       1.1  augustss 	if (uca.bulkout == -1) {
    376       1.1  augustss 		printf("%s: Could not find data bulk out\n", devname);
    377       1.1  augustss 		sc->sc_dying = 1;
    378       1.1  augustss 		goto error;
    379       1.1  augustss 	}
    380       1.1  augustss 
    381       1.1  augustss 	uca.portno = UCOM_UNK_PORTNO;
    382       1.1  augustss 	/* bulkin, bulkout set above */
    383       1.1  augustss 	uca.ibufsizepad = uca.ibufsize;
    384       1.1  augustss 	uca.opkthdrlen = 0;
    385       1.1  augustss 	uca.device = dev;
    386       1.1  augustss 	uca.iface = sc->sc_iface;
    387       1.1  augustss 	uca.methods = &ubsa_methods;
    388       1.1  augustss 	uca.arg = sc;
    389       1.1  augustss 	uca.info = NULL;
    390       1.1  augustss 
    391       1.1  augustss 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
    392       1.1  augustss 			   USBDEV(sc->sc_dev));
    393       1.1  augustss 
    394       1.1  augustss 	DPRINTF(("ubsa: in = 0x%x, out = 0x%x, intr = 0x%x\n",
    395      1.14  christos 	    uca.bulkin, uca.bulkout, sc->sc_intr_number));
    396       1.1  augustss 
    397      1.10  drochner 	sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, &uca,
    398      1.10  drochner 					    ucomprint, ucomsubmatch);
    399       1.1  augustss 
    400       1.1  augustss 	USB_ATTACH_SUCCESS_RETURN;
    401       1.1  augustss 
    402       1.1  augustss error:
    403       1.1  augustss 	USB_ATTACH_ERROR_RETURN;
    404       1.1  augustss }
    405       1.1  augustss 
    406       1.1  augustss USB_DETACH(ubsa)
    407       1.1  augustss {
    408       1.1  augustss 	USB_DETACH_START(ubsa, sc);
    409       1.5      fvdl 	int rv = 0;
    410       1.1  augustss 
    411       1.1  augustss 
    412       1.1  augustss 	DPRINTF(("ubsa_detach: sc = %p\n", sc));
    413       1.1  augustss 
    414       1.1  augustss 	if (sc->sc_intr_pipe != NULL) {
    415       1.1  augustss 		usbd_abort_pipe(sc->sc_intr_pipe);
    416       1.1  augustss 		usbd_close_pipe(sc->sc_intr_pipe);
    417       1.1  augustss 		free(sc->sc_intr_buf, M_USBDEV);
    418       1.1  augustss 		sc->sc_intr_pipe = NULL;
    419       1.1  augustss 	}
    420       1.1  augustss 
    421       1.1  augustss 	sc->sc_dying = 1;
    422       1.1  augustss 	if (sc->sc_subdev != NULL) {
    423       1.1  augustss 		rv = config_detach(sc->sc_subdev, flags);
    424       1.1  augustss 		sc->sc_subdev = NULL;
    425       1.1  augustss 	}
    426       1.1  augustss 
    427       1.1  augustss 	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
    428       1.1  augustss 			   USBDEV(sc->sc_dev));
    429       1.1  augustss 
    430       1.1  augustss 	return (rv);
    431       1.1  augustss }
    432       1.1  augustss 
    433       1.2     pooka int
    434       1.1  augustss ubsa_activate(device_ptr_t self, enum devact act)
    435       1.1  augustss {
    436       1.1  augustss 	struct ubsa_softc *sc = (struct ubsa_softc *)self;
    437       1.1  augustss 	int rv = 0;
    438       1.1  augustss 
    439       1.1  augustss 	switch (act) {
    440       1.1  augustss 	case DVACT_ACTIVATE:
    441       1.1  augustss 		return (EOPNOTSUPP);
    442       1.1  augustss 
    443       1.1  augustss 	case DVACT_DEACTIVATE:
    444       1.1  augustss 		if (sc->sc_subdev != NULL)
    445       1.1  augustss 			rv = config_deactivate(sc->sc_subdev);
    446       1.1  augustss 		sc->sc_dying = 1;
    447       1.1  augustss 		break;
    448       1.1  augustss 	}
    449       1.1  augustss 	return (rv);
    450       1.1  augustss }
    451       1.1  augustss 
    452       1.1  augustss Static int
    453       1.1  augustss ubsa_request(struct ubsa_softc *sc, u_int8_t request, u_int16_t value)
    454       1.1  augustss {
    455       1.1  augustss 	usb_device_request_t req;
    456       1.1  augustss 	usbd_status err;
    457       1.1  augustss 
    458      1.17   mlelstv 	if (sc->sc_quadumts)
    459      1.17   mlelstv 		req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
    460      1.17   mlelstv 	else
    461      1.17   mlelstv 		req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
    462      1.17   mlelstv 
    463       1.1  augustss 	req.bRequest = request;
    464       1.1  augustss 	USETW(req.wValue, value);
    465       1.1  augustss 	USETW(req.wIndex, sc->sc_iface_number);
    466       1.1  augustss 	USETW(req.wLength, 0);
    467       1.1  augustss 
    468       1.1  augustss 	err = usbd_do_request(sc->sc_udev, &req, 0);
    469       1.1  augustss 	if (err)
    470       1.1  augustss 		printf("%s: ubsa_request: %s\n",
    471       1.1  augustss 		    USBDEVNAME(sc->sc_dev), usbd_errstr(err));
    472       1.1  augustss 	return (err);
    473       1.1  augustss }
    474       1.1  augustss 
    475       1.1  augustss Static void
    476       1.1  augustss ubsa_dtr(struct ubsa_softc *sc, int onoff)
    477       1.1  augustss {
    478       1.1  augustss 
    479       1.1  augustss 	DPRINTF(("ubsa_dtr: onoff = %d\n", onoff));
    480       1.1  augustss 
    481       1.1  augustss 	if (sc->sc_dtr == onoff)
    482       1.1  augustss 		return;
    483       1.1  augustss 	sc->sc_dtr = onoff;
    484       1.1  augustss 
    485       1.1  augustss 	ubsa_request(sc, UBSA_SET_DTR, onoff ? 1 : 0);
    486       1.1  augustss }
    487       1.1  augustss 
    488       1.1  augustss Static void
    489       1.1  augustss ubsa_rts(struct ubsa_softc *sc, int onoff)
    490       1.1  augustss {
    491       1.1  augustss 
    492       1.1  augustss 	DPRINTF(("ubsa_rts: onoff = %d\n", onoff));
    493       1.1  augustss 
    494       1.1  augustss 	if (sc->sc_rts == onoff)
    495       1.1  augustss 		return;
    496       1.1  augustss 	sc->sc_rts = onoff;
    497       1.1  augustss 
    498       1.1  augustss 	ubsa_request(sc, UBSA_SET_RTS, onoff ? 1 : 0);
    499       1.1  augustss }
    500       1.1  augustss 
    501       1.1  augustss Static void
    502      1.17   mlelstv ubsa_quadumts_dtr(struct ubsa_softc *sc, int onoff)
    503      1.17   mlelstv {
    504      1.17   mlelstv 
    505      1.17   mlelstv 	DPRINTF(("ubsa_dtr: onoff = %d\n", onoff));
    506      1.17   mlelstv 
    507      1.17   mlelstv 	if (sc->sc_dtr == onoff)
    508      1.17   mlelstv 		return;
    509      1.17   mlelstv 	sc->sc_dtr = onoff;
    510      1.17   mlelstv 
    511      1.17   mlelstv 	ubsa_request(sc, UBSA_QUADUMTS_SET_PIN, (sc->sc_rts ? 2 : 0)+(sc->sc_dtr ? 1 : 0));
    512      1.17   mlelstv }
    513      1.17   mlelstv 
    514      1.17   mlelstv Static void
    515      1.17   mlelstv ubsa_quadumts_rts(struct ubsa_softc *sc, int onoff)
    516      1.17   mlelstv {
    517      1.17   mlelstv 
    518      1.17   mlelstv 	DPRINTF(("ubsa_rts: onoff = %d\n", onoff));
    519      1.17   mlelstv 
    520      1.17   mlelstv 	if (sc->sc_rts == onoff)
    521      1.17   mlelstv 		return;
    522      1.17   mlelstv 	sc->sc_rts = onoff;
    523      1.17   mlelstv 
    524      1.17   mlelstv 	ubsa_request(sc, UBSA_QUADUMTS_SET_PIN, (sc->sc_rts ? 2 : 0)+(sc->sc_dtr ? 1 : 0));
    525      1.17   mlelstv }
    526      1.17   mlelstv 
    527      1.17   mlelstv Static void
    528       1.1  augustss ubsa_break(struct ubsa_softc *sc, int onoff)
    529       1.1  augustss {
    530       1.1  augustss 	DPRINTF(("ubsa_rts: onoff = %d\n", onoff));
    531       1.1  augustss 
    532       1.1  augustss 	ubsa_request(sc, UBSA_SET_BREAK, onoff ? 1 : 0);
    533       1.1  augustss }
    534       1.1  augustss 
    535       1.1  augustss Static void
    536      1.16  christos ubsa_set(void *addr, int portno, int reg, int onoff)
    537       1.1  augustss {
    538       1.1  augustss 	struct ubsa_softc *sc;
    539       1.1  augustss 
    540       1.1  augustss 	sc = addr;
    541       1.1  augustss 	switch (reg) {
    542       1.1  augustss 	case UCOM_SET_DTR:
    543      1.17   mlelstv 		if (sc->sc_quadumts)
    544      1.17   mlelstv 			ubsa_quadumts_dtr(sc, onoff);
    545      1.17   mlelstv 		else
    546      1.17   mlelstv 			ubsa_dtr(sc, onoff);
    547       1.1  augustss 		break;
    548       1.1  augustss 	case UCOM_SET_RTS:
    549      1.17   mlelstv 		if (sc->sc_quadumts)
    550      1.17   mlelstv 			ubsa_quadumts_rts(sc, onoff);
    551      1.17   mlelstv 		else
    552      1.17   mlelstv 			ubsa_rts(sc, onoff);
    553       1.1  augustss 		break;
    554       1.1  augustss 	case UCOM_SET_BREAK:
    555      1.17   mlelstv 		if (!sc->sc_quadumts)
    556      1.17   mlelstv 			ubsa_break(sc, onoff);
    557       1.1  augustss 		break;
    558       1.1  augustss 	default:
    559       1.1  augustss 		break;
    560       1.1  augustss 	}
    561       1.1  augustss }
    562       1.1  augustss 
    563       1.1  augustss Static void
    564       1.1  augustss ubsa_baudrate(struct ubsa_softc *sc, speed_t speed)
    565       1.1  augustss {
    566       1.1  augustss 	u_int16_t value = 0;
    567       1.3  augustss 
    568       1.1  augustss 	DPRINTF(("ubsa_baudrate: speed = %d\n", speed));
    569       1.1  augustss 
    570       1.1  augustss 	switch(speed) {
    571       1.1  augustss 	case B0:
    572       1.1  augustss 		break;
    573       1.1  augustss 	case B300:
    574       1.1  augustss 	case B600:
    575       1.1  augustss 	case B1200:
    576       1.1  augustss 	case B2400:
    577       1.1  augustss 	case B4800:
    578       1.1  augustss 	case B9600:
    579       1.1  augustss 	case B19200:
    580       1.1  augustss 	case B38400:
    581       1.1  augustss 	case B57600:
    582       1.1  augustss 	case B115200:
    583       1.3  augustss 	case B230400:
    584       1.1  augustss 		value = B230400 / speed;
    585       1.1  augustss 		break;
    586       1.3  augustss 	default:
    587       1.1  augustss 		printf("%s: ubsa_param: unsupported baudrate, "
    588       1.1  augustss 		    "forcing default of 9600\n",
    589       1.1  augustss 		    USBDEVNAME(sc->sc_dev));
    590       1.1  augustss 		value = B230400 / B9600;
    591       1.1  augustss 		break;
    592       1.1  augustss 	};
    593       1.3  augustss 
    594       1.1  augustss 	if (speed == B0) {
    595       1.1  augustss 		ubsa_flow(sc, 0, 0);
    596       1.1  augustss 		ubsa_dtr(sc, 0);
    597       1.1  augustss 		ubsa_rts(sc, 0);
    598       1.1  augustss 	} else
    599       1.1  augustss 		ubsa_request(sc, UBSA_SET_BAUDRATE, value);
    600       1.1  augustss }
    601       1.1  augustss 
    602       1.1  augustss Static void
    603       1.1  augustss ubsa_parity(struct ubsa_softc *sc, tcflag_t cflag)
    604       1.1  augustss {
    605       1.1  augustss 	int value;
    606       1.1  augustss 
    607       1.1  augustss 	DPRINTF(("ubsa_parity: cflag = 0x%x\n", cflag));
    608       1.1  augustss 
    609       1.1  augustss 	if (cflag & PARENB)
    610       1.1  augustss 		value = (cflag & PARODD) ? UBSA_PARITY_ODD : UBSA_PARITY_EVEN;
    611       1.1  augustss 	else
    612       1.1  augustss 		value = UBSA_PARITY_NONE;
    613       1.1  augustss 
    614       1.1  augustss 	ubsa_request(sc, UBSA_SET_PARITY, value);
    615       1.1  augustss }
    616       1.1  augustss 
    617       1.1  augustss Static void
    618       1.1  augustss ubsa_databits(struct ubsa_softc *sc, tcflag_t cflag)
    619       1.1  augustss {
    620       1.1  augustss 	int value;
    621       1.1  augustss 
    622       1.1  augustss 	DPRINTF(("ubsa_databits: cflag = 0x%x\n", cflag));
    623       1.1  augustss 
    624       1.1  augustss 	switch (cflag & CSIZE) {
    625       1.1  augustss 	case CS5: value = 0; break;
    626       1.1  augustss 	case CS6: value = 1; break;
    627       1.1  augustss 	case CS7: value = 2; break;
    628       1.1  augustss 	case CS8: value = 3; break;
    629       1.3  augustss 	default:
    630       1.1  augustss 		printf("%s: ubsa_param: unsupported databits requested, "
    631       1.1  augustss 		    "forcing default of 8\n",
    632       1.1  augustss 		    USBDEVNAME(sc->sc_dev));
    633       1.1  augustss 		value = 3;
    634       1.1  augustss 	}
    635       1.1  augustss 
    636       1.1  augustss 	ubsa_request(sc, UBSA_SET_DATA_BITS, value);
    637       1.1  augustss }
    638       1.1  augustss 
    639       1.1  augustss Static void
    640       1.1  augustss ubsa_stopbits(struct ubsa_softc *sc, tcflag_t cflag)
    641       1.1  augustss {
    642       1.1  augustss 	int value;
    643       1.1  augustss 
    644       1.1  augustss 	DPRINTF(("ubsa_stopbits: cflag = 0x%x\n", cflag));
    645       1.1  augustss 
    646       1.1  augustss 	value = (cflag & CSTOPB) ? 1 : 0;
    647       1.1  augustss 
    648       1.1  augustss 	ubsa_request(sc, UBSA_SET_STOP_BITS, value);
    649       1.1  augustss }
    650       1.1  augustss 
    651       1.1  augustss Static void
    652       1.1  augustss ubsa_flow(struct ubsa_softc *sc, tcflag_t cflag, tcflag_t iflag)
    653       1.1  augustss {
    654       1.1  augustss 	int value;
    655       1.3  augustss 
    656       1.1  augustss 	DPRINTF(("ubsa_flow: cflag = 0x%x, iflag = 0x%x\n", cflag, iflag));
    657       1.1  augustss 
    658       1.1  augustss 	value = 0;
    659       1.1  augustss 	if (cflag & CRTSCTS)
    660       1.1  augustss 		value |= UBSA_FLOW_OCTS | UBSA_FLOW_IRTS;
    661       1.1  augustss 	if (iflag & (IXON|IXOFF))
    662       1.1  augustss 		value |= UBSA_FLOW_OXON | UBSA_FLOW_IXON;
    663       1.1  augustss 
    664       1.1  augustss 	ubsa_request(sc, UBSA_SET_FLOW_CTRL, value);
    665       1.1  augustss }
    666       1.1  augustss 
    667       1.1  augustss Static int
    668      1.16  christos ubsa_param(void *addr, int portno, struct termios *ti)
    669       1.1  augustss {
    670       1.3  augustss 	struct ubsa_softc *sc = addr;
    671       1.1  augustss 
    672       1.1  augustss 	DPRINTF(("ubsa_param: sc = %p\n", sc));
    673       1.1  augustss 
    674      1.17   mlelstv 	if (!sc->sc_quadumts) {
    675      1.17   mlelstv 		ubsa_baudrate(sc, ti->c_ospeed);
    676      1.17   mlelstv 		ubsa_parity(sc, ti->c_cflag);
    677      1.17   mlelstv 		ubsa_databits(sc, ti->c_cflag);
    678      1.17   mlelstv 		ubsa_stopbits(sc, ti->c_cflag);
    679      1.17   mlelstv 		ubsa_flow(sc, ti->c_cflag, ti->c_iflag);
    680      1.17   mlelstv 	}
    681       1.1  augustss 
    682       1.1  augustss 	return (0);
    683       1.1  augustss }
    684       1.1  augustss 
    685       1.1  augustss Static int
    686      1.16  christos ubsa_open(void *addr, int portno)
    687       1.1  augustss {
    688       1.3  augustss 	struct ubsa_softc *sc = addr;
    689       1.1  augustss 	int err;
    690       1.3  augustss 
    691       1.1  augustss 	if (sc->sc_dying)
    692       1.1  augustss 		return (ENXIO);
    693       1.1  augustss 
    694       1.1  augustss 	DPRINTF(("ubsa_open: sc = %p\n", sc));
    695       1.1  augustss 
    696       1.1  augustss 	if (sc->sc_intr_number != -1 && sc->sc_intr_pipe == NULL) {
    697       1.1  augustss 		sc->sc_intr_buf = malloc(sc->sc_isize, M_USBDEV, M_WAITOK);
    698      1.11  augustss 		err = usbd_open_pipe_intr(sc->sc_iface,
    699       1.1  augustss 		    sc->sc_intr_number,
    700       1.1  augustss 		    USBD_SHORT_XFER_OK,
    701       1.1  augustss 		    &sc->sc_intr_pipe,
    702       1.1  augustss 		    sc,
    703       1.1  augustss 		    sc->sc_intr_buf,
    704       1.1  augustss 		    sc->sc_isize,
    705       1.1  augustss 		    ubsa_intr,
    706       1.1  augustss 		    UBSA_INTR_INTERVAL);
    707       1.1  augustss 		if (err) {
    708       1.1  augustss 			printf("%s: cannot open interrupt pipe (addr %d)\n",
    709       1.1  augustss 			    USBDEVNAME(sc->sc_dev),
    710       1.1  augustss 			    sc->sc_intr_number);
    711       1.1  augustss 			return (EIO);
    712       1.1  augustss 		}
    713       1.1  augustss 	}
    714       1.1  augustss 
    715       1.1  augustss 	return (0);
    716       1.1  augustss }
    717       1.1  augustss 
    718       1.1  augustss Static void
    719      1.16  christos ubsa_close(void *addr, int portno)
    720       1.1  augustss {
    721       1.3  augustss 	struct ubsa_softc *sc = addr;
    722       1.1  augustss 	int err;
    723       1.1  augustss 
    724       1.1  augustss 	if (sc->sc_dying)
    725       1.1  augustss 		return;
    726       1.1  augustss 
    727       1.1  augustss 	DPRINTF(("ubsa_close: close\n"));
    728       1.1  augustss 
    729       1.1  augustss 	if (sc->sc_intr_pipe != NULL) {
    730       1.1  augustss 		err = usbd_abort_pipe(sc->sc_intr_pipe);
    731       1.1  augustss 		if (err)
    732       1.1  augustss 			printf("%s: abort interrupt pipe failed: %s\n",
    733       1.1  augustss 			    USBDEVNAME(sc->sc_dev),
    734       1.1  augustss 			    usbd_errstr(err));
    735       1.1  augustss 		err = usbd_close_pipe(sc->sc_intr_pipe);
    736       1.1  augustss 		if (err)
    737       1.1  augustss 			printf("%s: close interrupt pipe failed: %s\n",
    738       1.1  augustss 			    USBDEVNAME(sc->sc_dev),
    739       1.1  augustss 			    usbd_errstr(err));
    740       1.1  augustss 		free(sc->sc_intr_buf, M_USBDEV);
    741       1.1  augustss 		sc->sc_intr_pipe = NULL;
    742       1.1  augustss 	}
    743       1.1  augustss }
    744       1.1  augustss 
    745       1.1  augustss Static void
    746      1.16  christos ubsa_intr(usbd_xfer_handle xfer, usbd_private_handle priv,
    747      1.15  christos     usbd_status status)
    748       1.1  augustss {
    749       1.3  augustss 	struct ubsa_softc *sc = priv;
    750       1.1  augustss 	u_char *buf;
    751       1.1  augustss 
    752       1.1  augustss 	buf = sc->sc_intr_buf;
    753       1.1  augustss 	if (sc->sc_dying)
    754       1.1  augustss 		return;
    755       1.1  augustss 
    756       1.1  augustss 	if (status != USBD_NORMAL_COMPLETION) {
    757       1.1  augustss 		if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
    758       1.1  augustss 			return;
    759       1.1  augustss 
    760       1.1  augustss 		DPRINTF(("%s: ubsa_intr: abnormal status: %s\n",
    761      1.14  christos 		    USBDEVNAME(sc->sc_dev), usbd_errstr(status)));
    762       1.1  augustss 		usbd_clear_endpoint_stall_async(sc->sc_intr_pipe);
    763       1.1  augustss 		return;
    764       1.1  augustss 	}
    765       1.1  augustss 
    766       1.1  augustss 	/* incidentally, Belkin adapter status bits match UART 16550 bits */
    767       1.1  augustss 	sc->sc_lsr = buf[2];
    768       1.1  augustss 	sc->sc_msr = buf[3];
    769       1.1  augustss 
    770       1.1  augustss 	DPRINTF(("%s: ubsa lsr = 0x%02x, msr = 0x%02x\n",
    771      1.14  christos 	    USBDEVNAME(sc->sc_dev), sc->sc_lsr, sc->sc_msr));
    772       1.1  augustss 
    773       1.1  augustss 	ucom_status_change((struct ucom_softc *)sc->sc_subdev);
    774       1.1  augustss }
    775       1.1  augustss 
    776       1.1  augustss Static void
    777      1.16  christos ubsa_get_status(void *addr, int portno, u_char *lsr, u_char *msr)
    778       1.1  augustss {
    779       1.3  augustss 	struct ubsa_softc *sc = addr;
    780       1.1  augustss 
    781       1.1  augustss 	DPRINTF(("ubsa_get_status\n"));
    782       1.1  augustss 
    783       1.1  augustss 	if (lsr != NULL)
    784       1.1  augustss 		*lsr = sc->sc_lsr;
    785       1.1  augustss 	if (msr != NULL)
    786       1.1  augustss 		*msr = sc->sc_msr;
    787       1.1  augustss }
    788