diff mbox series

[U-Boot] treewide: Replace CONFIG_DM_SPI_FLASH with CONFIG_IS_ENABLED(DM_SPI_FLASH)

Message ID 20190219050721.4258-1-marek.vasut+renesas@gmail.com
State Deferred
Delegated to: Marek Vasut
Headers show
Series [U-Boot] treewide: Replace CONFIG_DM_SPI_FLASH with CONFIG_IS_ENABLED(DM_SPI_FLASH) | expand

Commit Message

Marek Vasut Feb. 19, 2019, 5:07 a.m. UTC
Perform the replacement to allow platforms use non-DM SPI flash access
in SPL/TPL. This is thus far needed on platforms with size constraints.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Jagan Teki <jagan@openedev.com>
Cc: Vignesh R <vigneshr@ti.com>
---
 cmd/sf.c                   | 4 ++--
 drivers/mtd/spi/sf_probe.c | 2 +-
 drivers/net/fm/fm.c        | 4 ++--
 env/sf.c                   | 2 +-
 include/spi_flash.h        | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

Comments

Raghavendra, Vignesh Feb. 20, 2019, 5:05 a.m. UTC | #1
On 19/02/19 10:37 AM, Marek Vasut wrote:
> Perform the replacement to allow platforms use non-DM SPI flash access
> in SPL/TPL. This is thus far needed on platforms with size constraints.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Jagan Teki <jagan@openedev.com>
> Cc: Vignesh R <vigneshr@ti.com>
> ---

I have a similar patch, but you beat me to it :)

Reviewed-by: Vignesh R <vigneshr@ti.com>


Regards
Vignesh

>  cmd/sf.c                   | 4 ++--
>  drivers/mtd/spi/sf_probe.c | 2 +-
>  drivers/net/fm/fm.c        | 4 ++--
>  env/sf.c                   | 2 +-
>  include/spi_flash.h        | 2 +-
>  5 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/cmd/sf.c b/cmd/sf.c
> index 738ef0e46d..7e92a43b2c 100644
> --- a/cmd/sf.c
> +++ b/cmd/sf.c
> @@ -84,7 +84,7 @@ static int do_spi_flash_probe(int argc, char * const argv[])
>  	unsigned int speed = CONFIG_SF_DEFAULT_SPEED;
>  	unsigned int mode = CONFIG_SF_DEFAULT_MODE;
>  	char *endp;
> -#ifdef CONFIG_DM_SPI_FLASH
> +#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
>  	struct udevice *new, *bus_dev;
>  	int ret;
>  	/* In DM mode defaults will be taken from DT */
> @@ -119,7 +119,7 @@ static int do_spi_flash_probe(int argc, char * const argv[])
>  			return -1;
>  	}
>  
> -#ifdef CONFIG_DM_SPI_FLASH
> +#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
>  	/* Remove the old device, otherwise probe will just be a nop */
>  	ret = spi_find_bus_and_cs(bus, cs, &bus_dev, &new);
>  	if (!ret) {
> diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
> index 7f1378f494..4282d48f26 100644
> --- a/drivers/mtd/spi/sf_probe.c
> +++ b/drivers/mtd/spi/sf_probe.c
> @@ -53,7 +53,7 @@ err_read_id:
>  	return ret;
>  }
>  
> -#ifndef CONFIG_DM_SPI_FLASH
> +#if !CONFIG_IS_ENABLED(DM_SPI_FLASH)
>  struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
>  				  unsigned int max_hz, unsigned int spi_mode)
>  {
> diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
> index e19d7777dc..6a5c9bbc9d 100644
> --- a/drivers/net/fm/fm.c
> +++ b/drivers/net/fm/fm.c
> @@ -377,7 +377,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
>  		addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
>  		int ret = 0;
>  
> -#ifdef CONFIG_DM_SPI_FLASH
> +#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
>  		struct udevice *new;
>  
>  		/* speed and mode will be read from DT */
> @@ -464,7 +464,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
>  	void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
>  	int ret = 0;
>  
> -#ifdef CONFIG_DM_SPI_FLASH
> +#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
>  	struct udevice *new;
>  
>  	/* speed and mode will be read from DT */
> diff --git a/env/sf.c b/env/sf.c
> index b3dec82c35..ee639b90fc 100644
> --- a/env/sf.c
> +++ b/env/sf.c
> @@ -52,7 +52,7 @@ static struct spi_flash *env_flash;
>  
>  static int setup_flash_device(void)
>  {
> -#ifdef CONFIG_DM_SPI_FLASH
> +#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
>  	struct udevice *new;
>  	int	ret;
>  
> diff --git a/include/spi_flash.h b/include/spi_flash.h
> index 7f691e8559..09f3896fb9 100644
> --- a/include/spi_flash.h
> +++ b/include/spi_flash.h
> @@ -51,7 +51,7 @@ struct dm_spi_flash_ops {
>  /* Access the serial operations for a device */
>  #define sf_get_ops(dev) ((struct dm_spi_flash_ops *)(dev)->driver->ops)
>  
> -#ifdef CONFIG_DM_SPI_FLASH
> +#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
>  /**
>   * spi_flash_read_dm() - Read data from SPI flash
>   *
>
Marek Vasut Feb. 20, 2019, 10:50 a.m. UTC | #2
On 2/20/19 6:05 AM, Vignesh R wrote:
> 
> 
> On 19/02/19 10:37 AM, Marek Vasut wrote:
>> Perform the replacement to allow platforms use non-DM SPI flash access
>> in SPL/TPL. This is thus far needed on platforms with size constraints.
>>
>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>> Cc: Jagan Teki <jagan@openedev.com>
>> Cc: Vignesh R <vigneshr@ti.com>
>> ---
> 
> I have a similar patch, but you beat me to it :)
> 
> Reviewed-by: Vignesh R <vigneshr@ti.com>

Except this one breaks a few platforms, so feel free to drop this one
and send yours , or merge them into one.
Frieder Schrempf Feb. 20, 2019, 11:18 a.m. UTC | #3
On 19.02.19 06:07, Marek Vasut wrote:
> Perform the replacement to allow platforms use non-DM SPI flash access
> in SPL/TPL. This is thus far needed on platforms with size constraints.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Jagan Teki <jagan@openedev.com>
> Cc: Vignesh R <vigneshr@ti.com>

I stumbled upon this issue when trying to build a non-DM SPL for imx 
with SPI flash access. This fixes the build.

Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>

> ---
>   cmd/sf.c                   | 4 ++--
>   drivers/mtd/spi/sf_probe.c | 2 +-
>   drivers/net/fm/fm.c        | 4 ++--
>   env/sf.c                   | 2 +-
>   include/spi_flash.h        | 2 +-
>   5 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/cmd/sf.c b/cmd/sf.c
> index 738ef0e46d..7e92a43b2c 100644
> --- a/cmd/sf.c
> +++ b/cmd/sf.c
> @@ -84,7 +84,7 @@ static int do_spi_flash_probe(int argc, char * const argv[])
>   	unsigned int speed = CONFIG_SF_DEFAULT_SPEED;
>   	unsigned int mode = CONFIG_SF_DEFAULT_MODE;
>   	char *endp;
> -#ifdef CONFIG_DM_SPI_FLASH
> +#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
>   	struct udevice *new, *bus_dev;
>   	int ret;
>   	/* In DM mode defaults will be taken from DT */
> @@ -119,7 +119,7 @@ static int do_spi_flash_probe(int argc, char * const argv[])
>   			return -1;
>   	}
>   
> -#ifdef CONFIG_DM_SPI_FLASH
> +#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
>   	/* Remove the old device, otherwise probe will just be a nop */
>   	ret = spi_find_bus_and_cs(bus, cs, &bus_dev, &new);
>   	if (!ret) {
> diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
> index 7f1378f494..4282d48f26 100644
> --- a/drivers/mtd/spi/sf_probe.c
> +++ b/drivers/mtd/spi/sf_probe.c
> @@ -53,7 +53,7 @@ err_read_id:
>   	return ret;
>   }
>   
> -#ifndef CONFIG_DM_SPI_FLASH
> +#if !CONFIG_IS_ENABLED(DM_SPI_FLASH)
>   struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
>   				  unsigned int max_hz, unsigned int spi_mode)
>   {
> diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
> index e19d7777dc..6a5c9bbc9d 100644
> --- a/drivers/net/fm/fm.c
> +++ b/drivers/net/fm/fm.c
> @@ -377,7 +377,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
>   		addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
>   		int ret = 0;
>   
> -#ifdef CONFIG_DM_SPI_FLASH
> +#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
>   		struct udevice *new;
>   
>   		/* speed and mode will be read from DT */
> @@ -464,7 +464,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
>   	void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
>   	int ret = 0;
>   
> -#ifdef CONFIG_DM_SPI_FLASH
> +#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
>   	struct udevice *new;
>   
>   	/* speed and mode will be read from DT */
> diff --git a/env/sf.c b/env/sf.c
> index b3dec82c35..ee639b90fc 100644
> --- a/env/sf.c
> +++ b/env/sf.c
> @@ -52,7 +52,7 @@ static struct spi_flash *env_flash;
>   
>   static int setup_flash_device(void)
>   {
> -#ifdef CONFIG_DM_SPI_FLASH
> +#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
>   	struct udevice *new;
>   	int	ret;
>   
> diff --git a/include/spi_flash.h b/include/spi_flash.h
> index 7f691e8559..09f3896fb9 100644
> --- a/include/spi_flash.h
> +++ b/include/spi_flash.h
> @@ -51,7 +51,7 @@ struct dm_spi_flash_ops {
>   /* Access the serial operations for a device */
>   #define sf_get_ops(dev) ((struct dm_spi_flash_ops *)(dev)->driver->ops)
>   
> -#ifdef CONFIG_DM_SPI_FLASH
> +#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
>   /**
>    * spi_flash_read_dm() - Read data from SPI flash
>    *
>
Marek Vasut Feb. 20, 2019, 11:20 a.m. UTC | #4
On 2/20/19 12:18 PM, Schrempf Frieder wrote:
> On 19.02.19 06:07, Marek Vasut wrote:
>> Perform the replacement to allow platforms use non-DM SPI flash access
>> in SPL/TPL. This is thus far needed on platforms with size constraints.
>>
>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>> Cc: Jagan Teki <jagan@openedev.com>
>> Cc: Vignesh R <vigneshr@ti.com>
> 
> I stumbled upon this issue when trying to build a non-DM SPL for imx 
> with SPI flash access. This fixes the build.
> 
> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>

This patch breaks x86 at least, so NAK.
Frieder Schrempf July 1, 2019, 8:06 a.m. UTC | #5
On 20.02.19 12:20, Marek Vasut wrote:
> On 2/20/19 12:18 PM, Schrempf Frieder wrote:
>> On 19.02.19 06:07, Marek Vasut wrote:
>>> Perform the replacement to allow platforms use non-DM SPI flash access
>>> in SPL/TPL. This is thus far needed on platforms with size constraints.
>>>
>>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>>> Cc: Jagan Teki <jagan@openedev.com>
>>> Cc: Vignesh R <vigneshr@ti.com>
>>
>> I stumbled upon this issue when trying to build a non-DM SPL for imx
>> with SPI flash access. This fixes the build.
>>
>> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
>> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> 
> This patch breaks x86 at least, so NAK.
> 
It seems, that there's still no solution for this upstream. I tried to 
build Marek's patch with a fixup on current master [1], but still the 
build breaks for some configurations [2].

Can someone have a look, how to fix the failing boards?

Thanks,
Frieder

[1] https://github.com/fschrempf/u-boot/commits/non_dm_spi_flash_in_spl
[2] https://travis-ci.org/fschrempf/u-boot/builds/551244482
diff mbox series

Patch

diff --git a/cmd/sf.c b/cmd/sf.c
index 738ef0e46d..7e92a43b2c 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -84,7 +84,7 @@  static int do_spi_flash_probe(int argc, char * const argv[])
 	unsigned int speed = CONFIG_SF_DEFAULT_SPEED;
 	unsigned int mode = CONFIG_SF_DEFAULT_MODE;
 	char *endp;
-#ifdef CONFIG_DM_SPI_FLASH
+#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
 	struct udevice *new, *bus_dev;
 	int ret;
 	/* In DM mode defaults will be taken from DT */
@@ -119,7 +119,7 @@  static int do_spi_flash_probe(int argc, char * const argv[])
 			return -1;
 	}
 
-#ifdef CONFIG_DM_SPI_FLASH
+#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
 	/* Remove the old device, otherwise probe will just be a nop */
 	ret = spi_find_bus_and_cs(bus, cs, &bus_dev, &new);
 	if (!ret) {
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index 7f1378f494..4282d48f26 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -53,7 +53,7 @@  err_read_id:
 	return ret;
 }
 
-#ifndef CONFIG_DM_SPI_FLASH
+#if !CONFIG_IS_ENABLED(DM_SPI_FLASH)
 struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
 				  unsigned int max_hz, unsigned int spi_mode)
 {
diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
index e19d7777dc..6a5c9bbc9d 100644
--- a/drivers/net/fm/fm.c
+++ b/drivers/net/fm/fm.c
@@ -377,7 +377,7 @@  int fm_init_common(int index, struct ccsr_fman *reg)
 		addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
 		int ret = 0;
 
-#ifdef CONFIG_DM_SPI_FLASH
+#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
 		struct udevice *new;
 
 		/* speed and mode will be read from DT */
@@ -464,7 +464,7 @@  int fm_init_common(int index, struct ccsr_fman *reg)
 	void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
 	int ret = 0;
 
-#ifdef CONFIG_DM_SPI_FLASH
+#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
 	struct udevice *new;
 
 	/* speed and mode will be read from DT */
diff --git a/env/sf.c b/env/sf.c
index b3dec82c35..ee639b90fc 100644
--- a/env/sf.c
+++ b/env/sf.c
@@ -52,7 +52,7 @@  static struct spi_flash *env_flash;
 
 static int setup_flash_device(void)
 {
-#ifdef CONFIG_DM_SPI_FLASH
+#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
 	struct udevice *new;
 	int	ret;
 
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 7f691e8559..09f3896fb9 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -51,7 +51,7 @@  struct dm_spi_flash_ops {
 /* Access the serial operations for a device */
 #define sf_get_ops(dev) ((struct dm_spi_flash_ops *)(dev)->driver->ops)
 
-#ifdef CONFIG_DM_SPI_FLASH
+#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
 /**
  * spi_flash_read_dm() - Read data from SPI flash
  *