diff options
author | Andreas Larsson <andreas@gaisler.com> | 2013-02-13 08:23:24 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2013-04-07 05:12:21 -0400 |
commit | 8ec5d84ef51cc64ed02bb9bf0e43a652178252c1 (patch) | |
tree | 03c1baca689bcd9b34cef525f7d7579a7e9662c5 /drivers/spi/spi.c | |
parent | 446411e18b2cb17d153e45f634a3c9a79ada3ac2 (diff) |
spi: Return error from of_spi_register_master on bad "cs-gpios" property
This makes sure that an error is returned on an incorrectly formed
"cs-gpios" property, but reports success when the "cs-gpios" property is
well formed or missing.
When holes in the cs-gpios property phandle list is used to indicate
that some other form of chipselect is to be used it is important that
failure to read a broken "cs-gpios" property does not silently fail
leading to the spi controller to use an unintended chipselect.
Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index bcca66c5107f..3738e7cbff33 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -1067,8 +1067,11 @@ static int of_spi_register_master(struct spi_master *master) | |||
1067 | nb = of_gpio_named_count(np, "cs-gpios"); | 1067 | nb = of_gpio_named_count(np, "cs-gpios"); |
1068 | master->num_chipselect = max(nb, (int)master->num_chipselect); | 1068 | master->num_chipselect = max(nb, (int)master->num_chipselect); |
1069 | 1069 | ||
1070 | if (nb < 1) | 1070 | /* Return error only for an incorrectly formed cs-gpios property */ |
1071 | if (nb == 0 || nb == -ENOENT) | ||
1071 | return 0; | 1072 | return 0; |
1073 | else if (nb < 0) | ||
1074 | return nb; | ||
1072 | 1075 | ||
1073 | cs = devm_kzalloc(&master->dev, | 1076 | cs = devm_kzalloc(&master->dev, |
1074 | sizeof(int) * master->num_chipselect, | 1077 | sizeof(int) * master->num_chipselect, |