From 10f1d3e76e63c8d61a0a3631b53ef39d1a5bf222 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Tue, 21 Mar 2023 12:16:44 +0100 Subject: [PATCH] rndis: fix dev info init for composite --- drivers/usbdev/rndis.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/usbdev/rndis.c b/drivers/usbdev/rndis.c index afc3c78573..840ce5a82a 100644 --- a/drivers/usbdev/rndis.c +++ b/drivers/usbdev/rndis.c @@ -87,6 +87,7 @@ static_assert((CONFIG_NET_LL_GUARDSIZE % 4) == 2, #define RNDIS_CONFIGID (1) #define RNDIS_CONFIGIDNONE (0) #define RNDIS_NINTERFACES (2) +#define RNDIS_NSTRIDS (0) #define RNDIS_EPINTIN_ADDR USB_EPIN(CONFIG_RNDIS_EPINTIN) #define RNDIS_EPBULKIN_ADDR USB_EPIN(CONFIG_RNDIS_EPBULKIN) @@ -2847,13 +2848,9 @@ static int usbclass_classobject(int minor, drvr = &alloc->drvr; *classdev = &drvr->drvr; -#ifdef CONFIG_RNDIS_COMPOSITE - priv->devinfo = *devinfo; -#else - priv->devinfo.epno[RNDIS_EP_INTIN_IDX] = USB_EPNO(RNDIS_EPINTIN_ADDR); - priv->devinfo.epno[RNDIS_EP_BULKIN_IDX] = USB_EPNO(RNDIS_EPBULKIN_ADDR); - priv->devinfo.epno[RNDIS_EP_BULKOUT_IDX] = USB_EPNO(RNDIS_EPBULKOUT_ADDR); -#endif + /* Get device info */ + + memcpy(&priv->devinfo, devinfo, sizeof(struct usbdev_devinfo_s)); /* Initialize the USB ethernet driver structure */ @@ -2935,8 +2932,17 @@ int usbdev_rndis_initialize(FAR const uint8_t *mac_address) int ret; FAR struct usbdevclass_driver_s *classdev; FAR struct rndis_driver_s *drvr; + struct usbdev_devinfo_s devinfo; - ret = usbclass_classobject(0, NULL, &classdev); + memset(&devinfo, 0, sizeof(struct usbdev_devinfo_s)); + devinfo.ninterfaces = RNDIS_NINTERFACES; + devinfo.nstrings = RNDIS_NSTRIDS; + devinfo.nendpoints = RNDIS_NUM_EPS; + devinfo.epno[RNDIS_EP_INTIN_IDX] = CONFIG_RNDIS_EPINTIN; + devinfo.epno[RNDIS_EP_BULKIN_IDX] = CONFIG_RNDIS_EPBULKIN; + devinfo.epno[RNDIS_EP_BULKOUT_IDX] = CONFIG_RNDIS_EPBULKOUT; + + ret = usbclass_classobject(0, &devinfo, &classdev); if (ret) { nerr("usbclass_classobject failed: %d\n", ret);