usbdev: Use BOARD_USBDEV_SERIALSTR config directly

A usbdev has only one serial string, so use a unique macro to control it.

For boards that enable board serial string using COMPOSITE_BOARD_SERIALSTR,
PL2303_BOARD_SERIALSTR, CDCACM_BOARD_SERIALSTR, USBADB_BOARD_SERIALSTR,
USBMSC_BOARD_SERIALSTR, and RNDIS_BOARD_SERIALSTR, they need to be replaced
with BOARD_USBDEV_SERIALSTR.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
zhangyuan21 2023-08-25 14:49:45 +08:00 committed by Xiang Xiao
parent f5cdfa73dc
commit 06d9356d12
10 changed files with 25 additions and 72 deletions

View File

@ -4429,5 +4429,7 @@ config BOARDCTL_IOCTL
endif # BOARDCTL endif # BOARDCTL
config BOARD_USBDEV_SERIALSTR config BOARD_USBDEV_SERIALSTR
bool bool "Board-specific usbdev serial string"
default n default n
---help---
Use board unique serial number to iSerialNumber in the device descriptor.

View File

@ -227,17 +227,10 @@ config COMPOSITE_PRODUCTSTR
---help--- ---help---
The product ID code/string The product ID code/string
config COMPOSITE_BOARD_SERIALSTR
bool "Enable board unique ID to composite serial string"
default n
select BOARD_USBDEV_SERIALSTR
---help---
Use board unique serial number to iSerialNumber in the device descriptor.
config COMPOSITE_SERIALSTR config COMPOSITE_SERIALSTR
string "Composite serial string" string "Composite serial string"
default "001" default "001"
depends on !COMPOSITE_BOARD_SERIALSTR depends on !BOARD_USBDEV_SERIALSTR
---help--- ---help---
Device serial number string Device serial number string
@ -366,13 +359,6 @@ config PL2303_VENDORSTR
string "Vendor string" string "Vendor string"
default "NuttX" default "NuttX"
config PL2303_BOARD_SERIALSTR
bool "Enable board unique ID to PL2303 serial string"
default n
select BOARD_USBDEV_SERIALSTR
---help---
Use board unique serial number to iSerialNumber in the device descriptor.
config PL2303_PRODUCTSTR config PL2303_PRODUCTSTR
string "Product string" string "Product string"
default "PL2303 Emulation" default "PL2303 Emulation"
@ -598,13 +584,6 @@ config CDCACM_PRODUCTSTR
string "Product string" string "Product string"
default "CDC/ACM Serial" default "CDC/ACM Serial"
config CDCACM_BOARD_SERIALSTR
bool "Enable board unique ID to CDC/ACM serial string"
default n
select BOARD_USBDEV_SERIALSTR
---help---
Use board unique serial number to iSerialNumber in the device descriptor.
endif # !CDCACM_COMPOSITE endif # !CDCACM_COMPOSITE
endif # CDCACM endif # CDCACM
@ -723,17 +702,10 @@ config USBADB_PRODUCTSTR
string "Product string" string "Product string"
default "Debug Bridge" default "Debug Bridge"
config USBADB_BOARD_SERIALSTR
bool "Enable board unique ID to USBADB serial string"
default n
select BOARD_USBDEV_SERIALSTR
---help---
Use board unique serial number to iSerialNumber in the device descriptor.
config USBADB_SERIALSTR config USBADB_SERIALSTR
string "Serial string" string "Serial string"
default "1234" default "1234"
depends on !USBADB_BOARD_SERIALSTR depends on !BOARD_USBDEV_SERIALSTR
endif # !USBADB_COMPOSITE endif # !USBADB_COMPOSITE
@ -908,13 +880,6 @@ config USBMSC_PRODUCTSTR
string "Mass storage product string" string "Mass storage product string"
default "Mass Storage" default "Mass Storage"
config USBMSC_BOARD_SERIALSTR
bool "Enable board unique ID to mass storage serial string"
default n
select BOARD_USBDEV_SERIALSTR
---help---
Use board unique serial number to iSerialNumber in the device descriptor.
endif # !USBMSC_COMPOSITE endif # !USBMSC_COMPOSITE
config USBMSC_VERSIONNO config USBMSC_VERSIONNO
@ -1012,17 +977,10 @@ config RNDIS_PRODUCTSTR
string "RNDIS product string" string "RNDIS product string"
default "RNDIS gadget" default "RNDIS gadget"
config RNDIS_BOARD_SERIALSTR
bool "Enable board unique ID to RNDIS serial string"
default n
select BOARD_USBDEV_SERIALSTR
---help---
Use board unique serial number to iSerialNumber in the device descriptor.
config RNDIS_SERIALSTR config RNDIS_SERIALSTR
string "RNDIS serial string" string "RNDIS serial string"
default "1234" default "1234"
depends on !RNDIS_BOARD_SERIALSTR depends on !BOARD_USBDEV_SERIALSTR
config RNDIS_VERSIONNO config RNDIS_VERSIONNO
hex "RNDIS Version Number" hex "RNDIS Version Number"
@ -1249,13 +1207,6 @@ config CDCECM_PRODUCTSTR
string "Product string" string "Product string"
default "CDC/ECM Ethernet" default "CDC/ECM Ethernet"
config CDCECM_BOARD_SERIALSTR
bool "Enable board unique ID to CDC/ECM serial string"
default n
select BOARD_USBDEV_SERIALSTR
---help---
Use board unique serial number to iSerialNumber in the device descriptor.
endif # !CDCECM_COMPOSITE endif # !CDCECM_COMPOSITE
endif # CDCECM endif # CDCECM

View File

@ -40,7 +40,7 @@
#include <nuttx/usb/adb.h> #include <nuttx/usb/adb.h>
#include <nuttx/fs/fs.h> #include <nuttx/fs/fs.h>
#ifdef CONFIG_USBADB_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
#include <nuttx/board.h> #include <nuttx/board.h>
#endif #endif
@ -837,7 +837,7 @@ static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
break; break;
case USBADB_SERIALSTRID: case USBADB_SERIALSTRID:
#ifdef CONFIG_USBADB_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
str = board_usbdev_serialstr(); str = board_usbdev_serialstr();
#else #else
str = CONFIG_USBADB_SERIALSTR; str = CONFIG_USBADB_SERIALSTR;

View File

@ -36,7 +36,7 @@
#include <nuttx/usb/cdcacm.h> #include <nuttx/usb/cdcacm.h>
#include <nuttx/usb/usbdev_trace.h> #include <nuttx/usb/usbdev_trace.h>
#ifdef CONFIG_CDCACM_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
#include <nuttx/board.h> #include <nuttx/board.h>
#endif #endif
@ -148,7 +148,7 @@ int cdcacm_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
break; break;
case CDCACM_SERIALSTRID: case CDCACM_SERIALSTRID:
#ifdef CONFIG_CDCACM_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
str = board_usbdev_serialstr(); str = board_usbdev_serialstr();
#else #else
str = CONFIG_CDCACM_SERIALSTR; str = CONFIG_CDCACM_SERIALSTR;

View File

@ -54,7 +54,7 @@
# include <nuttx/net/pkt.h> # include <nuttx/net/pkt.h>
#endif #endif
#ifdef CONFIG_CDCECM_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
#include <nuttx/board.h> #include <nuttx/board.h>
#endif #endif
@ -1173,7 +1173,7 @@ static int cdcecm_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
break; break;
case CDCECM_SERIALSTRID: case CDCECM_SERIALSTRID:
#ifdef CONFIG_CDCECM_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
str = board_usbdev_serialstr(); str = board_usbdev_serialstr();
#else #else
str = "0"; str = "0";

View File

@ -32,7 +32,7 @@
#include <assert.h> #include <assert.h>
#include <debug.h> #include <debug.h>
#ifdef CONFIG_COMPOSITE_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
#include <nuttx/board.h> #include <nuttx/board.h>
#endif #endif
@ -183,7 +183,7 @@ static const struct usb_qualdesc_s g_qualdesc =
const char g_compvendorstr[] = CONFIG_COMPOSITE_VENDORSTR; const char g_compvendorstr[] = CONFIG_COMPOSITE_VENDORSTR;
const char g_compproductstr[] = CONFIG_COMPOSITE_PRODUCTSTR; const char g_compproductstr[] = CONFIG_COMPOSITE_PRODUCTSTR;
#ifndef CONFIG_COMPOSITE_BOARD_SERIALSTR #ifndef CONFIG_BOARD_USBDEV_SERIALSTR
const char g_compserialstr[] = CONFIG_COMPOSITE_SERIALSTR; const char g_compserialstr[] = CONFIG_COMPOSITE_SERIALSTR;
#endif #endif
@ -233,7 +233,7 @@ int composite_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
break; break;
case COMPOSITE_SERIALSTRID: case COMPOSITE_SERIALSTRID:
#ifdef CONFIG_COMPOSITE_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
str = board_usbdev_serialstr(); str = board_usbdev_serialstr();
#else #else
str = g_compserialstr; str = g_compserialstr;

View File

@ -48,7 +48,7 @@
#include <nuttx/usb/usbdev.h> #include <nuttx/usb/usbdev.h>
#include <nuttx/usb/usbdev_trace.h> #include <nuttx/usb/usbdev_trace.h>
#ifdef CONFIG_PL2303_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
#include <nuttx/board.h> #include <nuttx/board.h>
#endif #endif
@ -791,7 +791,7 @@ static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
break; break;
case PL2303_SERIALSTRID: case PL2303_SERIALSTRID:
#ifdef CONFIG_PL2303_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
str = board_usbdev_serialstr(); str = board_usbdev_serialstr();
#else #else
str = CONFIG_PL2303_SERIALSTR; str = CONFIG_PL2303_SERIALSTR;

View File

@ -50,7 +50,7 @@
#include <nuttx/usb/rndis.h> #include <nuttx/usb/rndis.h>
#include <nuttx/wqueue.h> #include <nuttx/wqueue.h>
#ifdef CONFIG_RNDIS_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
#include <nuttx/board.h> #include <nuttx/board.h>
#endif #endif
@ -1839,7 +1839,7 @@ static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
break; break;
case RNDIS_SERIALSTRID: case RNDIS_SERIALSTRID:
#ifdef CONFIG_RNDIS_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
str = board_usbdev_serialstr(); str = board_usbdev_serialstr();
#else #else
str = CONFIG_RNDIS_SERIALSTR; str = CONFIG_RNDIS_SERIALSTR;

View File

@ -458,7 +458,7 @@ extern "C"
#ifndef CONFIG_USBMSC_COMPOSITE #ifndef CONFIG_USBMSC_COMPOSITE
EXTERN const char g_mscvendorstr[]; EXTERN const char g_mscvendorstr[];
EXTERN const char g_mscproductstr[]; EXTERN const char g_mscproductstr[];
#ifndef CONFIG_USBMSC_BOARD_SERIALSTR #ifndef CONFIG_BOARD_USBDEV_SERIALSTR
EXTERN const char g_mscserialstr[]; EXTERN const char g_mscserialstr[];
#endif #endif
@ -469,13 +469,13 @@ EXTERN const char g_mscserialstr[];
#else #else
EXTERN const char g_compvendorstr[]; EXTERN const char g_compvendorstr[];
EXTERN const char g_compproductstr[]; EXTERN const char g_compproductstr[];
#ifndef CONFIG_COMPOSITE_BOARD_SERIALSTR #ifndef CONFIG_BOARD_USBDEV_SERIALSTR
EXTERN const char g_compserialstr[]; EXTERN const char g_compserialstr[];
#endif #endif
#define g_mscvendorstr g_compvendorstr #define g_mscvendorstr g_compvendorstr
#define g_mscproductstr g_compproductstr #define g_mscproductstr g_compproductstr
#ifndef CONFIG_USBMSC_BOARD_SERIALSTR #ifndef CONFIG_BOARD_USBDEV_SERIALSTR
#define g_mscserialstr g_compserialstr #define g_mscserialstr g_compserialstr
#endif #endif
#endif #endif

View File

@ -33,7 +33,7 @@
#include <nuttx/usb/usb.h> #include <nuttx/usb/usb.h>
#include <nuttx/usb/usbdev_trace.h> #include <nuttx/usb/usbdev_trace.h>
#ifdef CONFIG_USBMSC_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
#include <nuttx/board.h> #include <nuttx/board.h>
#endif #endif
@ -107,7 +107,7 @@ static const struct usb_qualdesc_s g_qualdesc =
#ifndef CONFIG_USBMSC_COMPOSITE #ifndef CONFIG_USBMSC_COMPOSITE
const char g_mscvendorstr[] = CONFIG_USBMSC_VENDORSTR; const char g_mscvendorstr[] = CONFIG_USBMSC_VENDORSTR;
const char g_mscproductstr[] = CONFIG_USBMSC_PRODUCTSTR; const char g_mscproductstr[] = CONFIG_USBMSC_PRODUCTSTR;
#ifndef CONFIG_USBMSC_BOARD_SERIALSTR #ifndef CONFIG_BOARD_USBDEV_SERIALSTR
const char g_mscserialstr[] = CONFIG_USBMSC_SERIALSTR; const char g_mscserialstr[] = CONFIG_USBMSC_SERIALSTR;
#endif #endif
#endif #endif
@ -159,7 +159,7 @@ int usbmsc_mkstrdesc(uint8_t id, struct FAR usb_strdesc_s *strdesc)
break; break;
case USBMSC_SERIALSTRID: case USBMSC_SERIALSTRID:
#ifdef CONFIG_USBMSC_BOARD_SERIALSTR #ifdef CONFIG_BOARD_USBDEV_SERIALSTR
str = board_usbdev_serialstr(); str = board_usbdev_serialstr();
#else #else
str = g_mscserialstr; str = g_mscserialstr;