diff options
Diffstat (limited to 'drivers/net/sfc/falcon.c')
-rw-r--r-- | drivers/net/sfc/falcon.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c index 31ed1f49de00..71e0bed60616 100644 --- a/drivers/net/sfc/falcon.c +++ b/drivers/net/sfc/falcon.c | |||
@@ -1628,9 +1628,9 @@ static int falcon_spi_wait(struct efx_nic *efx) | |||
1628 | } | 1628 | } |
1629 | } | 1629 | } |
1630 | 1630 | ||
1631 | static int falcon_spi_cmd(const struct efx_spi_device *spi, | 1631 | int falcon_spi_cmd(const struct efx_spi_device *spi, |
1632 | unsigned int command, int address, | 1632 | unsigned int command, int address, |
1633 | const void *in, void *out, unsigned int len) | 1633 | const void *in, void *out, unsigned int len) |
1634 | { | 1634 | { |
1635 | struct efx_nic *efx = spi->efx; | 1635 | struct efx_nic *efx = spi->efx; |
1636 | bool addressed = (address >= 0); | 1636 | bool addressed = (address >= 0); |
@@ -1641,6 +1641,7 @@ static int falcon_spi_cmd(const struct efx_spi_device *spi, | |||
1641 | /* Input validation */ | 1641 | /* Input validation */ |
1642 | if (len > FALCON_SPI_MAX_LEN) | 1642 | if (len > FALCON_SPI_MAX_LEN) |
1643 | return -EINVAL; | 1643 | return -EINVAL; |
1644 | BUG_ON(!mutex_is_locked(&efx->spi_lock)); | ||
1644 | 1645 | ||
1645 | /* Check SPI not currently being accessed */ | 1646 | /* Check SPI not currently being accessed */ |
1646 | rc = falcon_spi_wait(efx); | 1647 | rc = falcon_spi_wait(efx); |
@@ -1699,8 +1700,7 @@ efx_spi_munge_command(const struct efx_spi_device *spi, | |||
1699 | return command | (((address >> 8) & spi->munge_address) << 3); | 1700 | return command | (((address >> 8) & spi->munge_address) << 3); |
1700 | } | 1701 | } |
1701 | 1702 | ||
1702 | 1703 | int falcon_spi_fast_wait(const struct efx_spi_device *spi) | |
1703 | static int falcon_spi_fast_wait(const struct efx_spi_device *spi) | ||
1704 | { | 1704 | { |
1705 | u8 status; | 1705 | u8 status; |
1706 | int i, rc; | 1706 | int i, rc; |
@@ -2253,13 +2253,15 @@ int falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out) | |||
2253 | __le16 *word, *limit; | 2253 | __le16 *word, *limit; |
2254 | u32 csum; | 2254 | u32 csum; |
2255 | 2255 | ||
2256 | region = kmalloc(NVCONFIG_END, GFP_KERNEL); | 2256 | region = kmalloc(FALCON_NVCONFIG_END, GFP_KERNEL); |
2257 | if (!region) | 2257 | if (!region) |
2258 | return -ENOMEM; | 2258 | return -ENOMEM; |
2259 | nvconfig = region + NVCONFIG_OFFSET; | 2259 | nvconfig = region + NVCONFIG_OFFSET; |
2260 | 2260 | ||
2261 | spi = efx->spi_flash ? efx->spi_flash : efx->spi_eeprom; | 2261 | spi = efx->spi_flash ? efx->spi_flash : efx->spi_eeprom; |
2262 | rc = falcon_spi_read(spi, 0, NVCONFIG_END, NULL, region); | 2262 | mutex_lock(&efx->spi_lock); |
2263 | rc = falcon_spi_read(spi, 0, FALCON_NVCONFIG_END, NULL, region); | ||
2264 | mutex_unlock(&efx->spi_lock); | ||
2263 | if (rc) { | 2265 | if (rc) { |
2264 | EFX_ERR(efx, "Failed to read %s\n", | 2266 | EFX_ERR(efx, "Failed to read %s\n", |
2265 | efx->spi_flash ? "flash" : "EEPROM"); | 2267 | efx->spi_flash ? "flash" : "EEPROM"); |
@@ -2283,7 +2285,7 @@ int falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out) | |||
2283 | limit = (__le16 *) (nvconfig + 1); | 2285 | limit = (__le16 *) (nvconfig + 1); |
2284 | } else { | 2286 | } else { |
2285 | word = region; | 2287 | word = region; |
2286 | limit = region + NVCONFIG_END; | 2288 | limit = region + FALCON_NVCONFIG_END; |
2287 | } | 2289 | } |
2288 | for (csum = 0; word < limit; ++word) | 2290 | for (csum = 0; word < limit; ++word) |
2289 | csum += le16_to_cpu(*word); | 2291 | csum += le16_to_cpu(*word); |
@@ -2555,6 +2557,11 @@ static int falcon_spi_device_init(struct efx_nic *efx, | |||
2555 | SPI_DEV_TYPE_FIELD(device_type, SPI_DEV_TYPE_ADDR_LEN); | 2557 | SPI_DEV_TYPE_FIELD(device_type, SPI_DEV_TYPE_ADDR_LEN); |
2556 | spi_device->munge_address = (spi_device->size == 1 << 9 && | 2558 | spi_device->munge_address = (spi_device->size == 1 << 9 && |
2557 | spi_device->addr_len == 1); | 2559 | spi_device->addr_len == 1); |
2560 | spi_device->erase_command = | ||
2561 | SPI_DEV_TYPE_FIELD(device_type, SPI_DEV_TYPE_ERASE_CMD); | ||
2562 | spi_device->erase_size = | ||
2563 | 1 << SPI_DEV_TYPE_FIELD(device_type, | ||
2564 | SPI_DEV_TYPE_ERASE_SIZE); | ||
2558 | spi_device->block_size = | 2565 | spi_device->block_size = |
2559 | 1 << SPI_DEV_TYPE_FIELD(device_type, | 2566 | 1 << SPI_DEV_TYPE_FIELD(device_type, |
2560 | SPI_DEV_TYPE_BLOCK_SIZE); | 2567 | SPI_DEV_TYPE_BLOCK_SIZE); |