Commit 8f863428 authored by wengjianfeng's avatar wengjianfeng Committed by Kalle Valo

wilc1000: remove redundant code

Some of the code is redundant, so goto statements are used to remove them
Signed-off-by: default avatarwengjianfeng <wengjianfeng@yulong.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210705023731.31496-1-samirweng1979@163.com
parent 1d89fd1a
...@@ -1127,27 +1127,22 @@ int wilc_wlan_start(struct wilc *wilc) ...@@ -1127,27 +1127,22 @@ int wilc_wlan_start(struct wilc *wilc)
} }
acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
ret = wilc->hif_func->hif_write_reg(wilc, WILC_VMM_CORE_CFG, reg); ret = wilc->hif_func->hif_write_reg(wilc, WILC_VMM_CORE_CFG, reg);
if (ret) { if (ret)
release_bus(wilc, WILC_BUS_RELEASE_ONLY); goto release;
return ret;
}
reg = 0; reg = 0;
if (wilc->io_type == WILC_HIF_SDIO && wilc->dev_irq_num) if (wilc->io_type == WILC_HIF_SDIO && wilc->dev_irq_num)
reg |= WILC_HAVE_SDIO_IRQ_GPIO; reg |= WILC_HAVE_SDIO_IRQ_GPIO;
ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_1, reg); ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_1, reg);
if (ret) { if (ret)
release_bus(wilc, WILC_BUS_RELEASE_ONLY); goto release;
return ret;
}
wilc->hif_func->hif_sync_ext(wilc, NUM_INT_EXT); wilc->hif_func->hif_sync_ext(wilc, NUM_INT_EXT);
ret = wilc->hif_func->hif_read_reg(wilc, WILC_CHIPID, &chipid); ret = wilc->hif_func->hif_read_reg(wilc, WILC_CHIPID, &chipid);
if (ret) { if (ret)
release_bus(wilc, WILC_BUS_RELEASE_ONLY); goto release;
return ret;
}
wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, &reg); wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, &reg);
if ((reg & BIT(10)) == BIT(10)) { if ((reg & BIT(10)) == BIT(10)) {
...@@ -1159,8 +1154,9 @@ int wilc_wlan_start(struct wilc *wilc) ...@@ -1159,8 +1154,9 @@ int wilc_wlan_start(struct wilc *wilc)
reg |= BIT(10); reg |= BIT(10);
ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg); ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, &reg); wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, &reg);
release_bus(wilc, WILC_BUS_RELEASE_ONLY);
release:
release_bus(wilc, WILC_BUS_RELEASE_ONLY);
return ret; return ret;
} }
...@@ -1174,36 +1170,34 @@ int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif) ...@@ -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, &reg); ret = wilc->hif_func->hif_read_reg(wilc, WILC_GP_REG_0, &reg);
if (ret) { if (ret) {
netdev_err(vif->ndev, "Error while reading reg\n"); netdev_err(vif->ndev, "Error while reading reg\n");
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); goto release;
return ret;
} }
ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0, ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0,
(reg | WILC_ABORT_REQ_BIT)); (reg | WILC_ABORT_REQ_BIT));
if (ret) { if (ret) {
netdev_err(vif->ndev, "Error while writing reg\n"); netdev_err(vif->ndev, "Error while writing reg\n");
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); goto release;
return ret;
} }
ret = wilc->hif_func->hif_read_reg(wilc, WILC_FW_HOST_COMM, &reg); ret = wilc->hif_func->hif_read_reg(wilc, WILC_FW_HOST_COMM, &reg);
if (ret) { if (ret) {
netdev_err(vif->ndev, "Error while reading reg\n"); netdev_err(vif->ndev, "Error while reading reg\n");
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); goto release;
return ret;
} }
reg = BIT(0); reg = BIT(0);
ret = wilc->hif_func->hif_write_reg(wilc, WILC_FW_HOST_COMM, reg); ret = wilc->hif_func->hif_write_reg(wilc, WILC_FW_HOST_COMM, reg);
if (ret) { if (ret) {
netdev_err(vif->ndev, "Error while writing reg\n"); netdev_err(vif->ndev, "Error while writing reg\n");
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); goto release;
return ret;
} }
ret = 0;
release:
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
return 0; return ret;
} }
void wilc_wlan_cleanup(struct net_device *dev) void wilc_wlan_cleanup(struct net_device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment