Deleted Added
full compact
usb_serial.c (214831) usb_serial.c (214843)
1/* $NetBSD: ucom.c,v 1.40 2001/11/13 06:24:54 lukem Exp $ */
2
3/*-
4 * Copyright (c) 2001-2003, 2005, 2008
5 * Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/* $NetBSD: ucom.c,v 1.40 2001/11/13 06:24:54 lukem Exp $ */
2
3/*-
4 * Copyright (c) 2001-2003, 2005, 2008
5 * Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/usb/serial/usb_serial.c 214831 2010-11-05 09:06:23Z n_hibma $");
31__FBSDID("$FreeBSD: head/sys/dev/usb/serial/usb_serial.c 214843 2010-11-05 19:12:48Z n_hibma $");
32
33/*-
34 * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
35 * All rights reserved.
36 *
37 * This code is derived from software contributed to The NetBSD Foundation
38 * by Lennart Augustsson (lennart@augustsson.net) at
39 * Carlstedt Research & Technology.

--- 140 unchanged lines hidden (view full) ---

180MODULE_VERSION(ucom, 1);
181
182#define UCOM_UNIT_MAX 128 /* limits size of ucom_bitmap */
183
184static uint8_t ucom_bitmap[(UCOM_UNIT_MAX + 7) / 8];
185static struct mtx ucom_bitmap_mtx;
186MTX_SYSINIT(ucom_bitmap_mtx, &ucom_bitmap_mtx, "ucom bitmap", MTX_DEF);
187
32
33/*-
34 * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
35 * All rights reserved.
36 *
37 * This code is derived from software contributed to The NetBSD Foundation
38 * by Lennart Augustsson (lennart@augustsson.net) at
39 * Carlstedt Research & Technology.

--- 140 unchanged lines hidden (view full) ---

180MODULE_VERSION(ucom, 1);
181
182#define UCOM_UNIT_MAX 128 /* limits size of ucom_bitmap */
183
184static uint8_t ucom_bitmap[(UCOM_UNIT_MAX + 7) / 8];
185static struct mtx ucom_bitmap_mtx;
186MTX_SYSINIT(ucom_bitmap_mtx, &ucom_bitmap_mtx, "ucom bitmap", MTX_DEF);
187
188#define UCOM_TTY_PREFIX "U"
189
188/*
189 * Mark a unit number (the X in cuaUX) as in use.
190 *
191 * Note that devices using a different naming scheme (see ucom_tty_name()
192 * callback) still use this unit allocation.
193 */
194static int
195ucom_unit_alloc(void)

--- 119 unchanged lines hidden (view full) ---

315 if (sc->sc_callback->ucom_tty_name) {
316 sc->sc_callback->ucom_tty_name(sc, buf,
317 sizeof(buf), ssc->sc_unit, sc->sc_subunit);
318 }
319 if (buf[0] == 0) {
320 /* Use default TTY name */
321 if (ssc->sc_subunits > 1) {
322 /* multiple modems in one */
190/*
191 * Mark a unit number (the X in cuaUX) as in use.
192 *
193 * Note that devices using a different naming scheme (see ucom_tty_name()
194 * callback) still use this unit allocation.
195 */
196static int
197ucom_unit_alloc(void)

--- 119 unchanged lines hidden (view full) ---

317 if (sc->sc_callback->ucom_tty_name) {
318 sc->sc_callback->ucom_tty_name(sc, buf,
319 sizeof(buf), ssc->sc_unit, sc->sc_subunit);
320 }
321 if (buf[0] == 0) {
322 /* Use default TTY name */
323 if (ssc->sc_subunits > 1) {
324 /* multiple modems in one */
323 snprintf(buf, sizeof(buf), "U%u.%u",
325 snprintf(buf, sizeof(buf), UCOM_TTY_PREFIX "%u.%u",
324 ssc->sc_unit, sc->sc_subunit);
325 } else {
326 /* single modem */
326 ssc->sc_unit, sc->sc_subunit);
327 } else {
328 /* single modem */
327 snprintf(buf, sizeof(buf), "U%u", ssc->sc_unit);
329 snprintf(buf, sizeof(buf), UCOM_TTY_PREFIX "%u",
330 ssc->sc_unit);
328 }
329 }
330 tty_makedev(tp, NULL, "%s", buf);
331
332 sc->sc_tty = tp;
333
334 DPRINTF("ttycreate: %s\n", buf);
335 cv_init(&sc->sc_cv, "ucom");

--- 68 unchanged lines hidden (view full) ---

404 if (sc->sc_callback->ucom_stop_write) {
405 (sc->sc_callback->ucom_stop_write) (sc);
406 }
407 mtx_unlock(sc->sc_mtx);
408 }
409 cv_destroy(&sc->sc_cv);
410}
411
331 }
332 }
333 tty_makedev(tp, NULL, "%s", buf);
334
335 sc->sc_tty = tp;
336
337 DPRINTF("ttycreate: %s\n", buf);
338 cv_init(&sc->sc_cv, "ucom");

--- 68 unchanged lines hidden (view full) ---

407 if (sc->sc_callback->ucom_stop_write) {
408 (sc->sc_callback->ucom_stop_write) (sc);
409 }
410 mtx_unlock(sc->sc_mtx);
411 }
412 cv_destroy(&sc->sc_cv);
413}
414
415void
416ucom_set_pnpinfo_usb(struct ucom_super_softc *ssc, device_t dev)
417{
418 char buf[64];
419 uint8_t iface_index;
420 struct usb_attach_arg *uaa;
421
422 snprintf(buf, sizeof(buf), "ttyname=%s%d ttyports=%d",
423 UCOM_TTY_PREFIX, ssc->sc_unit, ssc->sc_subunits);
424
425 /* Store the PNP info in the first interface for the dev */
426 uaa = device_get_ivars(dev);
427 iface_index = uaa->info.bIfaceIndex;
428
429 if (usbd_set_pnpinfo(uaa->device, iface_index, buf) != 0)
430 device_printf(dev, "Could not set PNP info\n");
431}
432
412static void
413ucom_queue_command(struct ucom_softc *sc,
414 usb_proc_callback_t *fn, struct termios *pt,
415 struct usb_proc_msg *t0, struct usb_proc_msg *t1)
416{
417 struct ucom_super_softc *ssc = sc->sc_super;
418 struct ucom_param_task *task;
419

--- 999 unchanged lines hidden ---
433static void
434ucom_queue_command(struct ucom_softc *sc,
435 usb_proc_callback_t *fn, struct termios *pt,
436 struct usb_proc_msg *t0, struct usb_proc_msg *t1)
437{
438 struct ucom_super_softc *ssc = sc->sc_super;
439 struct ucom_param_task *task;
440

--- 999 unchanged lines hidden ---