From 4dd520b36bce9b35f7a12f3ffd9a95269d425170 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 9 Sep 2019 06:00:00 -0700 Subject: [PATCH] dm: spi: Return 0 if driver does not implement ops->cs_info 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 Tested-by: Jagan Teki # SoPine Reviewed-by: Jagan Teki --- 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 5540eb7d38..44eab3947e 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 a4d1b65682..947516073e 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -261,11 +261,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.39.5