Commit 39d0f1b0 authored by Ajay Singh's avatar Ajay Singh Committed by Kalle Valo

wifi: wilc1000: add 'isinit' flag for SDIO bus similar to SPI

Similar to SPI priv data, add 'isinit' variable in SDIO priv. Make use
of the state to invoke hif_init() once, and acquire the lock before
accessing hif function.
Signed-off-by: default avatarAjay Singh <ajay.kathat@microchip.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220720160302.231516-7-ajay.kathat@microchip.com
parent ad3e683a
...@@ -26,6 +26,7 @@ static const struct sdio_device_id wilc_sdio_ids[] = { ...@@ -26,6 +26,7 @@ static const struct sdio_device_id wilc_sdio_ids[] = {
struct wilc_sdio { struct wilc_sdio {
bool irq_gpio; bool irq_gpio;
u32 block_size; u32 block_size;
bool isinit;
int has_thrpt_enh3; int has_thrpt_enh3;
}; };
...@@ -193,6 +194,13 @@ static int wilc_sdio_reset(struct wilc *wilc) ...@@ -193,6 +194,13 @@ static int wilc_sdio_reset(struct wilc *wilc)
return 0; return 0;
} }
static bool wilc_sdio_is_init(struct wilc *wilc)
{
struct wilc_sdio *sdio_priv = wilc->bus_data;
return sdio_priv->isinit;
}
static int wilc_sdio_suspend(struct device *dev) static int wilc_sdio_suspend(struct device *dev)
{ {
struct sdio_func *func = dev_to_sdio_func(dev); struct sdio_func *func = dev_to_sdio_func(dev);
...@@ -581,6 +589,9 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size) ...@@ -581,6 +589,9 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
static int wilc_sdio_deinit(struct wilc *wilc) static int wilc_sdio_deinit(struct wilc *wilc)
{ {
struct wilc_sdio *sdio_priv = wilc->bus_data;
sdio_priv->isinit = false;
return 0; return 0;
} }
...@@ -700,6 +711,7 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume) ...@@ -700,6 +711,7 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume)
sdio_priv->has_thrpt_enh3); sdio_priv->has_thrpt_enh3);
} }
sdio_priv->isinit = true;
return 0; return 0;
} }
...@@ -981,6 +993,7 @@ static const struct wilc_hif_func wilc_hif_sdio = { ...@@ -981,6 +993,7 @@ static const struct wilc_hif_func wilc_hif_sdio = {
.enable_interrupt = wilc_sdio_enable_interrupt, .enable_interrupt = wilc_sdio_enable_interrupt,
.disable_interrupt = wilc_sdio_disable_interrupt, .disable_interrupt = wilc_sdio_disable_interrupt,
.hif_reset = wilc_sdio_reset, .hif_reset = wilc_sdio_reset,
.hif_is_init = wilc_sdio_is_init,
}; };
static int wilc_sdio_resume(struct device *dev) static int wilc_sdio_resume(struct device *dev)
......
...@@ -1029,6 +1029,13 @@ static int wilc_spi_reset(struct wilc *wilc) ...@@ -1029,6 +1029,13 @@ static int wilc_spi_reset(struct wilc *wilc)
return result; return result;
} }
static bool wilc_spi_is_init(struct wilc *wilc)
{
struct wilc_spi *spi_priv = wilc->bus_data;
return spi_priv->isinit;
}
static int wilc_spi_deinit(struct wilc *wilc) static int wilc_spi_deinit(struct wilc *wilc)
{ {
struct wilc_spi *spi_priv = wilc->bus_data; struct wilc_spi *spi_priv = wilc->bus_data;
...@@ -1250,4 +1257,5 @@ static const struct wilc_hif_func wilc_hif_spi = { ...@@ -1250,4 +1257,5 @@ static const struct wilc_hif_func wilc_hif_spi = {
.hif_block_rx_ext = wilc_spi_read, .hif_block_rx_ext = wilc_spi_read,
.hif_sync_ext = wilc_spi_sync_ext, .hif_sync_ext = wilc_spi_sync_ext,
.hif_reset = wilc_spi_reset, .hif_reset = wilc_spi_reset,
.hif_is_init = wilc_spi_is_init,
}; };
...@@ -1481,9 +1481,12 @@ int wilc_wlan_init(struct net_device *dev) ...@@ -1481,9 +1481,12 @@ int wilc_wlan_init(struct net_device *dev)
wilc->quit = 0; wilc->quit = 0;
if (wilc->hif_func->hif_init(wilc, false)) { if (!wilc->hif_func->hif_is_init(wilc)) {
ret = -EIO; acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
goto fail; ret = wilc->hif_func->hif_init(wilc, false);
release_bus(wilc, WILC_BUS_RELEASE_ONLY);
if (ret)
goto fail;
} }
if (!wilc->tx_buffer) if (!wilc->tx_buffer)
......
...@@ -373,6 +373,7 @@ struct wilc_hif_func { ...@@ -373,6 +373,7 @@ struct wilc_hif_func {
int (*enable_interrupt)(struct wilc *nic); int (*enable_interrupt)(struct wilc *nic);
void (*disable_interrupt)(struct wilc *nic); void (*disable_interrupt)(struct wilc *nic);
int (*hif_reset)(struct wilc *wilc); int (*hif_reset)(struct wilc *wilc);
bool (*hif_is_init)(struct wilc *wilc);
}; };
#define WILC_MAX_CFG_FRAME_SIZE 1468 #define WILC_MAX_CFG_FRAME_SIZE 1468
......
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