Skip to contentSkip to conversation

mmc: wbsd: remove redundant assignment to variable id and id check

PATCH In review Colin Ian King 2 participants 2 messages Feb 6, 2024 – Feb 13, 2024

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

PATCH v2 1/1 mmc: wbsd: remove redundant assignment to variable id and id check

The variable id is being initialized with a value that is never read, it is being re-assigned later on. The initialization is redundant and can be removed.

As noted by Ulf Hansson the unknown hardware check id != 0xFFFF is also redundant and can be removed too.

Cleans up clang scan build warning:
drivers/mmc/host/wbsd.c:1287:4: warning: Value stored to 'id' is never read [deadcode.DeadStores]

---
V2: As suggested by Ulf Hansson, also remove the redundant

    hardware check for id != 0xFFFF.
---
 drivers/mmc/host/wbsd.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/mmc/host/wbsd.c +0 -7
index 001a468bc149..4b32421d9f6d 100644
@@ -1284,8 +1284,6 @@ static int wbsd_scan(struct wbsd_host *host)
 			continue;
 
 		for (j = 0; j < ARRAY_SIZE(unlock_codes); j++) {
-			id = 0xFFFF;
-
 			host->config = config_ports[i];
 			host->unlock_code = unlock_codes[j];
 
@@ -1306,11 +1304,6 @@ static int wbsd_scan(struct wbsd_host *host)
 					return 0;
 				}
 			}
-
-			if (id != 0xFFFF) {
-				DBG("Unknown hardware (id %x) found at %x\n",
-					id, config_ports[i]);
-			}
 		}
 
 		release_region(config_ports[i], 2);
Signature · 1 line
2.39.2
#1 lore raw
Quoted 5 lines · Colin Ian King

The variable id is being initialized with a value that is never read, it is being re-assigned later on. The initialization is redundant and can be removed.

Quoted 8 lines

As noted by Ulf Hansson the unknown hardware check id != 0xFFFF is also redundant and can be removed too.

Cleans up clang scan build warning:
drivers/mmc/host/wbsd.c:1287:4: warning: Value stored to 'id' is never read [deadcode.DeadStores]

I had a second look and it's not entirely clear what the check if (id != 0xFFFF) is used for. Therefore, I suggest we simply keep that check, to be safe.

That said, I decided to pick your patch v1 for next, thanks!

Kind regards
Uffe

Quoted 35 lines

---
V2: As suggested by Ulf Hansson, also remove the redundant

    hardware check for id != 0xFFFF.
---
 drivers/mmc/host/wbsd.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/mmc/host/wbsd.c +0 -8
index 001a468bc149..4b32421d9f6d 100644
@@ -1284,8 +1284,6 @@ static int wbsd_scan(struct wbsd_host *host)
                        continue;
 
                for (j = 0; j < ARRAY_SIZE(unlock_codes); j++) {
-                       id = 0xFFFF;
-
                        host->config = config_ports[i];
                        host->unlock_code = unlock_codes[j];
 
@@ -1306,11 +1304,6 @@ static int wbsd_scan(struct wbsd_host *host)
                                        return 0;
                                }
                        }
-
-                       if (id != 0xFFFF) {
-                               DBG("Unknown hardware (id %x) found at %x\n",
-                                       id, config_ports[i]);
-                       }
                }
 
                release_region(config_ports[i], 2);
--

2.39.2