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