Deleted Added
full compact
uplcom.c (188942) uplcom.c (189265)
1/* $NetBSD: uplcom.c,v 1.21 2001/11/13 06:24:56 lukem Exp $ */
2
3#include <sys/cdefs.h>
1/* $NetBSD: uplcom.c,v 1.21 2001/11/13 06:24:56 lukem Exp $ */
2
3#include <sys/cdefs.h>
4__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uplcom.c 188942 2009-02-23 18:31:00Z thompsa $");
4__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uplcom.c 189265 2009-03-02 02:44:10Z thompsa $");
5
6/*-
7 * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:

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

140};
141
142struct uplcom_softc {
143 struct usb2_com_super_softc sc_super_ucom;
144 struct usb2_com_softc sc_ucom;
145
146 struct usb2_xfer *sc_xfer[UPLCOM_N_TRANSFER];
147 struct usb2_device *sc_udev;
5
6/*-
7 * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:

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

140};
141
142struct uplcom_softc {
143 struct usb2_com_super_softc sc_super_ucom;
144 struct usb2_com_softc sc_ucom;
145
146 struct usb2_xfer *sc_xfer[UPLCOM_N_TRANSFER];
147 struct usb2_device *sc_udev;
148 struct mtx sc_mtx;
148
149 uint16_t sc_line;
150
151 uint8_t sc_lsr; /* local status register */
152 uint8_t sc_msr; /* uplcom status register */
153 uint8_t sc_chiptype; /* type of chip */
154 uint8_t sc_ctrl_iface_no;
155 uint8_t sc_data_iface_no;

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

321 struct uplcom_softc *sc = device_get_softc(dev);
322 struct usb2_interface *iface;
323 struct usb2_interface_descriptor *id;
324 int error;
325
326 DPRINTFN(11, "\n");
327
328 device_set_usb2_desc(dev);
149
150 uint16_t sc_line;
151
152 uint8_t sc_lsr; /* local status register */
153 uint8_t sc_msr; /* uplcom status register */
154 uint8_t sc_chiptype; /* type of chip */
155 uint8_t sc_ctrl_iface_no;
156 uint8_t sc_data_iface_no;

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

322 struct uplcom_softc *sc = device_get_softc(dev);
323 struct usb2_interface *iface;
324 struct usb2_interface_descriptor *id;
325 int error;
326
327 DPRINTFN(11, "\n");
328
329 device_set_usb2_desc(dev);
330 mtx_init(&sc->sc_mtx, "uplcom", NULL, MTX_DEF);
329
330 DPRINTF("sc = %p\n", sc);
331
332 sc->sc_chiptype = USB_GET_DRIVER_INFO(uaa);
333 sc->sc_udev = uaa->device;
334
335 DPRINTF("chiptype: %s\n",
336 (sc->sc_chiptype == TYPE_PL2303X) ?

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

365 UPLCOM_SECOND_IFACE_INDEX, uaa->info.bIfaceIndex);
366 } else {
367 sc->sc_data_iface_no = sc->sc_ctrl_iface_no;
368 sc->sc_iface_index[0] = UPLCOM_IFACE_INDEX;
369 }
370
371 error = usb2_transfer_setup(uaa->device,
372 sc->sc_iface_index, sc->sc_xfer, uplcom_config_data,
331
332 DPRINTF("sc = %p\n", sc);
333
334 sc->sc_chiptype = USB_GET_DRIVER_INFO(uaa);
335 sc->sc_udev = uaa->device;
336
337 DPRINTF("chiptype: %s\n",
338 (sc->sc_chiptype == TYPE_PL2303X) ?

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

367 UPLCOM_SECOND_IFACE_INDEX, uaa->info.bIfaceIndex);
368 } else {
369 sc->sc_data_iface_no = sc->sc_ctrl_iface_no;
370 sc->sc_iface_index[0] = UPLCOM_IFACE_INDEX;
371 }
372
373 error = usb2_transfer_setup(uaa->device,
374 sc->sc_iface_index, sc->sc_xfer, uplcom_config_data,
373 UPLCOM_N_TRANSFER, sc, &Giant);
375 UPLCOM_N_TRANSFER, sc, &sc->sc_mtx);
374 if (error) {
375 DPRINTF("one or more missing USB endpoints, "
376 "error=%s\n", usb2_errstr(error));
377 goto detach;
378 }
379 error = uplcom_reset(sc, uaa->device);
380 if (error) {
381 device_printf(dev, "reset failed, error=%s\n",
382 usb2_errstr(error));
383 goto detach;
384 }
385 /* clear stall at first run */
376 if (error) {
377 DPRINTF("one or more missing USB endpoints, "
378 "error=%s\n", usb2_errstr(error));
379 goto detach;
380 }
381 error = uplcom_reset(sc, uaa->device);
382 if (error) {
383 device_printf(dev, "reset failed, error=%s\n",
384 usb2_errstr(error));
385 goto detach;
386 }
387 /* clear stall at first run */
388 mtx_lock(&sc->sc_mtx);
386 usb2_transfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_WR]);
387 usb2_transfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_RD]);
389 usb2_transfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_WR]);
390 usb2_transfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_RD]);
391 mtx_unlock(&sc->sc_mtx);
388
389 error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
392
393 error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
390 &uplcom_callback, &Giant);
394 &uplcom_callback, &sc->sc_mtx);
391 if (error) {
392 goto detach;
393 }
394 /*
395 * do the initialization during attach so that the system does not
396 * sleep during open:
397 */
398 if (sc->sc_chiptype == TYPE_PL2303X) {

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

411static int
412uplcom_detach(device_t dev)
413{
414 struct uplcom_softc *sc = device_get_softc(dev);
415
416 DPRINTF("sc=%p\n", sc);
417
418 usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1);
395 if (error) {
396 goto detach;
397 }
398 /*
399 * do the initialization during attach so that the system does not
400 * sleep during open:
401 */
402 if (sc->sc_chiptype == TYPE_PL2303X) {

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

415static int
416uplcom_detach(device_t dev)
417{
418 struct uplcom_softc *sc = device_get_softc(dev);
419
420 DPRINTF("sc=%p\n", sc);
421
422 usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1);
419
420 usb2_transfer_unsetup(sc->sc_xfer, UPLCOM_N_TRANSFER);
423 usb2_transfer_unsetup(sc->sc_xfer, UPLCOM_N_TRANSFER);
424 mtx_destroy(&sc->sc_mtx);
421
422 return (0);
423}
424
425static usb2_error_t
426uplcom_reset(struct uplcom_softc *sc, struct usb2_device *udev)
427{
428 struct usb2_device_request req;

--- 403 unchanged lines hidden ---
425
426 return (0);
427}
428
429static usb2_error_t
430uplcom_reset(struct uplcom_softc *sc, struct usb2_device *udev)
431{
432 struct usb2_device_request req;

--- 403 unchanged lines hidden ---