qca: spi-nor: Store the probe information to avoid unnecessary probes

Change-Id: If7260e4a4065d6406d9a8554f43853663f0e8f3b
Signed-off-by: Santan Kumar <santank@codeaurora.org>
This commit is contained in:
Santan Kumar 2018-02-07 18:29:52 +05:30
parent 66f395836e
commit a0dd6f4332
4 changed files with 19 additions and 9 deletions

View file

@ -135,8 +135,7 @@ static int do_spi_flash_probe(int argc, char * const argv[])
flash = dev_get_uclass_priv(new);
#else
if (flash)
spi_flash_free(flash);
spi_flash_free(flash);
new = spi_flash_probe(bus, cs, speed, mode);
flash = new;

View file

@ -214,8 +214,6 @@ void sf_env_relocate_spec(void)
}
err_read:
spi_flash_free(env_flash);
env_flash = NULL;
out:
free(tmp_env1);
free(tmp_env2);
@ -316,7 +314,6 @@ void sf_env_relocate_spec(void)
if (ret)
gd->env_valid = 1;
out:
spi_flash_free(env_flash);
if (buf)
free(buf);
env_flash = NULL;

View file

@ -17,6 +17,8 @@
#include "sf_internal.h"
struct spi_flash *spi_flash_ptr[MAX_SF_BUS_NUM][MAX_SF_CS_NUM] = {NULL};
/**
* spi_flash_probe_slave() - Probe for a SPI flash device on a bus
*
@ -83,10 +85,16 @@ struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
{
struct spi_slave *bus;
if (spi_flash_ptr[busnum][cs] != NULL)
return spi_flash_ptr[busnum][cs];
bus = spi_setup_slave(busnum, cs, max_hz, spi_mode);
if (!bus)
return NULL;
return spi_flash_probe_tail(bus);
spi_flash_ptr[busnum][cs] = spi_flash_probe_tail(bus);
return spi_flash_ptr[busnum][cs];
}
#ifdef CONFIG_OF_SPI_FLASH
@ -104,11 +112,15 @@ struct spi_flash *spi_flash_probe_fdt(const void *blob, int slave_node,
void spi_flash_free(struct spi_flash *flash)
{
if (flash) {
#ifdef CONFIG_SPI_FLASH_MTD
spi_flash_mtd_unregister();
spi_flash_mtd_unregister();
#endif
spi_free_slave(flash->spi);
free(flash);
spi_free_slave(flash->spi);
free(flash);
}
memset(spi_flash_ptr, NULL, sizeof(spi_flash_ptr));
}
#else /* defined CONFIG_DM_SPI_FLASH */

View file

@ -30,6 +30,8 @@
#ifndef CONFIG_SF_DEFAULT_BUS
# define CONFIG_SF_DEFAULT_BUS 0
#endif
#define MAX_SF_BUS_NUM 5
#define MAX_SF_CS_NUM 5
struct spi_slave;