Skip to contentSkip to conversation

Cleanup of -Wunused-const-variable in drivers/usb/host/xhci-tegra.c

PATCH In review Nathan Huckleberry 4 participants 5 messages Jun 13, 2019 – Jun 14, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hey all,

I'm looking into cleaning up ignored warnings in the kernel so we can remove compiler flags to ignore warnings.

There's an unused variable ('mbox_cmd_name') in xhci-tegra.c. Looks like it was intended for logging or debugging, but never used. Just wanted to reach out to ask the best steps for cleaning this up.

If the variable is no longer needed I'd like to send a patch to remove it.

https://github.com/ClangBuiltLinux/linux/issues/533

Thanks,
Nathan Huckleberry

maintainer
#1 lore raw
Quoted 10 lines · Nathan Huckleberry

Hey all,

I'm looking into cleaning up ignored warnings in the kernel so we can remove compiler flags to ignore warnings.

There's an unused variable ('mbox_cmd_name') in xhci-tegra.c. Looks like it was intended for logging or debugging, but never used. Just wanted to reach out to ask the best steps for cleaning this up.

If the variable is no longer needed I'd like to send a patch to remove it.

You never have to ask permission to send a patch :)

#2 lore raw

PATCH 1/1 usb: host: xhci-tegra: Fix Wunused-const-variable

Clang produces the following warning

drivers/usb/host/xhci-tegra.c:357:27: warning: unused variable 'mbox_cmd_name' [-Wunused-const-variable]
static const char * const mbox_cmd_name[] = {

Looks like it was intended for logging or debugging, but was never implemented. Removing mbox_cmd_name.

---
 drivers/usb/host/xhci-tegra.c | 23 -----------------------
 1 file changed, 23 deletions(-)
drivers/usb/host/xhci-tegra.c +0 -23
index 294158113d62..dafc65911fc0 100644
@@ -354,29 +354,6 @@ enum tegra_xusb_mbox_cmd {
 	MBOX_CMD_NAK
 };
 
-static const char * const mbox_cmd_name[] = {
-	[  1] = "MSG_ENABLE",
-	[  2] = "INC_FALCON_CLOCK",
-	[  3] = "DEC_FALCON_CLOCK",
-	[  4] = "INC_SSPI_CLOCK",
-	[  5] = "DEC_SSPI_CLOCK",
-	[  6] = "SET_BW",
-	[  7] = "SET_SS_PWR_GATING",
-	[  8] = "SET_SS_PWR_UNGATING",
-	[  9] = "SAVE_DFE_CTLE_CTX",
-	[ 10] = "AIRPLANE_MODE_ENABLED",
-	[ 11] = "AIRPLANE_MODE_DISABLED",
-	[ 12] = "START_HSIC_IDLE",
-	[ 13] = "STOP_HSIC_IDLE",
-	[ 14] = "DBC_WAKE_STACK",
-	[ 15] = "HSIC_PRETEND_CONNECT",
-	[ 16] = "RESET_SSPI",
-	[ 17] = "DISABLE_SS_LFPS_DETECTION",
-	[ 18] = "ENABLE_SS_LFPS_DETECTION",
-	[128] = "ACK",
-	[129] = "NAK",
-};
-
 struct tegra_xusb_mbox_msg {
 	u32 cmd;
 	u32 data;
Signature · 1 line
2.22.0.rc2.383.gf4fbbf30c2-goog
Acked-by on v1 1/1
#3 lore raw

Re: [PATCH] usb: host: xhci-tegra: Fix Wunused-const-variable

Quoted 9 lines · Nathan Huckleberry

Clang produces the following warning

drivers/usb/host/xhci-tegra.c:357:27: warning: unused variable 'mbox_cmd_name' [-Wunused-const-variable]
static const char * const mbox_cmd_name[] = {

Looks like it was intended for logging or debugging, but was never implemented. Removing mbox_cmd_name.

Quoted 6 lines
---
 drivers/usb/host/xhci-tegra.c | 23 -----------------------
 1 file changed, 23 deletions(-)

I wonder why we're not seeing this with regular GCC builds. This code has been in the kernel for a long time. Oh... looking at the git log, I see that -Wunused-const-variable was moved to W=1 about 3 years ago, so these are no longer showing up by default. That would explain it.

Anyway:

Quoted 37 lines
drivers/usb/host/xhci-tegra.c +0 -23
index 294158113d62..dafc65911fc0 100644
@@ -354,29 +354,6 @@ enum tegra_xusb_mbox_cmd {
 	MBOX_CMD_NAK
 };
 
-static const char * const mbox_cmd_name[] = {
-	[  1] = "MSG_ENABLE",
-	[  2] = "INC_FALCON_CLOCK",
-	[  3] = "DEC_FALCON_CLOCK",
-	[  4] = "INC_SSPI_CLOCK",
-	[  5] = "DEC_SSPI_CLOCK",
-	[  6] = "SET_BW",
-	[  7] = "SET_SS_PWR_GATING",
-	[  8] = "SET_SS_PWR_UNGATING",
-	[  9] = "SAVE_DFE_CTLE_CTX",
-	[ 10] = "AIRPLANE_MODE_ENABLED",
-	[ 11] = "AIRPLANE_MODE_DISABLED",
-	[ 12] = "START_HSIC_IDLE",
-	[ 13] = "STOP_HSIC_IDLE",
-	[ 14] = "DBC_WAKE_STACK",
-	[ 15] = "HSIC_PRETEND_CONNECT",
-	[ 16] = "RESET_SSPI",
-	[ 17] = "DISABLE_SS_LFPS_DETECTION",
-	[ 18] = "ENABLE_SS_LFPS_DETECTION",
-	[128] = "ACK",
-	[129] = "NAK",
-};
-
 struct tegra_xusb_mbox_msg {
 	u32 cmd;
 	u32 data;
Signature · 1 line
2.22.0.rc2.383.gf4fbbf30c2-goog
#4 lore raw
In reply to Nathan Huckleberry
Quoted 5 lines · Nathan Huckleberry

Hey all,

I'm looking into cleaning up ignored warnings in the kernel so we can remove compiler flags to ignore warnings.

Quoted 7 lines

There's an unused variable ('mbox_cmd_name') in xhci-tegra.c. Looks like it was intended for logging or debugging, but never used. Just wanted to reach out to ask the best steps for cleaning this up.

If the variable is no longer needed I'd like to send a patch to remove it.

https://github.com/ClangBuiltLinux/linux/issues/533

Feel free to send that patch. If we ever need this debug information again we can easily add it back by reverting.

Thierry