Module Name: src Committed By: mlelstv Date: Sun Jul 31 13:01:17 UTC 2022
Modified Files: src/sys/dev/usb: umodem_common.c Log Message: Compute a unique port number from interface index. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/dev/usb/umodem_common.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/umodem_common.c diff -u src/sys/dev/usb/umodem_common.c:1.35 src/sys/dev/usb/umodem_common.c:1.36 --- src/sys/dev/usb/umodem_common.c:1.35 Sat Aug 7 16:19:17 2021 +++ src/sys/dev/usb/umodem_common.c Sun Jul 31 13:01:16 2022 @@ -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_commo #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, stru 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));