diff options
| author | mlelstv <mlelstv@NetBSD.org> | 2022-07-31 13:01:16 +0000 |
|---|---|---|
| committer | mlelstv <mlelstv@NetBSD.org> | 2022-07-31 13:01:16 +0000 |
| commit | 139d4be7285a14b6b2321c3cd01ac88cb031f9cf (patch) | |
| tree | 3e5a325f7f9705b7810bd1b0b5a23277c5c5d144 | |
| parent | 8b9c7810cf2b83327e6932590835b72483e53de3 (diff) | |
Compute a unique port number from interface index.
| -rw-r--r-- | sys/dev/usb/umodem_common.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/dev/usb/umodem_common.c b/sys/dev/usb/umodem_common.c index 6bcbd172547..32e869c0893 100644 --- a/sys/dev/usb/umodem_common.c +++ b/sys/dev/usb/umodem_common.c @@ -1,4 +1,4 @@ -/* $NetBSD: umodem_common.c,v 1.35 2021/08/07 16:19:17 thorpej Exp $ */ +/* $NetBSD: umodem_common.c,v 1.36 2022/07/31 13:01:16 mlelstv Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: umodem_common.c,v 1.35 2021/08/07 16:19:17 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umodem_common.c,v 1.36 2022/07/31 13:01:16 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -68,6 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: umodem_common.c,v 1.35 2021/08/07 16:19:17 thorpej E #include <dev/usb/usbdi.h> #include <dev/usb/usbdi_util.h> +#include <dev/usb/usbdivar.h> #include <dev/usb/usbdevs.h> #include <dev/usb/usb_quirks.h> @@ -260,6 +261,15 @@ umodem_common_attach(device_t self, struct umodem_softc *sc, ucaa->ucaa_iface = sc->sc_data_iface; ucaa->ucaa_arg = sc; + /* + * Each port takes two interfaces (control and data). + * + * If no port number is assigned by the specific driver, + * use the interface to compute a logical port number. + */ + if (ucaa->ucaa_portno == UCOM_UNK_PORTNO) + ucaa->ucaa_portno = uiaa->uiaa_iface->ui_index / 2; + usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); DPRINTF(("umodem_common_attach: sc=%p\n", sc)); |
