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