Skip to contentSkip to conversation

PCI: shpchp: Remove surplus variable and ineffectual error check

PATCH Applied Krzysztof Wilczynski 2 participants 2 messages May 21, 2020 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: shpchp: Remove surplus variable and ineffectual error check

Function remove_board() calls shpchp_unconfigure_device() and checks its return code for a possible error which is unnecessary as shpchp_unconfigure_device() always returns 0.

Also, remove surplus variable that has not been used for anything. This will also address the following Coccinelle warning:

drivers/pci/hotplug/shpchp_pci.c:66:5-7: Unneeded variable: "rc". Return "0" on line 86

---
 drivers/pci/hotplug/shpchp.h      | 2 +-
 drivers/pci/hotplug/shpchp_ctrl.c | 3 +--
 drivers/pci/hotplug/shpchp_pci.c  | 5 +----
 3 files changed, 3 insertions(+), 7 deletions(-)
drivers/pci/hotplug/shpchp.h +1 -1
index f7f13ee5d06e..6e85885b554c 100644
@@ -164,7 +164,7 @@ u8 shpchp_handle_switch_change(u8 hp_slot, struct controller *ctrl);
 u8 shpchp_handle_presence_change(u8 hp_slot, struct controller *ctrl);
 u8 shpchp_handle_power_fault(u8 hp_slot, struct controller *ctrl);
 int shpchp_configure_device(struct slot *p_slot);
-int shpchp_unconfigure_device(struct slot *p_slot);
+void shpchp_unconfigure_device(struct slot *p_slot);
 void cleanup_slots(struct controller *ctrl);
 void shpchp_queue_pushbutton_work(struct work_struct *work);
 int shpc_init(struct controller *ctrl, struct pci_dev *pdev);
drivers/pci/hotplug/shpchp_ctrl.c +1 -2
index 078003dcde5b..afdc52d1cae7 100644
@@ -341,8 +341,7 @@ static int remove_board(struct slot *p_slot)
 	u8 hp_slot;
 	int rc;
 
-	if (shpchp_unconfigure_device(p_slot))
-		return(1);
+	shpchp_unconfigure_device(p_slot);
 
 	hp_slot = p_slot->device - ctrl->slot_device_offset;
 	p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
drivers/pci/hotplug/shpchp_pci.c +1 -4
index 115701301487..36db0c3c4ea6 100644
@@ -61,9 +61,8 @@ int shpchp_configure_device(struct slot *p_slot)
 	return ret;
 }
 
-int shpchp_unconfigure_device(struct slot *p_slot)
+void shpchp_unconfigure_device(struct slot *p_slot)
 {
-	int rc = 0;
 	struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
 	struct pci_dev *dev, *temp;
 	struct controller *ctrl = p_slot->ctrl;
@@ -83,6 +82,4 @@ int shpchp_unconfigure_device(struct slot *p_slot)
 	}
 
 	pci_unlock_rescan_remove();
-	return rc;
 }
-
Signature · 1 line
2.26.2
#1 lore raw
Quoted 11 lines · Krzysztof Wilczynski

Function remove_board() calls shpchp_unconfigure_device() and checks its return code for a possible error which is unnecessary as shpchp_unconfigure_device() always returns 0.

Also, remove surplus variable that has not been used for anything. This will also address the following Coccinelle warning:

drivers/pci/hotplug/shpchp_pci.c:66:5-7: Unneeded variable: "rc". Return "0" on line 86

Applied to pci/hotplug for v5.8, thanks!

Quoted 58 lines
---
 drivers/pci/hotplug/shpchp.h      | 2 +-
 drivers/pci/hotplug/shpchp_ctrl.c | 3 +--
 drivers/pci/hotplug/shpchp_pci.c  | 5 +----
 3 files changed, 3 insertions(+), 7 deletions(-)
drivers/pci/hotplug/shpchp.h +1 -1
index f7f13ee5d06e..6e85885b554c 100644
@@ -164,7 +164,7 @@ u8 shpchp_handle_switch_change(u8 hp_slot, struct controller *ctrl);
 u8 shpchp_handle_presence_change(u8 hp_slot, struct controller *ctrl);
 u8 shpchp_handle_power_fault(u8 hp_slot, struct controller *ctrl);
 int shpchp_configure_device(struct slot *p_slot);
-int shpchp_unconfigure_device(struct slot *p_slot);
+void shpchp_unconfigure_device(struct slot *p_slot);
 void cleanup_slots(struct controller *ctrl);
 void shpchp_queue_pushbutton_work(struct work_struct *work);
 int shpc_init(struct controller *ctrl, struct pci_dev *pdev);
drivers/pci/hotplug/shpchp_ctrl.c +1 -2
index 078003dcde5b..afdc52d1cae7 100644
@@ -341,8 +341,7 @@ static int remove_board(struct slot *p_slot)
 	u8 hp_slot;
 	int rc;
 
-	if (shpchp_unconfigure_device(p_slot))
-		return(1);
+	shpchp_unconfigure_device(p_slot);
 
 	hp_slot = p_slot->device - ctrl->slot_device_offset;
 	p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
drivers/pci/hotplug/shpchp_pci.c +1 -4
index 115701301487..36db0c3c4ea6 100644
@@ -61,9 +61,8 @@ int shpchp_configure_device(struct slot *p_slot)
 	return ret;
 }
 
-int shpchp_unconfigure_device(struct slot *p_slot)
+void shpchp_unconfigure_device(struct slot *p_slot)
 {
-	int rc = 0;
 	struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
 	struct pci_dev *dev, *temp;
 	struct controller *ctrl = p_slot->ctrl;
@@ -83,6 +82,4 @@ int shpchp_unconfigure_device(struct slot *p_slot)
 	}
 
 	pci_unlock_rescan_remove();
-	return rc;
 }
-
Signature · 1 line
2.26.2