diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2013-02-12 12:48:37 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2013-02-13 05:11:53 -0500 |
commit | e80beb27d2f81a1c3c8887e0e0a82d77bb392d28 (patch) | |
tree | 1f81c7ffb20b23d5f7a157e996fbb176779af88a /drivers/hwmon/gpio-fan.c | |
parent | bd69f73f2c81eed9a398708b8c4bb3409ba1b0f9 (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/hwmon/gpio-fan.c')
-rw-r--r-- | drivers/hwmon/gpio-fan.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index 4e04c1228e51..39781945a5d2 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c | |||
@@ -422,7 +422,7 @@ static int gpio_fan_get_of_pdata(struct device *dev, | |||
422 | 422 | ||
423 | /* Fill GPIO pin array */ | 423 | /* Fill GPIO pin array */ |
424 | pdata->num_ctrl = of_gpio_count(node); | 424 | pdata->num_ctrl = of_gpio_count(node); |
425 | if (!pdata->num_ctrl) { | 425 | if (pdata->num_ctrl <= 0) { |
426 | dev_err(dev, "gpios DT property empty / missing"); | 426 | dev_err(dev, "gpios DT property empty / missing"); |
427 | return -ENODEV; | 427 | return -ENODEV; |
428 | } | 428 | } |
@@ -477,7 +477,7 @@ static int gpio_fan_get_of_pdata(struct device *dev, | |||
477 | pdata->speed = speed; | 477 | pdata->speed = speed; |
478 | 478 | ||
479 | /* Alarm GPIO if one exists */ | 479 | /* Alarm GPIO if one exists */ |
480 | if (of_gpio_named_count(node, "alarm-gpios")) { | 480 | if (of_gpio_named_count(node, "alarm-gpios") > 0) { |
481 | struct gpio_fan_alarm *alarm; | 481 | struct gpio_fan_alarm *alarm; |
482 | int val; | 482 | int val; |
483 | enum of_gpio_flags flags; | 483 | enum of_gpio_flags flags; |