diff options
author | Andreas Larsson <andreas@gaisler.com> | 2013-02-13 08:20:25 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2013-04-07 05:12:20 -0400 |
commit | 446411e18b2cb17d153e45f634a3c9a79ada3ac2 (patch) | |
tree | d0b227257591b9a010d453bef1bd2645901e3f0d | |
parent | 3d3522604a5557e80fdcab61c54bd04eaf15b525 (diff) |
spi: Initialize cs_gpio and cs_gpios with -ENOENT
The return value from of_get_named_gpio is -ENOENT when the given index
matches a hole in the "cs-gpios" property phandle list. However, the
default value of cs_gpio in struct spi_device and entries of cs_gpios in
struct spi_master is -EINVAL, which is documented to indicate that a
GPIO line should not be used for the given spi_device.
This sets the default value of cs_gpio in struct spi_device and entries
of cs_gpios in struct spi_master to -ENOENT. Thus, -ENOENT is the only
value used to indicate that no GPIO line should be used.
Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
-rw-r--r-- | drivers/spi/spi.c | 4 | ||||
-rw-r--r-- | include/linux/spi/spi.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 004b10f184d4..bcca66c5107f 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -334,7 +334,7 @@ struct spi_device *spi_alloc_device(struct spi_master *master) | |||
334 | spi->dev.parent = &master->dev; | 334 | spi->dev.parent = &master->dev; |
335 | spi->dev.bus = &spi_bus_type; | 335 | spi->dev.bus = &spi_bus_type; |
336 | spi->dev.release = spidev_release; | 336 | spi->dev.release = spidev_release; |
337 | spi->cs_gpio = -EINVAL; | 337 | spi->cs_gpio = -ENOENT; |
338 | device_initialize(&spi->dev); | 338 | device_initialize(&spi->dev); |
339 | return spi; | 339 | return spi; |
340 | } | 340 | } |
@@ -1079,7 +1079,7 @@ static int of_spi_register_master(struct spi_master *master) | |||
1079 | return -ENOMEM; | 1079 | return -ENOMEM; |
1080 | 1080 | ||
1081 | for (i = 0; i < master->num_chipselect; i++) | 1081 | for (i = 0; i < master->num_chipselect; i++) |
1082 | cs[i] = -EINVAL; | 1082 | cs[i] = -ENOENT; |
1083 | 1083 | ||
1084 | for (i = 0; i < nb; i++) | 1084 | for (i = 0; i < nb; i++) |
1085 | cs[i] = of_get_named_gpio(np, "cs-gpios", i); | 1085 | cs[i] = of_get_named_gpio(np, "cs-gpios", i); |
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 38c2b925923d..c395f32b53b3 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h | |||
@@ -57,7 +57,7 @@ extern struct bus_type spi_bus_type; | |||
57 | * @modalias: Name of the driver to use with this device, or an alias | 57 | * @modalias: Name of the driver to use with this device, or an alias |
58 | * for that name. This appears in the sysfs "modalias" attribute | 58 | * for that name. This appears in the sysfs "modalias" attribute |
59 | * for driver coldplugging, and in uevents used for hotplugging | 59 | * for driver coldplugging, and in uevents used for hotplugging |
60 | * @cs_gpio: gpio number of the chipselect line (optional, -EINVAL when | 60 | * @cs_gpio: gpio number of the chipselect line (optional, -ENOENT when |
61 | * when not using a GPIO line) | 61 | * when not using a GPIO line) |
62 | * | 62 | * |
63 | * A @spi_device is used to interchange data between an SPI slave | 63 | * A @spi_device is used to interchange data between an SPI slave |
@@ -261,7 +261,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) | |||
261 | * queue so the subsystem notifies the driver that it may relax the | 261 | * queue so the subsystem notifies the driver that it may relax the |
262 | * hardware by issuing this call | 262 | * hardware by issuing this call |
263 | * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS | 263 | * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS |
264 | * number. Any individual value may be -EINVAL for CS lines that | 264 | * number. Any individual value may be -ENOENT for CS lines that |
265 | * are not GPIOs (driven by the SPI controller itself). | 265 | * are not GPIOs (driven by the SPI controller itself). |
266 | * | 266 | * |
267 | * Each SPI master controller can communicate with one or more @spi_device | 267 | * Each SPI master controller can communicate with one or more @spi_device |