* [U-Boot] [PATCH v2 1/3] sf: Add dm_spi_flash_probe
@ 2015-10-24 3:54 Jagan Teki
2015-10-24 3:54 ` [U-Boot] [PATCH v2 2/3] sf: spi_flash_probe for both dm/non-dm Jagan Teki
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jagan Teki @ 2015-10-24 3:54 UTC (permalink / raw)
To: u-boot
Updated dm-spi-flash probe using dm_spi_flash_probe.
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
Changes for v2:
- none
common/cmd_sf.c | 23 ++++-------------------
drivers/mtd/spi/sf-uclass.c | 27 ++++++++++++++++++++++++++-
include/spi_flash.h | 5 ++---
3 files changed, 32 insertions(+), 23 deletions(-)
diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index ac7f5df..f1926e3 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -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);
diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index 350e21a..9c109fa 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -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);
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 3b2d555..5abbf99 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -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,
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH v2 2/3] sf: spi_flash_probe for both dm/non-dm
2015-10-24 3:54 [U-Boot] [PATCH v2 1/3] sf: Add dm_spi_flash_probe Jagan Teki
@ 2015-10-24 3:54 ` Jagan Teki
2015-11-05 18:25 ` Simon Glass
2015-10-24 3:54 ` [U-Boot] [PATCH v2 3/3] sf: Remove spi_flash_remove Jagan Teki
2015-11-05 18:25 ` [U-Boot] [PATCH v2 1/3] sf: Add dm_spi_flash_probe Simon Glass
2 siblings, 1 reply; 7+ messages in thread
From: Jagan Teki @ 2015-10-24 3:54 UTC (permalink / raw)
To: u-boot
Let's use spi_flash_probe for dm and no-dm spi-flash
and make respective function definations separately.
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
Changes for v2:
- none
common/cmd_sf.c | 19 ++-----------------
drivers/mtd/spi/sf-uclass.c | 17 +----------------
include/spi_flash.h | 18 ++++--------------
3 files changed, 7 insertions(+), 47 deletions(-)
diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index f1926e3..cdc6c26 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -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;
}
diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index 9c109fa..a1c5810 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -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;
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 5abbf99..0afc9fb 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -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);
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH v2 3/3] sf: Remove spi_flash_remove
2015-10-24 3:54 [U-Boot] [PATCH v2 1/3] sf: Add dm_spi_flash_probe Jagan Teki
2015-10-24 3:54 ` [U-Boot] [PATCH v2 2/3] sf: spi_flash_probe for both dm/non-dm Jagan Teki
@ 2015-10-24 3:54 ` Jagan Teki
2015-11-05 18:25 ` Simon Glass
2015-11-05 18:25 ` [U-Boot] [PATCH v2 1/3] sf: Add dm_spi_flash_probe Simon Glass
2 siblings, 1 reply; 7+ messages in thread
From: Jagan Teki @ 2015-10-24 3:54 UTC (permalink / raw)
To: u-boot
Use direct call to device_remove instead of exctra
spi_flash_remove defination.
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
Changes for v2:
- none
drivers/mtd/spi/sf-uclass.c | 7 +------
include/spi_flash.h | 2 --
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index a1c5810..60d6cd9 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -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",
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 0afc9fb..0037f0b 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -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)
{
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH v2 2/3] sf: spi_flash_probe for both dm/non-dm
2015-10-24 3:54 ` [U-Boot] [PATCH v2 2/3] sf: spi_flash_probe for both dm/non-dm Jagan Teki
@ 2015-11-05 18:25 ` Simon Glass
0 siblings, 0 replies; 7+ messages in thread
From: Simon Glass @ 2015-11-05 18:25 UTC (permalink / raw)
To: u-boot
Hi Jagan,
On 23 October 2015 at 21:54, Jagan Teki <jteki@openedev.com> wrote:
> Let's use spi_flash_probe for dm and no-dm spi-flash
> and make respective function definations separately.
>
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Jagan Teki <jteki@openedev.com>
> ---
> Changes for v2:
> - none
>
> common/cmd_sf.c | 19 ++-----------------
> drivers/mtd/spi/sf-uclass.c | 17 +----------------
> include/spi_flash.h | 18 ++++--------------
> 3 files changed, 7 insertions(+), 47 deletions(-)
>
> diff --git a/common/cmd_sf.c b/common/cmd_sf.c
> index f1926e3..cdc6c26 100644
> --- a/common/cmd_sf.c
> +++ b/common/cmd_sf.c
> @@ -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;
> }
>
> diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
> index 9c109fa..a1c5810 100644
> --- a/drivers/mtd/spi/sf-uclass.c
> +++ b/drivers/mtd/spi/sf-uclass.c
> @@ -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)
How come this function is being removed? I don't think all drivers
have been converted to driver model yet.
> -{
> - 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;
> diff --git a/include/spi_flash.h b/include/spi_flash.h
> index 5abbf99..0afc9fb 100644
> --- a/include/spi_flash.h
> +++ b/include/spi_flash.h
> @@ -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);
>
> --
> 1.9.1
>
Regards,
Simon
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH v2 3/3] sf: Remove spi_flash_remove
2015-10-24 3:54 ` [U-Boot] [PATCH v2 3/3] sf: Remove spi_flash_remove Jagan Teki
@ 2015-11-05 18:25 ` Simon Glass
2015-12-15 6:33 ` Jagan Teki
0 siblings, 1 reply; 7+ messages in thread
From: Simon Glass @ 2015-11-05 18:25 UTC (permalink / raw)
To: u-boot
On 23 October 2015 at 21:54, Jagan Teki <jteki@openedev.com> wrote:
> Use direct call to device_remove instead of exctra
> spi_flash_remove defination.
>
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Jagan Teki <jteki@openedev.com>
> ---
> Changes for v2:
> - none
>
> drivers/mtd/spi/sf-uclass.c | 7 +------
> include/spi_flash.h | 2 --
> 2 files changed, 1 insertion(+), 8 deletions(-)
>
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH v2 1/3] sf: Add dm_spi_flash_probe
2015-10-24 3:54 [U-Boot] [PATCH v2 1/3] sf: Add dm_spi_flash_probe Jagan Teki
2015-10-24 3:54 ` [U-Boot] [PATCH v2 2/3] sf: spi_flash_probe for both dm/non-dm Jagan Teki
2015-10-24 3:54 ` [U-Boot] [PATCH v2 3/3] sf: Remove spi_flash_remove Jagan Teki
@ 2015-11-05 18:25 ` Simon Glass
2 siblings, 0 replies; 7+ messages in thread
From: Simon Glass @ 2015-11-05 18:25 UTC (permalink / raw)
To: u-boot
Hi Jagan,
On 23 October 2015 at 21:54, Jagan Teki <jteki@openedev.com> wrote:
> Updated dm-spi-flash probe using dm_spi_flash_probe.
>
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Jagan Teki <jteki@openedev.com>
> ---
> Changes for v2:
> - none
>
> common/cmd_sf.c | 23 ++++-------------------
> drivers/mtd/spi/sf-uclass.c | 27 ++++++++++++++++++++++++++-
> include/spi_flash.h | 5 ++---
> 3 files changed, 32 insertions(+), 23 deletions(-)
>
> diff --git a/common/cmd_sf.c b/common/cmd_sf.c
> index ac7f5df..f1926e3 100644
> --- a/common/cmd_sf.c
> +++ b/common/cmd_sf.c
> @@ -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);
> diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
> index 350e21a..9c109fa 100644
> --- a/drivers/mtd/spi/sf-uclass.c
> +++ b/drivers/mtd/spi/sf-uclass.c
> @@ -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)
This is a probe function....
> +{
> + 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);
> + }
But it starts by removing a device. The probe function should probe, only.
> + 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);
> diff --git a/include/spi_flash.h b/include/spi_flash.h
> index 3b2d555..5abbf99 100644
> --- a/include/spi_flash.h
> +++ b/include/spi_flash.h
> @@ -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,
> --
> 1.9.1
>
Regards,
Simon
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH v2 3/3] sf: Remove spi_flash_remove
2015-11-05 18:25 ` Simon Glass
@ 2015-12-15 6:33 ` Jagan Teki
0 siblings, 0 replies; 7+ messages in thread
From: Jagan Teki @ 2015-12-15 6:33 UTC (permalink / raw)
To: u-boot
On 5 November 2015 at 23:55, Simon Glass <sjg@chromium.org> wrote:
> On 23 October 2015 at 21:54, Jagan Teki <jteki@openedev.com> wrote:
>> Use direct call to device_remove instead of exctra
>> spi_flash_remove defination.
>>
>> Cc: Simon Glass <sjg@chromium.org>
>> Signed-off-by: Jagan Teki <jteki@openedev.com>
>> ---
>> Changes for v2:
>> - none
>>
>> drivers/mtd/spi/sf-uclass.c | 7 +------
>> include/spi_flash.h | 2 --
>> 2 files changed, 1 insertion(+), 8 deletions(-)
>>
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
Applied to u-boot-spi/master
thanks!
--
Jagan.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-12-15 6:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-24 3:54 [U-Boot] [PATCH v2 1/3] sf: Add dm_spi_flash_probe Jagan Teki
2015-10-24 3:54 ` [U-Boot] [PATCH v2 2/3] sf: spi_flash_probe for both dm/non-dm Jagan Teki
2015-11-05 18:25 ` Simon Glass
2015-10-24 3:54 ` [U-Boot] [PATCH v2 3/3] sf: Remove spi_flash_remove Jagan Teki
2015-11-05 18:25 ` Simon Glass
2015-12-15 6:33 ` Jagan Teki
2015-11-05 18:25 ` [U-Boot] [PATCH v2 1/3] sf: Add dm_spi_flash_probe Simon Glass
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.