Commit 1305e9184a3de84f78dca102b293d21007bb6c49

Authored by Adrian Bunk
Committed by Greg Kroah-Hartman
1 parent 0cccd0c206

[PATCH] PCI: cpqphp_ctrl.c: board_replaced(): remove dead code

The Coverity checker correctly noted, that in function board_replaced in
drivers/pci/hotplug/cpqphp_ctrl.c, the variable src always has the
value 8, and therefore much code after the

...
                        if (rc || src) {
...
                                if (rc)
                                        return rc;
                                else
                                        return 1;
                        }
...

can never be called.

This patch removes the unreachable code in this function fixing kernel
Bugzilla #6073.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 1 changed file with 14 additions and 62 deletions Side-by-side Diff

drivers/pci/hotplug/cpqphp_ctrl.c
... ... @@ -1282,9 +1282,7 @@
1282 1282 u8 hp_slot;
1283 1283 u8 temp_byte;
1284 1284 u8 adapter_speed;
1285   - u32 index;
1286 1285 u32 rc = 0;
1287   - u32 src = 8;
1288 1286  
1289 1287 hp_slot = func->device - ctrl->slot_device_offset;
1290 1288  
1291 1289  
1292 1290  
... ... @@ -1368,68 +1366,17 @@
1368 1366  
1369 1367 rc = cpqhp_configure_board(ctrl, func);
1370 1368  
1371   - if (rc || src) {
1372   - /* If configuration fails, turn it off
1373   - * Get slot won't work for devices behind
1374   - * bridges, but in this case it will always be
1375   - * called for the "base" bus/dev/func of an
1376   - * adapter. */
  1369 + /* If configuration fails, turn it off
  1370 + * Get slot won't work for devices behind
  1371 + * bridges, but in this case it will always be
  1372 + * called for the "base" bus/dev/func of an
  1373 + * adapter. */
1377 1374  
1378   - mutex_lock(&ctrl->crit_sect);
1379   -
1380   - amber_LED_on (ctrl, hp_slot);
1381   - green_LED_off (ctrl, hp_slot);
1382   - slot_disable (ctrl, hp_slot);
1383   -
1384   - set_SOGO(ctrl);
1385   -
1386   - /* Wait for SOBS to be unset */
1387   - wait_for_ctrl_irq (ctrl);
1388   -
1389   - mutex_unlock(&ctrl->crit_sect);
1390   -
1391   - if (rc)
1392   - return rc;
1393   - else
1394   - return 1;
1395   - }
1396   -
1397   - func->status = 0;
1398   - func->switch_save = 0x10;
1399   -
1400   - index = 1;
1401   - while (((func = cpqhp_slot_find(func->bus, func->device, index)) != NULL) && !rc) {
1402   - rc |= cpqhp_configure_board(ctrl, func);
1403   - index++;
1404   - }
1405   -
1406   - if (rc) {
1407   - /* If configuration fails, turn it off
1408   - * Get slot won't work for devices behind
1409   - * bridges, but in this case it will always be
1410   - * called for the "base" bus/dev/func of an
1411   - * adapter. */
1412   -
1413   - mutex_lock(&ctrl->crit_sect);
1414   -
1415   - amber_LED_on (ctrl, hp_slot);
1416   - green_LED_off (ctrl, hp_slot);
1417   - slot_disable (ctrl, hp_slot);
1418   -
1419   - set_SOGO(ctrl);
1420   -
1421   - /* Wait for SOBS to be unset */
1422   - wait_for_ctrl_irq (ctrl);
1423   -
1424   - mutex_unlock(&ctrl->crit_sect);
1425   -
1426   - return rc;
1427   - }
1428   - /* Done configuring so turn LED on full time */
1429   -
1430 1375 mutex_lock(&ctrl->crit_sect);
1431 1376  
1432   - green_LED_on (ctrl, hp_slot);
  1377 + amber_LED_on (ctrl, hp_slot);
  1378 + green_LED_off (ctrl, hp_slot);
  1379 + slot_disable (ctrl, hp_slot);
1433 1380  
1434 1381 set_SOGO(ctrl);
1435 1382  
... ... @@ -1437,7 +1384,12 @@
1437 1384 wait_for_ctrl_irq (ctrl);
1438 1385  
1439 1386 mutex_unlock(&ctrl->crit_sect);
1440   - rc = 0;
  1387 +
  1388 + if (rc)
  1389 + return rc;
  1390 + else
  1391 + return 1;
  1392 +
1441 1393 } else {
1442 1394 /* Something is wrong
1443 1395