From 139d4be7285a14b6b2321c3cd01ac88cb031f9cf Mon Sep 17 00:00:00 2001 From: mlelstv Date: Sun, 31 Jul 2022 13:01:16 +0000 Subject: Compute a unique port number from interface index. --- sys/dev/usb/umodem_common.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'sys/dev') 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 -__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 #include +#include #include #include @@ -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)); -- cgit