[PATCH] wilc1000: remove redundant code
From: samirweng1979
Date: Sun Jul 04 2021 - 22:41:20 EST
From: wengjianfeng <wengjianfeng@xxxxxxxxxx>
Some of the code is redundant, so goto statements are used to remove them
Signed-off-by: wengjianfeng <wengjianfeng@xxxxxxxxxx>
---
drivers/net/wireless/microchip/wilc1000/wlan.c | 38 +++++++++++---------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index 2030fc7..200a103 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -1127,27 +1127,22 @@ int wilc_wlan_start(struct wilc *wilc)
}
acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
ret = wilc->hif_func->hif_write_reg(wilc, WILC_VMM_CORE_CFG, reg);
- if (ret) {
- release_bus(wilc, WILC_BUS_RELEASE_ONLY);
- return ret;
- }
+ if (ret)
+ goto release;
+
reg = 0;
if (wilc->io_type == WILC_HIF_SDIO && wilc->dev_irq_num)
reg |= WILC_HAVE_SDIO_IRQ_GPIO;
ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_1, reg);
- if (ret) {
- release_bus(wilc, WILC_BUS_RELEASE_ONLY);
- return ret;
- }
+ if (ret)
+ goto release;
wilc->hif_func->hif_sync_ext(wilc, NUM_INT_EXT);
ret = wilc->hif_func->hif_read_reg(wilc, WILC_CHIPID, &chipid);
- if (ret) {
- release_bus(wilc, WILC_BUS_RELEASE_ONLY);
- return ret;
- }
+ if (ret)
+ goto release;
wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
if ((reg & BIT(10)) == BIT(10)) {
@@ -1159,8 +1154,9 @@ int wilc_wlan_start(struct wilc *wilc)
reg |= BIT(10);
ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
- release_bus(wilc, WILC_BUS_RELEASE_ONLY);
+release:
+ release_bus(wilc, WILC_BUS_RELEASE_ONLY);
return ret;
}
@@ -1174,36 +1170,34 @@ int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif)
ret = wilc->hif_func->hif_read_reg(wilc, WILC_GP_REG_0, ®);
if (ret) {
netdev_err(vif->ndev, "Error while reading reg\n");
- release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
- return ret;
+ goto release;
}
ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0,
(reg | WILC_ABORT_REQ_BIT));
if (ret) {
netdev_err(vif->ndev, "Error while writing reg\n");
- release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
- return ret;
+ goto release;
}
ret = wilc->hif_func->hif_read_reg(wilc, WILC_FW_HOST_COMM, ®);
if (ret) {
netdev_err(vif->ndev, "Error while reading reg\n");
- release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
- return ret;
+ goto release;
}
reg = BIT(0);
ret = wilc->hif_func->hif_write_reg(wilc, WILC_FW_HOST_COMM, reg);
if (ret) {
netdev_err(vif->ndev, "Error while writing reg\n");
- release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
- return ret;
+ goto release;
}
+ ret = 0;
+release:
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
- return 0;
+ return ret;
}
void wilc_wlan_cleanup(struct net_device *dev)
--
1.9.1