Skip to content

Commit

Permalink
wilc1000: Convert module-global "isinit" to device-specific variable
Browse files Browse the repository at this point in the history
Move static "isinit" variable to wilc_spi structure to allow multiple
WILC1000 devices per machine.

Signed-off-by: David Mosberger-Tang <davidm@egauge.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210828151346.3012697-1-davidm@egauge.net
  • Loading branch information
David Mosberger-Tang authored and Kalle Valo committed Aug 29, 2021
1 parent 4b51de0 commit 50cbbfd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/net/wireless/microchip/wilc1000/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ MODULE_PARM_DESC(enable_crc16,
#define WILC_SPI_RSP_HDR_EXTRA_DATA 8

struct wilc_spi {
bool isinit; /* true if SPI protocol has been configured */
bool probing_crc; /* true if we're probing chip's CRC config */
bool crc7_enabled; /* true if crc7 is currently enabled */
bool crc16_enabled; /* true if crc16 is currently enabled */
Expand Down Expand Up @@ -908,15 +909,15 @@ static int wilc_spi_init(struct wilc *wilc, bool resume)
struct wilc_spi *spi_priv = wilc->bus_data;
u32 reg;
u32 chipid;
static int isinit;
int ret, i;

if (isinit) {
if (spi_priv->isinit) {
/* Confirm we can read chipid register without error: */
ret = wilc_spi_read_reg(wilc, WILC_CHIPID, &chipid);
if (ret)
dev_err(&spi->dev, "Fail cmd read chip id...\n");
if (ret == 0)
return 0;

return ret;
dev_err(&spi->dev, "Fail cmd read chip id...\n");
}

/*
Expand Down Expand Up @@ -974,15 +975,15 @@ static int wilc_spi_init(struct wilc *wilc, bool resume)
spi_priv->probing_crc = false;

/*
* make sure can read back chip id correctly
* make sure can read chip id without protocol error
*/
ret = wilc_spi_read_reg(wilc, WILC_CHIPID, &chipid);
if (ret) {
dev_err(&spi->dev, "Fail cmd read chip id...\n");
return ret;
}

isinit = 1;
spi_priv->isinit = true;

return 0;
}
Expand Down

0 comments on commit 50cbbfd

Please sign in to comment.