public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 1/4] dm: spi: Return 0 if driver does not implement ops->cs_info
@ 2019-09-09 13:00 Bin Meng
  2019-09-09 13:00 ` [U-Boot] [PATCH v2 2/4] dm: spi: Change cs_info op to return -EINVAL for invalid cs num Bin Meng
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Bin Meng @ 2019-09-09 13:00 UTC (permalink / raw)
  To: u-boot

If an SPI controller driver does not implement ops->cs_info, that
probably means any chip select number could be valid, hence let's
return 0 for spi_cs_info().

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>

---

Changes in v2:
- update spi-howto.rst to reflect the code changes

 doc/driver-model/spi-howto.rst | 4 ++--
 drivers/spi/spi-uclass.c       | 7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/doc/driver-model/spi-howto.rst b/doc/driver-model/spi-howto.rst
index a538fdc..7e64fae 100644
--- a/doc/driver-model/spi-howto.rst
+++ b/doc/driver-model/spi-howto.rst
@@ -634,8 +634,8 @@ method for cs_info() to deal with this. If you don't provide it, then the
 device tree will be used to determine what chip selects are valid.
 
 Return -ENODEV if the supplied chip select is invalid, or 0 if it is valid.
-If you don't provide the cs_info() method, -ENODEV is assumed for all
-chip selects that do not appear in the device tree.
+If you don't provide the cs_info() method, 0 is assumed for all chip selects
+that do not appear in the device tree.
 
 
 Test it
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 88cb2a1..24de0b5 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -237,11 +237,10 @@ int spi_cs_info(struct udevice *bus, uint cs, struct spi_cs_info *info)
 		return ops->cs_info(bus, cs, info);
 
 	/*
-	 * We could assume there is at least one valid chip select, but best
-	 * to be sure and return an error in this case. The driver didn't
-	 * care enough to tell us.
+	 * We could assume there is at least one valid chip select.
+	 * The driver didn't care enough to tell us.
 	 */
-	return -ENODEV;
+	return 0;
 }
 
 int spi_find_bus_and_cs(int busnum, int cs, struct udevice **busp,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-01-09 13:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-09 13:00 [U-Boot] [PATCH v2 1/4] dm: spi: Return 0 if driver does not implement ops->cs_info Bin Meng
2019-09-09 13:00 ` [U-Boot] [PATCH v2 2/4] dm: spi: Change cs_info op to return -EINVAL for invalid cs num Bin Meng
2019-09-09 13:00 ` [U-Boot] [PATCH v2 3/4] dm: spi: Check cs number before accessing slaves Bin Meng
2019-10-16 14:05   ` Jagan Teki
2019-10-16 15:21   ` Jagan Teki
2019-10-29 10:15     ` Bin Meng
2019-11-18  7:15       ` Bin Meng
2020-01-09 13:47         ` Bin Meng
2020-01-09 13:48           ` Jagan Teki
2019-09-09 13:00 ` [U-Boot] [PATCH v2 4/4] test: dm: spi: Fix sandbox dm_test_spi_find() Bin Meng
2019-10-16 14:07   ` Jagan Teki
2019-09-29  8:04 ` [U-Boot] [PATCH v2 1/4] dm: spi: Return 0 if driver does not implement ops->cs_info Bin Meng
2019-10-08 12:59   ` Bin Meng
2019-10-14  2:33     ` Bin Meng
2019-10-16 10:14   ` Jagan Teki
2019-10-16 13:58 ` Jagan Teki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox