dm: spi: Add logging of some return values
authorSimon Glass <sjg@chromium.org>
Mon, 1 Oct 2018 18:22:24 +0000 (12:22 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 9 Oct 2018 10:40:27 +0000 (04:40 -0600)
When SPI flash operations fail it is helpful to be able to see the error
codes and where they are generated. Add logging to capture this
information for read operations.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/mtd/spi/sf-uclass.c
drivers/mtd/spi/sf_probe.c
drivers/mtd/spi/spi_flash.c
drivers/spi/spi-uclass.c

index 3858f77a6dd19ea17509a34aac7204fb4c79b515..662525f016f6996c66ce3884ab281e1a50faa627 100644 (file)
@@ -14,18 +14,18 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len, void *buf)
 {
-       return sf_get_ops(dev)->read(dev, offset, len, buf);
+       return log_ret(sf_get_ops(dev)->read(dev, offset, len, buf));
 }
 
 int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len,
                       const void *buf)
 {
-       return sf_get_ops(dev)->write(dev, offset, len, buf);
+       return log_ret(sf_get_ops(dev)->write(dev, offset, len, buf));
 }
 
 int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len)
 {
-       return sf_get_ops(dev)->erase(dev, offset, len);
+       return log_ret(sf_get_ops(dev)->erase(dev, offset, len));
 }
 
 /*
index 42c7cdedf6f3120b3a7d7d2ddc9f44c4e120491d..94fde2ae7a366671e1d2411045dbd0182edf9d55 100644 (file)
@@ -97,7 +97,7 @@ static int spi_flash_std_read(struct udevice *dev, u32 offset, size_t len,
 {
        struct spi_flash *flash = dev_get_uclass_priv(dev);
 
-       return spi_flash_cmd_read_ops(flash, offset, len, buf);
+       return log_ret(spi_flash_cmd_read_ops(flash, offset, len, buf));
 }
 
 static int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,
index 7113c855fe4c8ba3bc8661d2c38ca1ce5cfc80cf..92300603644d259b8c073a4adb494f21f9620278 100644 (file)
@@ -471,14 +471,14 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
        u8 cmdsz;
        u32 remain_len, read_len, read_addr;
        int bank_sel = 0;
-       int ret = -1;
+       int ret = 0;
 
        /* Handle memory-mapped SPI */
        if (flash->memory_map) {
                ret = spi_claim_bus(spi);
                if (ret) {
                        debug("SF: unable to claim SPI bus\n");
-                       return ret;
+                       return log_ret(ret);
                }
                spi_xfer(spi, 0, NULL, NULL, SPI_XFER_MMAP);
                spi_flash_copy_mmap(data, flash->memory_map + offset, len);
@@ -501,7 +501,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
 #ifdef CONFIG_SPI_FLASH_BAR
                ret = write_bar(flash, read_addr);
                if (ret < 0)
-                       return ret;
+                       return log_ret(ret);
                bank_sel = flash->bank_curr;
 #endif
                remain_len = ((SPI_FLASH_16MB_BOUN << flash->shift) *
@@ -531,7 +531,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
        ret = clean_bar(flash);
 #endif
 
-       return ret;
+       return log_ret(ret);
 }
 
 #ifdef CONFIG_SPI_FLASH_SST
index c517d066f693f44d94fd805308ff8af4b5948a9c..b84255bd27439d7bb6f86bdb1fda3d7d31d565d2 100644 (file)
@@ -63,11 +63,11 @@ int dm_spi_claim_bus(struct udevice *dev)
                int ret = spi_set_speed_mode(bus, speed, slave->mode);
 
                if (ret)
-                       return ret;
+                       return log_ret(ret);
                slave->speed = speed;
        }
 
-       return ops->claim_bus ? ops->claim_bus(dev) : 0;
+       return log_ret(ops->claim_bus ? ops->claim_bus(dev) : 0);
 }
 
 void dm_spi_release_bus(struct udevice *dev)
@@ -92,7 +92,7 @@ int dm_spi_xfer(struct udevice *dev, unsigned int bitlen,
 
 int spi_claim_bus(struct spi_slave *slave)
 {
-       return dm_spi_claim_bus(slave->dev);
+       return log_ret(dm_spi_claim_bus(slave->dev));
 }
 
 void spi_release_bus(struct spi_slave *slave)