public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* drivers/pci/hotplug/cpqphp_ctrl.c: board_replaced: dead code
@ 2005-03-22 20:59 Adrian Bunk
  2005-03-24 18:07 ` Rolf Eike Beer
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Bunk @ 2005-03-22 20:59 UTC (permalink / raw)
  To: greg; +Cc: linux-kernel, linux-pci

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.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: drivers/pci/hotplug/cpqphp_ctrl.c: board_replaced: dead code
  2005-03-22 20:59 drivers/pci/hotplug/cpqphp_ctrl.c: board_replaced: dead code Adrian Bunk
@ 2005-03-24 18:07 ` Rolf Eike Beer
  0 siblings, 0 replies; 2+ messages in thread
From: Rolf Eike Beer @ 2005-03-24 18:07 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: greg, linux-kernel, linux-pci, pcihpd-discuss

Adrian Bunk wrote:
> 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.

Yes, this is the only use of src in the whole function. If this is not a bug
than this patch removes all the dead code.

Eike

Signed-off-by: Rolf Eike Beer <eike-hotplug@sf-tec.de>

--- linux-2.6.11/drivers/pci/hotplug/cpqphp_ctrl.c	2005-03-02 08:37:55.000000000 +0100
+++ linux-2.6.12-rc1/drivers/pci/hotplug/cpqphp_ctrl.c	2005-03-24 19:01:23.000000000 +0100
@@ -1284,7 +1284,6 @@ static u32 board_replaced(struct pci_fun
 	u8 adapter_speed;
 	u32 index;
 	u32 rc = 0;
-	u32 src = 8;
 
 	hp_slot = func->device - ctrl->slot_device_offset;
 
@@ -1367,98 +1366,25 @@ static u32 board_replaced(struct pci_fun
 			/* It must be the same board */
 
 			rc = cpqhp_configure_board(ctrl, func);
+		}
+		/* If configuration fails, turn it off
+		 * Get slot won't work for devices behind
+		 * bridges, but in this case it will always be
+		 * called for the "base" bus/dev/func of an
+		 * adapter. */
 
-			if (rc || src) {
-				/* If configuration fails, turn it off
-				 * Get slot won't work for devices behind
-				 * bridges, but in this case it will always be
-				 * called for the "base" bus/dev/func of an
-				 * adapter. */
-
-				down(&ctrl->crit_sect);
-
-				amber_LED_on (ctrl, hp_slot);
-				green_LED_off (ctrl, hp_slot);
-				slot_disable (ctrl, hp_slot);
-
-				set_SOGO(ctrl);
-
-				/* Wait for SOBS to be unset */
-				wait_for_ctrl_irq (ctrl);
-
-				up(&ctrl->crit_sect);
-
-				if (rc)
-					return rc;
-				else
-					return 1;
-			}
-
-			func->status = 0;
-			func->switch_save = 0x10;
-
-			index = 1;
-			while (((func = cpqhp_slot_find(func->bus, func->device, index)) != NULL) && !rc) {
-				rc |= cpqhp_configure_board(ctrl, func);
-				index++;
-			}
-
-			if (rc) {
-				/* If configuration fails, turn it off
-				 * Get slot won't work for devices behind
-				 * bridges, but in this case it will always be
-				 * called for the "base" bus/dev/func of an
-				 * adapter. */
-
-				down(&ctrl->crit_sect);
-
-				amber_LED_on (ctrl, hp_slot);
-				green_LED_off (ctrl, hp_slot);
-				slot_disable (ctrl, hp_slot);
-
-				set_SOGO(ctrl);
-
-				/* Wait for SOBS to be unset */
-				wait_for_ctrl_irq (ctrl);
-
-				up(&ctrl->crit_sect);
-
-				return rc;
-			}
-			/* Done configuring so turn LED on full time */
-
-			down(&ctrl->crit_sect);
-
-			green_LED_on (ctrl, hp_slot);
-
-			set_SOGO(ctrl);
-
-			/* Wait for SOBS to be unset */
-			wait_for_ctrl_irq (ctrl);
-
-			up(&ctrl->crit_sect);
-			rc = 0;
-		} else {
-			/* Something is wrong
-
-			 * Get slot won't work for devices behind bridges, but
-			 * in this case it will always be called for the "base"
-			 * bus/dev/func of an adapter. */
-
-			down(&ctrl->crit_sect);
-
-			amber_LED_on (ctrl, hp_slot);
-			green_LED_off (ctrl, hp_slot);
-			slot_disable (ctrl, hp_slot);
+		down(&ctrl->crit_sect);
 
-			set_SOGO(ctrl);
+		amber_LED_on(ctrl, hp_slot);
+		green_LED_off(ctrl, hp_slot);
+		slot_disable(ctrl, hp_slot);
 
-			/* Wait for SOBS to be unset */
-			wait_for_ctrl_irq (ctrl);
+		set_SOGO(ctrl);
 
-			up(&ctrl->crit_sect);
-		}
+		/* Wait for SOBS to be unset */
+		wait_for_ctrl_irq(ctrl);
 
+		up(&ctrl->crit_sect);
 	}
 	return rc;
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-03-25 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-22 20:59 drivers/pci/hotplug/cpqphp_ctrl.c: board_replaced: dead code Adrian Bunk
2005-03-24 18:07 ` Rolf Eike Beer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox