[SLOF] [PATCH 1/4] usb: Move XHCI port state arrays from header to .c file

Thomas Huth thuth at redhat.com
Tue Aug 2 07:50:26 AEST 2016


Arrays should not be declared in a header (to avoid that it gets
declared multiple times when the header is included more than once),
so the ps_array_usbX settings should reside in the .c file instead.

Signed-off-by: Thomas Huth <thuth at redhat.com>
---
 lib/libusb/usb-xhci.c | 17 +++++++++++++++++
 lib/libusb/usb-xhci.h | 18 ------------------
 2 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/lib/libusb/usb-xhci.c b/lib/libusb/usb-xhci.c
index a3e9adc..b59fd40 100644
--- a/lib/libusb/usb-xhci.c
+++ b/lib/libusb/usb-xhci.c
@@ -25,6 +25,23 @@
 #define dprintf(_x ...)
 #endif
 
+struct port_state ps_array_usb2[] = {
+	{1, 0, 0, 0, PORTSC_PLS_U0, "ERROR"}
+};
+
+struct port_state ps_array_usb3[] = {
+	{0, 0, 0, 0, PORTSC_PLS_DISABLED, "Powered-OFF"},
+	{1, 0, 0, 0, PORTSC_PLS_POLLING,  "Polling"},
+	{1, 0, 0, 0, PORTSC_PLS_U0,       "Polling"},
+	{1, 0, 0, 0, PORTSC_PLS_RXDETECT, "***  Disconnected ***"},
+	{1, 0, 0, 0, PORTSC_PLS_DISABLED, "Disabled"},
+	{1, 0, 0, 0, PORTSC_PLS_INACTIVE, "Error"},
+	{1, 0, 0, 0, PORTSC_PLS_TEST_MODE,"Loopback"},
+	{1, 0, 0, 0, PORTSC_PLS_COMP_MODE,"Compliancek"},
+	{1, 1, 0, 1, PORTSC_PLS_U0,       "******  Reset  ******"},
+	{1, 1, 1, 0, PORTSC_PLS_U0,       "****** Enabled ******"},
+};
+
 static void dump_xhci_regs(struct xhci_hcd *xhcd)
 {
 #ifdef XHCI_DEBUG
diff --git a/lib/libusb/usb-xhci.h b/lib/libusb/usb-xhci.h
index 8172a37..b02fcbf 100644
--- a/lib/libusb/usb-xhci.h
+++ b/lib/libusb/usb-xhci.h
@@ -101,24 +101,6 @@ struct port_state {
 	char *state;
 };
 
-
-struct port_state ps_array_usb2[] = {
-	{1, 0, 0, 0, PORTSC_PLS_U0, "ERROR"}
-};
-
-struct port_state ps_array_usb3[] = {
-	{0, 0, 0, 0, PORTSC_PLS_DISABLED, "Powered-OFF"},
-	{1, 0, 0, 0, PORTSC_PLS_POLLING,  "Polling"},
-	{1, 0, 0, 0, PORTSC_PLS_U0,       "Polling"},
-	{1, 0, 0, 0, PORTSC_PLS_RXDETECT, "***  Disconnected ***"},
-	{1, 0, 0, 0, PORTSC_PLS_DISABLED, "Disabled"},
-	{1, 0, 0, 0, PORTSC_PLS_INACTIVE, "Error"},
-	{1, 0, 0, 0, PORTSC_PLS_TEST_MODE,"Loopback"},
-	{1, 0, 0, 0, PORTSC_PLS_COMP_MODE,"Compliancek"},
-	{1, 1, 0, 1, PORTSC_PLS_U0,       "******  Reset  ******"},
-	{1, 1, 1, 0, PORTSC_PLS_U0,       "****** Enabled ******"},
-};
-
 /* 5.4 Host Controller Operational Registers
  * Table 26
  */
-- 
1.8.3.1



More information about the SLOF mailing list