Skip to contentSkip to conversation

sf: Add dm_spi_flash_probe

PATCH Superseded Jagan Teki 2 participants 7 messages Oct 19, 2015 – Oct 28, 2015 Memory technology devices (MTD)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

PATCH 1/3 sf: Add dm_spi_flash_probe

Updated dm-spi-flash probe using dm_spi_flash_probe.

---
 common/cmd_sf.c             | 23 ++++-------------------
 drivers/mtd/spi/sf-uclass.c | 27 ++++++++++++++++++++++++++-
 include/spi_flash.h         |  5 ++---
 3 files changed, 32 insertions(+), 23 deletions(-)
common/cmd_sf.c +4 -19
index ac7f5df..f1926e3 100644
@@ -8,7 +8,6 @@
 
 #include <common.h>
 #include <div64.h>
-#include <dm.h>
 #include <malloc.h>
 #include <mapmem.h>
 #include <spi.h>
@@ -17,7 +16,6 @@
 #include <linux/mtd/mtd.h>
 
 #include <asm/io.h>
-#include <dm/device-internal.h>
 
 static struct spi_flash *flash;
 
@@ -85,10 +83,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
-	struct udevice *new, *bus_dev;
-	int ret;
-#else
+#ifndef CONFIG_DM_SPI_FLASH
 	struct spi_flash *new;
 #endif
 
@@ -119,21 +114,11 @@ static int do_spi_flash_probe(int argc, char * const argv[])
 	}
 
 #ifdef CONFIG_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) {
-		device_remove(new);
-		device_unbind(new);
-	}
-	flash = NULL;
-	ret = spi_flash_probe_bus_cs(bus, cs, speed, mode, &new);
-	if (ret) {
-		printf("Failed to initialize SPI flash at %u:%u (error %d)\n",
-		       bus, cs, ret);
+	flash = dm_spi_flash_probe(bus, cs, speed, mode);
+	if (!flash) {
+		printf("Failed to initialize SPI flash at %u:%u\n", bus, cs);
 		return 1;
 	}
-
-	flash = dev_get_uclass_priv(new);
 #else
 	if (flash)
 		spi_flash_free(flash);
drivers/mtd/spi/sf-uclass.c +26 -1
index 350e21a..9c109fa 100644
@@ -47,7 +47,7 @@ void spi_flash_free(struct spi_flash *flash)
 	spi_flash_remove(flash->spi->dev);
 }
 
-int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
+static int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
 			   unsigned int max_hz, unsigned int spi_mode,
 			   struct udevice **devp)
 {
@@ -67,6 +67,31 @@ int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
 	return 0;
 }
 
+struct spi_flash *dm_spi_flash_probe(unsigned int busnum, unsigned int cs,
+				unsigned int max_hz, unsigned int spi_mode)
+{
+	struct udevice *bus, *new;
+	struct spi_flash *flash;
+	int ret;
+
+	/* Remove the old device, otherwise probe will just be a nop */
+	ret = spi_find_bus_and_cs(busnum, cs, &bus, &new);
+	if (!ret) {
+		device_remove(new);
+		device_unbind(new);
+	}
+	flash = NULL;
+
+	ret = spi_flash_probe_bus_cs(busnum, cs, max_hz, spi_mode, &new);
+	if (ret) {
+		printf("Failed to initialize SPI flash at %u:%u (error %d)\n",
+		       busnum, cs, ret);
+		return flash;
+	}
+
+	return dev_get_uclass_priv(new);
+}
+
 int spi_flash_remove(struct udevice *dev)
 {
 	return device_remove(dev);
include/spi_flash.h +2 -3
index 3b2d555..5abbf99 100644
@@ -154,9 +154,8 @@ int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
  */
 int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len);
 
-int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
-			   unsigned int max_hz, unsigned int spi_mode,
-			   struct udevice **devp);
+struct spi_flash *dm_spi_flash_probe(unsigned int busnum, unsigned int cs,
+				unsigned int max_hz, unsigned int spi_mode);
 
 /* Compatibility function - this is the old U-Boot API */
 struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 2/3 sf: spi_flash_probe for both dm/non-dm

Let's use spi_flash_probe for dm and no-dm spi-flash and make respective function definations separately.

---
 common/cmd_sf.c             | 19 ++-----------------
 drivers/mtd/spi/sf-uclass.c | 17 +----------------
 include/spi_flash.h         | 18 ++++--------------
 3 files changed, 7 insertions(+), 47 deletions(-)
common/cmd_sf.c +2 -17
index f1926e3..cdc6c26 100644
@@ -83,9 +83,6 @@ 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;
-#ifndef CONFIG_DM_SPI_FLASH
-	struct spi_flash *new;
-#endif
 
 	if (argc >= 2) {
 		cs = simple_strtoul(argv[1], &endp, 0);
@@ -113,27 +110,15 @@ static int do_spi_flash_probe(int argc, char * const argv[])
 			return -1;
 	}
 
-#ifdef CONFIG_DM_SPI_FLASH
-	flash = dm_spi_flash_probe(bus, cs, speed, mode);
-	if (!flash) {
-		printf("Failed to initialize SPI flash at %u:%u\n", bus, cs);
-		return 1;
-	}
-#else
 	if (flash)
 		spi_flash_free(flash);
 
-	new = spi_flash_probe(bus, cs, speed, mode);
-	flash = new;
-
-	if (!new) {
+	flash = spi_flash_probe(bus, cs, speed, mode);
+	if (!flash) {
 		printf("Failed to initialize SPI flash at %u:%u\n", bus, cs);
 		return 1;
 	}
 
-	flash = new;
-#endif
-
 	return 0;
 }
 
drivers/mtd/spi/sf-uclass.c +1 -16
index 9c109fa..a1c5810 100644
@@ -27,21 +27,6 @@ int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len)
 	return sf_get_ops(dev)->erase(dev, offset, len);
 }
 
-/*
- * TODO(sjg at chromium.org): This is an old-style function. We should remove
- * it when all SPI flash drivers use dm
- */
-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
-				  unsigned int max_hz, unsigned int spi_mode)
-{
-	struct udevice *dev;
-
-	if (spi_flash_probe_bus_cs(bus, cs, max_hz, spi_mode, &dev))
-		return NULL;
-
-	return dev_get_uclass_priv(dev);
-}
-
 void spi_flash_free(struct spi_flash *flash)
 {
 	spi_flash_remove(flash->spi->dev);
@@ -67,7 +52,7 @@ static int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
 	return 0;
 }
 
-struct spi_flash *dm_spi_flash_probe(unsigned int busnum, unsigned int cs,
+struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
 				unsigned int max_hz, unsigned int spi_mode)
 {
 	struct udevice *bus, *new;
include/spi_flash.h +4 -14
index 5abbf99..0afc9fb 100644
@@ -154,16 +154,6 @@ int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
  */
 int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len);
 
-struct spi_flash *dm_spi_flash_probe(unsigned int busnum, unsigned int cs,
-				unsigned int max_hz, unsigned int spi_mode);
-
-/* Compatibility function - this is the old U-Boot API */
-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
-				  unsigned int max_hz, unsigned int spi_mode);
-
-/* Compatibility function - this is the old U-Boot API */
-void spi_flash_free(struct spi_flash *flash);
-
 int spi_flash_remove(struct udevice *flash);
 
 static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
@@ -192,8 +182,6 @@ 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
-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
-		unsigned int max_hz, unsigned int spi_mode);
 
 /**
  * Set up a new SPI flash from an fdt node
@@ -207,8 +195,6 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 struct spi_flash *spi_flash_probe_fdt(const void *blob, int slave_node,
 				      int spi_node);
 
-void spi_flash_free(struct spi_flash *flash);
-
 static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
 		size_t len, void *buf)
 {
@@ -228,6 +214,10 @@ static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
 }
 #endif
 
+struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+			unsigned int max_hz, unsigned int spi_mode);
+void spi_flash_free(struct spi_flash *flash);
+
 void spi_boot(void) __noreturn;
 void spi_spl_load_image(uint32_t offs, unsigned int size, void *vdst);
 
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/3 sf: spi_flash_probe for both dm/non-dm

Hi Jagan,

Quoted 10 lines · Jagan Teki

Let's use spi_flash_probe for dm and no-dm spi-flash and make respective function definations separately.

---
 common/cmd_sf.c             | 19 ++-----------------
 drivers/mtd/spi/sf-uclass.c | 17 +----------------
 include/spi_flash.h         | 18 ++++--------------
 3 files changed, 7 insertions(+), 47 deletions(-)

I think this is going in the wrong direction - we should not be abstracting out driver model, we should be moving everything to use it.

Quoted 131 lines
common/cmd_sf.c +2 -17
index f1926e3..cdc6c26 100644
@@ -83,9 +83,6 @@ 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;
-#ifndef CONFIG_DM_SPI_FLASH
-       struct spi_flash *new;
-#endif
 
        if (argc >= 2) {
                cs = simple_strtoul(argv[1], &endp, 0);
@@ -113,27 +110,15 @@ static int do_spi_flash_probe(int argc, char * const argv[])
                        return -1;
        }
 
-#ifdef CONFIG_DM_SPI_FLASH
-       flash = dm_spi_flash_probe(bus, cs, speed, mode);
-       if (!flash) {
-               printf("Failed to initialize SPI flash at %u:%u\n", bus, cs);
-               return 1;
-       }
-#else
        if (flash)
                spi_flash_free(flash);
 
-       new = spi_flash_probe(bus, cs, speed, mode);
-       flash = new;
-
-       if (!new) {
+       flash = spi_flash_probe(bus, cs, speed, mode);
+       if (!flash) {
                printf("Failed to initialize SPI flash at %u:%u\n", bus, cs);
                return 1;
        }
 
-       flash = new;
-#endif
-
        return 0;
 }
 
drivers/mtd/spi/sf-uclass.c +1 -16
index 9c109fa..a1c5810 100644
@@ -27,21 +27,6 @@ int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len)
        return sf_get_ops(dev)->erase(dev, offset, len);
 }
 
-/*
- * TODO(sjg at chromium.org): This is an old-style function. We should remove
- * it when all SPI flash drivers use dm
- */
-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
-                                 unsigned int max_hz, unsigned int spi_mode)
-{
-       struct udevice *dev;
-
-       if (spi_flash_probe_bus_cs(bus, cs, max_hz, spi_mode, &dev))
-               return NULL;
-
-       return dev_get_uclass_priv(dev);
-}
-
 void spi_flash_free(struct spi_flash *flash)
 {
        spi_flash_remove(flash->spi->dev);
@@ -67,7 +52,7 @@ static int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
        return 0;
 }
 
-struct spi_flash *dm_spi_flash_probe(unsigned int busnum, unsigned int cs,
+struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
                                unsigned int max_hz, unsigned int spi_mode)
 {
        struct udevice *bus, *new;
include/spi_flash.h +4 -15
index 5abbf99..0afc9fb 100644
@@ -154,16 +154,6 @@ int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
  */
 int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len);
 
-struct spi_flash *dm_spi_flash_probe(unsigned int busnum, unsigned int cs,
-                               unsigned int max_hz, unsigned int spi_mode);
-
-/* Compatibility function - this is the old U-Boot API */
-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
-                                 unsigned int max_hz, unsigned int spi_mode);
-
-/* Compatibility function - this is the old U-Boot API */
-void spi_flash_free(struct spi_flash *flash);
-
 int spi_flash_remove(struct udevice *flash);
 
 static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
@@ -192,8 +182,6 @@ 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
-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
-               unsigned int max_hz, unsigned int spi_mode);
 
 /**
  * Set up a new SPI flash from an fdt node
@@ -207,8 +195,6 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 struct spi_flash *spi_flash_probe_fdt(const void *blob, int slave_node,
                                      int spi_node);
 
-void spi_flash_free(struct spi_flash *flash);
-
 static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
                size_t len, void *buf)
 {
@@ -228,6 +214,10 @@ static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
 }
 #endif
 
+struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+                       unsigned int max_hz, unsigned int spi_mode);
+void spi_flash_free(struct spi_flash *flash);
+
 void spi_boot(void) __noreturn;
 void spi_spl_load_image(uint32_t offs, unsigned int size, void *vdst);
 
--
Quoted 2 lines

1.9.1

Regards,
Simon

author
#3 lore raw

PATCH 2/3 sf: spi_flash_probe for both dm/non-dm

Hi Simon,

Quoted 14 lines · Simon Glass

Hi Jagan,

Quoted 10 lines · Jagan Teki

Let's use spi_flash_probe for dm and no-dm spi-flash and make respective function definations separately.

---
 common/cmd_sf.c             | 19 ++-----------------
 drivers/mtd/spi/sf-uclass.c | 17 +----------------
 include/spi_flash.h         | 18 ++++--------------
 3 files changed, 7 insertions(+), 47 deletions(-)
Quoted 3 lines

I think this is going in the wrong direction - we should not be abstracting out driver model, we should be moving everything to use it.

I'm thinking command code might not know about how driver model handled for for particular device driver. Just process the inputs what the user has given and do driver-model stuff at driver level.

Anyway dm_spi enabled boards will use driver model at sf-uclass and non-dm will directly go.

Quoted 141 lines
Quoted 132 lines
common/cmd_sf.c +2 -17
index f1926e3..cdc6c26 100644
@@ -83,9 +83,6 @@ 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;
-#ifndef CONFIG_DM_SPI_FLASH
-       struct spi_flash *new;
-#endif
 
        if (argc >= 2) {
                cs = simple_strtoul(argv[1], &endp, 0);
@@ -113,27 +110,15 @@ static int do_spi_flash_probe(int argc, char * const argv[])
                        return -1;
        }
 
-#ifdef CONFIG_DM_SPI_FLASH
-       flash = dm_spi_flash_probe(bus, cs, speed, mode);
-       if (!flash) {
-               printf("Failed to initialize SPI flash at %u:%u\n", bus, cs);
-               return 1;
-       }
-#else
        if (flash)
                spi_flash_free(flash);
 
-       new = spi_flash_probe(bus, cs, speed, mode);
-       flash = new;
-
-       if (!new) {
+       flash = spi_flash_probe(bus, cs, speed, mode);
+       if (!flash) {
                printf("Failed to initialize SPI flash at %u:%u\n", bus, cs);
                return 1;
        }
 
-       flash = new;
-#endif
-
        return 0;
 }
 
drivers/mtd/spi/sf-uclass.c +1 -16
index 9c109fa..a1c5810 100644
@@ -27,21 +27,6 @@ int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len)
        return sf_get_ops(dev)->erase(dev, offset, len);
 }
 
-/*
- * TODO(sjg at chromium.org): This is an old-style function. We should remove
- * it when all SPI flash drivers use dm
- */
-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
-                                 unsigned int max_hz, unsigned int spi_mode)
-{
-       struct udevice *dev;
-
-       if (spi_flash_probe_bus_cs(bus, cs, max_hz, spi_mode, &dev))
-               return NULL;
-
-       return dev_get_uclass_priv(dev);
-}
-
 void spi_flash_free(struct spi_flash *flash)
 {
        spi_flash_remove(flash->spi->dev);
@@ -67,7 +52,7 @@ static int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
        return 0;
 }
 
-struct spi_flash *dm_spi_flash_probe(unsigned int busnum, unsigned int cs,
+struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
                                unsigned int max_hz, unsigned int spi_mode)
 {
        struct udevice *bus, *new;
include/spi_flash.h +4 -15
index 5abbf99..0afc9fb 100644
@@ -154,16 +154,6 @@ int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
  */
 int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len);
 
-struct spi_flash *dm_spi_flash_probe(unsigned int busnum, unsigned int cs,
-                               unsigned int max_hz, unsigned int spi_mode);
-
-/* Compatibility function - this is the old U-Boot API */
-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
-                                 unsigned int max_hz, unsigned int spi_mode);
-
-/* Compatibility function - this is the old U-Boot API */
-void spi_flash_free(struct spi_flash *flash);
-
 int spi_flash_remove(struct udevice *flash);
 
 static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
@@ -192,8 +182,6 @@ 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
-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
-               unsigned int max_hz, unsigned int spi_mode);
 
 /**
  * Set up a new SPI flash from an fdt node
@@ -207,8 +195,6 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 struct spi_flash *spi_flash_probe_fdt(const void *blob, int slave_node,
                                      int spi_node);
 
-void spi_flash_free(struct spi_flash *flash);
-
 static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
                size_t len, void *buf)
 {
@@ -228,6 +214,10 @@ static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
 }
 #endif
 
+struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+                       unsigned int max_hz, unsigned int spi_mode);
+void spi_flash_free(struct spi_flash *flash);
+
 void spi_boot(void) __noreturn;
 void spi_spl_load_image(uint32_t offs, unsigned int size, void *vdst);
 
--
Quoted 2 lines

1.9.1

Regards,
Simon
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Signature · 1 line
Jagan | openedev.
author
#4 lore raw

PATCH 3/3 sf: Remove spi_flash_remove

In reply to Jagan Teki

Use direct call to device_remove instead of exctra spi_flash_remove defination.

---
 drivers/mtd/spi/sf-uclass.c | 7 +------
 include/spi_flash.h         | 2 --
 2 files changed, 1 insertion(+), 8 deletions(-)
drivers/mtd/spi/sf-uclass.c +1 -6
index a1c5810..60d6cd9 100644
@@ -29,7 +29,7 @@ int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len)
 
 void spi_flash_free(struct spi_flash *flash)
 {
-	spi_flash_remove(flash->spi->dev);
+	device_remove(flash->spi->dev);
 }
 
 static int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
@@ -77,11 +77,6 @@ struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
 	return dev_get_uclass_priv(new);
 }
 
-int spi_flash_remove(struct udevice *dev)
-{
-	return device_remove(dev);
-}
-
 UCLASS_DRIVER(spi_flash) = {
 	.id		= UCLASS_SPI_FLASH,
 	.name		= "spi_flash",
include/spi_flash.h +0 -2
index 0afc9fb..0037f0b 100644
@@ -154,8 +154,6 @@ int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
  */
 int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len);
 
-int spi_flash_remove(struct udevice *flash);
-
 static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
 				 size_t len, void *buf)
 {
Signature · 1 line
1.9.1
#6 lore raw

PATCH 1/3 sf: Add dm_spi_flash_probe

In reply to Jagan Teki

Hi Jagan,

Quoted 48 lines · Jagan Teki

Updated dm-spi-flash probe using dm_spi_flash_probe.

---
 common/cmd_sf.c             | 23 ++++-------------------
 drivers/mtd/spi/sf-uclass.c | 27 ++++++++++++++++++++++++++-
 include/spi_flash.h         |  5 ++---
 3 files changed, 32 insertions(+), 23 deletions(-)
common/cmd_sf.c +1 -8
index ac7f5df..f1926e3 100644
@@ -8,7 +8,6 @@
 
 #include <common.h>
 #include <div64.h>
-#include <dm.h>
 #include <malloc.h>
 #include <mapmem.h>
 #include <spi.h>
@@ -17,7 +16,6 @@
 #include <linux/mtd/mtd.h>
 
 #include <asm/io.h>
-#include <dm/device-internal.h>
 
 static struct spi_flash *flash;
 
@@ -85,10 +83,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
-       struct udevice *new, *bus_dev;
-       int ret;
-#else
+#ifndef CONFIG_DM_SPI_FLASH
        struct spi_flash *new;
 #endif
 
@@ -119,21 +114,11 @@ static int do_spi_flash_probe(int argc, char * const argv[])
        }
 
 #ifdef CONFIG_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);

common/cmd_sf.c static int do_spi_flash_probe(int argc, char * const argv[]) · line 117

Quoted 10 lines
common/cmd_sf.c +1 -9
-       if (!ret) {
-               device_remove(new);
-               device_unbind(new);
-       }
-       flash = NULL;
-       ret = spi_flash_probe_bus_cs(bus, cs, speed, mode, &new);
-       if (ret) {
-               printf("Failed to initialize SPI flash at %u:%u (error %d)\n",
-                      bus, cs, ret);
+       flash = dm_spi_flash_probe(bus, cs, speed, mode);

The dm_ functions should use driver model - i.e. a udevice, not a bus number and CS number.

[snip]

Regards,
Simon