From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Neil Armstrong <neil.armstrong@linaro.org>,
Lukasz Majewski <lukma@denx.de>, Tom Rini <trini@konsulko.com>,
Jagan Teki <jagan@amarulasolutions.com>,
Vignesh R <vigneshr@ti.com>
Cc: u-boot@lists.denx.de, Neil Armstrong <neil.armstrong@linaro.org>
Subject: Re: [PATCH v2 1/2] spi: add DM_SPI_FLASH compatibility inline functions
Date: Wed, 02 Oct 2024 09:29:22 +0200 [thread overview]
Message-ID: <8734lfm08d.fsf@baylibre.com> (raw)
In-Reply-To: <20241001-uboot-topic-dfu-sf-dt-v2-1-67f7acfa3ff5@linaro.org>
Hi Neil,
Thank you for the patch.
On mar., oct. 01, 2024 at 18:06, Neil Armstrong <neil.armstrong@linaro.org> wrote:
> To smoothly handle the transition from the legacy SPI FLASH
> API to the the driver model API, add the DM functions
> as dummy inline functions.
>
> Today, client code uses #if/#else conditionals, but it's better
> to use if(IS_ENABLED()) to make sure all code builds fine
> and avoid configuration hell, leaving the compiler remove
> the dead code.
>
> An example is cmd/sf, which could make use of those dummy
> functions to drop the conditional compilation.
>
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> ---
> include/spi_flash.h | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/include/spi_flash.h b/include/spi_flash.h
> index 10d19fd4b11..2e703e85250 100644
> --- a/include/spi_flash.h
> +++ b/include/spi_flash.h
> @@ -139,6 +139,40 @@ int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs,
> void sandbox_sf_unbind_emul(struct sandbox_state *state, int busnum, int cs);
>
> #else
> +/* Compatibility functions for when DM_SPI_FLASH is disabled */
> +static inline int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
> + struct udevice **devp)
> +{
> + return -ENODEV;
> +}
> +
> +static inline int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len,
> + void *buf)
> +{
> + return -ENODEV;
> +}
> +
> +static inline int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
> + const void *buf)
> +{
> + return -ENODEV;
> +}
> +
> +static inline int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len)
> +{
> + return -ENODEV;
> +}
> +
> +static inline int spl_flash_get_sw_write_prot(struct udevice *dev)
> +{
> + return -ENODEV;
> +}
> +
> +static inline int spi_flash_std_probe(struct udevice *dev)
> +{
> + return -ENODEV;
> +}
> +
> struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
> unsigned int max_hz, unsigned int spi_mode);
>
>
> --
> 2.34.1
next prev parent reply other threads:[~2024-10-02 7:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-01 16:06 [PATCH v2 0/2] dfu: sf: fix flash probe when DM_SPI_FLASH is enabled Neil Armstrong
2024-10-01 16:06 ` [PATCH v2 1/2] spi: add DM_SPI_FLASH compatibility inline functions Neil Armstrong
2024-10-02 7:29 ` Mattijs Korpershoek [this message]
2024-10-10 8:09 ` Mattijs Korpershoek
2024-10-01 16:06 ` [PATCH v2 2/2] dfu: sf: rely on DT for spi speed and mode Neil Armstrong
2024-10-02 7:30 ` Mattijs Korpershoek
2024-10-24 7:43 ` [PATCH v2 0/2] dfu: sf: fix flash probe when DM_SPI_FLASH is enabled Mattijs Korpershoek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8734lfm08d.fsf@baylibre.com \
--to=mkorpershoek@baylibre.com \
--cc=jagan@amarulasolutions.com \
--cc=lukma@denx.de \
--cc=neil.armstrong@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox