[U-Boot] [PATCH] sf: remove spi-flash chip names from SPL binary

Jagan Teki jagan at amarulasolutions.com
Fri Sep 28 17:20:41 UTC 2018


On Fri, Aug 17, 2018 at 12:23 PM Simon Goldschmidt
<simon.k.r.goldschmidt at gmail.com> wrote:
>
> The table of spi flash chips 'spi_flash_ids' currently
> includes chip names. The only usage of these is to
> print the name when the chip is probed.
>
> Since this message is not shown in SPL, we can remove
> the names from the SPL binary.
>
> Removing the chip names saves ~890 Byte from the SPL
> binary in my configuration (socfpga_socrates_defconfig,
> MACRONIX, SPANSION and STMICRO enabled).
>
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>
> ---
>
>  drivers/mtd/spi/sf_internal.h   |  10 ++
>  drivers/mtd/spi/spi_flash.c     |   7 +-
>  drivers/mtd/spi/spi_flash_ids.c | 270 +++++++++++++++++---------------
>  3 files changed, 156 insertions(+), 131 deletions(-)
>
> diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
> index 4f63cacc64..e5f91ca952 100644
> --- a/drivers/mtd/spi/sf_internal.h
> +++ b/drivers/mtd/spi/sf_internal.h
> @@ -113,9 +113,18 @@ int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len,
>  #define JEDEC_EXT(info)                (((info)->id[3]) << 8 | ((info)->id[4]))
>  #define SPI_FLASH_MAX_ID_LEN   6
>
> +/* Exclude chip names for SPL to save space */
> +#ifdef CONFIG_SPL_BUILD
> +#define SPI_FLASH_INCLUDE_NAME 0
> +#else
> +#define SPI_FLASH_INCLUDE_NAME 1

No need for extra macro, define macros wherever needed and expand SPL
and non-SPL?

> +#endif
> +
>  struct spi_flash_info {
> +#if SPI_FLASH_INCLUDE_NAME
>         /* Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO]) */
>         const char      *name;
> +#endif
>
>         /*
>          * This array stores the ID bytes.
> @@ -147,6 +156,7 @@ struct spi_flash_info {
>  };
>

[snip]

>         {},     /* Empty entry to terminate the list */
>         /*
> @@ -205,3 +213,5 @@ const struct spi_flash_info spi_flash_ids[] = {
>          * (w25q256fw, w25q256fv_qpi)
>          */
>  };
> +
> +const size_t spi_flash_ids_size = ARRAY_SIZE(spi_flash_ids);

Check array size directly in for loop.


More information about the U-Boot mailing list