diff options
author | hselasky <hselasky@FreeBSD.org> | 2012-08-05 08:56:29 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2012-08-05 08:56:29 +0000 |
commit | c00a121761a94418efab6d83840096cb961b71d1 (patch) | |
tree | 36084a6f7068274856cc4d22ec80a640c819c28b | |
parent | 5f9688f4ffbef7ac96c49a51717e34740c42f167 (diff) | |
download | FreeBSD-src-c00a121761a94418efab6d83840096cb961b71d1.zip FreeBSD-src-c00a121761a94418efab6d83840096cb961b71d1.tar.gz |
Minor style nit:
Use the interface number from the USB interface descriptor
like in the other USB serial drivers. These numbers are not
supposed to be different, though in theory they can. Make sure
that the driver then uses the interface number given by the USB
descriptor, and not the logical index of the USB stack.
For the future:
Whenever the term "index" is used in the USB code, it refers to
a number computed by the USB stack.
Whenever the term "number" is used in the USB code, it refers to
a number in a USB descriptor.
MFC after: 2 weeks
-rw-r--r-- | sys/dev/usb/serial/uslcom.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/sys/dev/usb/serial/uslcom.c b/sys/dev/usb/serial/uslcom.c index 702c09c..f1d5b36 100644 --- a/sys/dev/usb/serial/uslcom.c +++ b/sys/dev/usb/serial/uslcom.c @@ -135,7 +135,7 @@ struct uslcom_softc { uint8_t sc_msr; uint8_t sc_lsr; - uint8_t sc_IfIdx; + uint8_t sc_iface_no; }; static device_probe_t uslcom_probe; @@ -382,7 +382,8 @@ uslcom_attach(device_t dev) usb_callout_init_mtx(&sc->sc_watchdog, &sc->sc_mtx, 0); sc->sc_udev = uaa->device; - sc->sc_IfIdx = uaa->info.bIfaceIndex; + /* use the interface number from the USB interface descriptor */ + sc->sc_iface_no = uaa->info.bIfaceNum; error = usbd_transfer_setup(uaa->device, &uaa->info.bIfaceIndex, sc->sc_xfer, uslcom_config, @@ -437,7 +438,7 @@ uslcom_open(struct ucom_softc *ucom) req.bmRequestType = USLCOM_WRITE; req.bRequest = USLCOM_UART; USETW(req.wValue, USLCOM_UART_ENABLE); - USETW(req.wIndex, sc->sc_IfIdx); + USETW(req.wIndex, sc->sc_iface_no); USETW(req.wLength, 0); if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, @@ -461,7 +462,7 @@ uslcom_close(struct ucom_softc *ucom) req.bmRequestType = USLCOM_WRITE; req.bRequest = USLCOM_UART; USETW(req.wValue, USLCOM_UART_DISABLE); - USETW(req.wIndex, sc->sc_IfIdx); + USETW(req.wIndex, sc->sc_iface_no); USETW(req.wLength, 0); if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, @@ -485,7 +486,7 @@ uslcom_set_dtr(struct ucom_softc *ucom, uint8_t onoff) req.bmRequestType = USLCOM_WRITE; req.bRequest = USLCOM_CTRL; USETW(req.wValue, ctl); - USETW(req.wIndex, sc->sc_IfIdx); + USETW(req.wIndex, sc->sc_iface_no); USETW(req.wLength, 0); if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, @@ -509,7 +510,7 @@ uslcom_set_rts(struct ucom_softc *ucom, uint8_t onoff) req.bmRequestType = USLCOM_WRITE; req.bRequest = USLCOM_CTRL; USETW(req.wValue, ctl); - USETW(req.wIndex, sc->sc_IfIdx); + USETW(req.wIndex, sc->sc_iface_no); USETW(req.wLength, 0); if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, @@ -540,7 +541,7 @@ uslcom_param(struct ucom_softc *ucom, struct termios *t) req.bmRequestType = USLCOM_WRITE; req.bRequest = USLCOM_SET_BAUD_RATE; USETW(req.wValue, 0); - USETW(req.wIndex, sc->sc_IfIdx); + USETW(req.wIndex, sc->sc_iface_no); USETW(req.wLength, sizeof(baudrate)); if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, @@ -577,7 +578,7 @@ uslcom_param(struct ucom_softc *ucom, struct termios *t) req.bmRequestType = USLCOM_WRITE; req.bRequest = USLCOM_DATA; USETW(req.wValue, data); - USETW(req.wIndex, sc->sc_IfIdx); + USETW(req.wIndex, sc->sc_iface_no); USETW(req.wLength, 0); if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, @@ -599,7 +600,7 @@ uslcom_param(struct ucom_softc *ucom, struct termios *t) req.bmRequestType = USLCOM_WRITE; req.bRequest = USLCOM_SET_FLOWCTRL; USETW(req.wValue, 0); - USETW(req.wIndex, sc->sc_IfIdx); + USETW(req.wIndex, sc->sc_iface_no); USETW(req.wLength, sizeof(flowctrl)); if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, @@ -629,7 +630,7 @@ uslcom_set_break(struct ucom_softc *ucom, uint8_t onoff) req.bmRequestType = USLCOM_WRITE; req.bRequest = USLCOM_BREAK; USETW(req.wValue, brk); - USETW(req.wIndex, sc->sc_IfIdx); + USETW(req.wIndex, sc->sc_iface_no); USETW(req.wLength, 0); if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, @@ -783,7 +784,7 @@ uslcom_control_callback(struct usb_xfer *xfer, usb_error_t error) req.bmRequestType = USLCOM_READ; req.bRequest = USLCOM_RCTRL; USETW(req.wValue, 0); - USETW(req.wIndex, sc->sc_IfIdx); + USETW(req.wIndex, sc->sc_iface_no); USETW(req.wLength, sizeof(buf)); usbd_xfer_set_frames(xfer, 2); |