aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-oc-tiny.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2013-02-12 12:48:37 -0500
committerGrant Likely <grant.likely@secretlab.ca>2013-02-13 05:11:53 -0500
commite80beb27d2f81a1c3c8887e0e0a82d77bb392d28 (patch)
tree1f81c7ffb20b23d5f7a157e996fbb176779af88a /drivers/spi/spi-oc-tiny.c
parentbd69f73f2c81eed9a398708b8c4bb3409ba1b0f9 (diff)
gpio: Make of_count_named_gpios() use new of_count_phandle_with_args()
This patch replaces the horribly coded of_count_named_gpios() with a call to of_count_phandle_with_args() which is far more efficient. This also changes the return value of of_gpio_count() & of_gpio_named_count() from 'unsigned int' to 'int' so that it can return an error code. All the users of that function are fixed up to correctly handle a negative return value. v2: Split GPIO portion into a separate patch Tested-by: Andreas Larsson <andreas@gaisler.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Rob Herring <rob.herring@calxeda.com>
Diffstat (limited to 'drivers/spi/spi-oc-tiny.c')
-rw-r--r--drivers/spi/spi-oc-tiny.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/spi/spi-oc-tiny.c b/drivers/spi/spi-oc-tiny.c
index 432e66ec3088..cb2e284bd814 100644
--- a/drivers/spi/spi-oc-tiny.c
+++ b/drivers/spi/spi-oc-tiny.c
@@ -54,7 +54,7 @@ struct tiny_spi {
54 unsigned int txc, rxc; 54 unsigned int txc, rxc;
55 const u8 *txp; 55 const u8 *txp;
56 u8 *rxp; 56 u8 *rxp;
57 unsigned int gpio_cs_count; 57 int gpio_cs_count;
58 int *gpio_cs; 58 int *gpio_cs;
59}; 59};
60 60
@@ -74,7 +74,7 @@ static void tiny_spi_chipselect(struct spi_device *spi, int is_active)
74{ 74{
75 struct tiny_spi *hw = tiny_spi_to_hw(spi); 75 struct tiny_spi *hw = tiny_spi_to_hw(spi);
76 76
77 if (hw->gpio_cs_count) { 77 if (hw->gpio_cs_count > 0) {
78 gpio_set_value(hw->gpio_cs[spi->chip_select], 78 gpio_set_value(hw->gpio_cs[spi->chip_select],
79 (spi->mode & SPI_CS_HIGH) ? is_active : !is_active); 79 (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
80 } 80 }
@@ -254,7 +254,7 @@ static int tiny_spi_of_probe(struct platform_device *pdev)
254 if (!np) 254 if (!np)
255 return 0; 255 return 0;
256 hw->gpio_cs_count = of_gpio_count(np); 256 hw->gpio_cs_count = of_gpio_count(np);
257 if (hw->gpio_cs_count) { 257 if (hw->gpio_cs_count > 0) {
258 hw->gpio_cs = devm_kzalloc(&pdev->dev, 258 hw->gpio_cs = devm_kzalloc(&pdev->dev,
259 hw->gpio_cs_count * sizeof(unsigned int), 259 hw->gpio_cs_count * sizeof(unsigned int),
260 GFP_KERNEL); 260 GFP_KERNEL);
@@ -352,7 +352,7 @@ static int tiny_spi_probe(struct platform_device *pdev)
352 goto exit_gpio; 352 goto exit_gpio;
353 gpio_direction_output(hw->gpio_cs[i], 1); 353 gpio_direction_output(hw->gpio_cs[i], 1);
354 } 354 }
355 hw->bitbang.master->num_chipselect = max(1U, hw->gpio_cs_count); 355 hw->bitbang.master->num_chipselect = max(1, hw->gpio_cs_count);
356 356
357 /* register our spi controller */ 357 /* register our spi controller */
358 err = spi_bitbang_start(&hw->bitbang); 358 err = spi_bitbang_start(&hw->bitbang);