From 18b7a87239ac483e52d86295d88aa88db3dada19 Mon Sep 17 00:00:00 2001 From: Gunjan Gupta Date: Sun, 3 Sep 2023 11:10:50 +0000 Subject: [PATCH 2/2] Fix issues when doing insmod/rmmod and reboot Based on https://github.com/fifteenhex/xradio/commit/428a46e4eab939a63c9173324304a540c4ca8ca3 https://github.com/fifteenhex/xradio/commit/bb2c7169a26835abe1e90edb92951a348c8a45 --- drivers/net/wireless/xradio/main.c | 2 ++ drivers/net/wireless/xradio/sdio.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/xradio/main.c b/drivers/net/wireless/xradio/main.c index f072629828a9..374b161bb498 100644 --- a/drivers/net/wireless/xradio/main.c +++ b/drivers/net/wireless/xradio/main.c @@ -616,6 +616,7 @@ int xradio_core_init(struct sdio_func* func) err2: /* err1: MRK: unused label*/ xradio_free_common(dev); + sdio_set_drvdata(func, NULL); return err; } @@ -628,6 +629,7 @@ void xradio_core_deinit(struct sdio_func* func) xradio_unregister_bh(hw_priv); xradio_pm_deinit(&hw_priv->pm_state); xradio_free_common(hw_priv->hw); + sdio_set_drvdata(func, NULL); } return; } diff --git a/drivers/net/wireless/xradio/sdio.c b/drivers/net/wireless/xradio/sdio.c index 6ef47a8c3202..e13f80828b41 100644 --- a/drivers/net/wireless/xradio/sdio.c +++ b/drivers/net/wireless/xradio/sdio.c @@ -203,17 +203,22 @@ static int sdio_probe(struct sdio_func *func, xradio_core_init(func); - try_module_get(func->dev.driver->owner); return 0; } /* Disconnect Function to be called by SDIO stack when * device is disconnected */ static void sdio_remove(struct sdio_func *func) { + struct mmc_card *card = func->card; + xradio_core_deinit(func); sdio_claim_host(func); sdio_disable_func(func); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)) + mmc_hw_reset(card); +#else + mmc_hw_reset(card->host); +#endif sdio_release_host(func); - module_put(func->dev.driver->owner); } static int sdio_suspend(struct device *dev) -- 2.34.1