ret = wilc_cfg80211_init(&wilc, &func->dev, WILC_HIF_SDIO,
&wilc_hif_sdio);
- if (ret) {
- kfree(sdio_priv);
- return ret;
- }
+ if (ret)
+ goto free;
if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
struct device_node *np = func->card->dev.of_node;
wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc");
if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) {
- kfree(sdio_priv);
- return -EPROBE_DEFER;
+ ret = -EPROBE_DEFER;
+ goto netdev_cleanup;
} else if (!IS_ERR(wilc->rtc_clk))
clk_prepare_enable(wilc->rtc_clk);
dev_info(&func->dev, "Driver Initializing success\n");
return 0;
+
+netdev_cleanup:
+ wilc_netdev_cleanup(wilc);
+free:
+ kfree(sdio_priv);
+ return ret;
}
static void wilc_sdio_remove(struct sdio_func *func)
return -ENOMEM;
ret = wilc_cfg80211_init(&wilc, &spi->dev, WILC_HIF_SPI, &wilc_hif_spi);
- if (ret) {
- kfree(spi_priv);
- return ret;
- }
+ if (ret)
+ goto free;
spi_set_drvdata(spi, wilc);
wilc->dev = &spi->dev;
wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc");
if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) {
- kfree(spi_priv);
- return -EPROBE_DEFER;
+ ret = -EPROBE_DEFER;
+ goto netdev_cleanup;
} else if (!IS_ERR(wilc->rtc_clk))
clk_prepare_enable(wilc->rtc_clk);
return 0;
+
+netdev_cleanup:
+ wilc_netdev_cleanup(wilc);
+free:
+ kfree(spi_priv);
+ return ret;
}
static int wilc_bus_remove(struct spi_device *spi)