summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorSimon Guinot <simon.guinot@sequanux.org>2015-02-25 12:58:19 -0500
committerGuenter Roeck <linux@roeck-us.net>2015-03-09 12:59:36 -0400
commit73ef85f42da2df8b567fea109c67ed53db937bcc (patch)
tree0b72ae38e8aeb5d432827e753b690438bae1244d /drivers/hwmon
parent6552f327cab8eb6c773ba4f702cf6a371d1dc467 (diff)
hwmon: (gpio-fan) allow to use alarm support alone from DT
On some boards, such as the LaCie 2Big Network v2 or 2Big NAS (based on Marvell Kirkwood SoCs), an I2C fan controller is used but the alarm signal is wired to a separate GPIO. Unfortunately, the gpio-fan driver can't be used to handle GPIO alarm alone from DT: an error is returned if the "gpios" DT property is missing. This patch allows to use the gpio-fan driver even if the "alarm-gpios" DT property is defined alone. Signed-off-by: Simon Guinot <simon.guinot@sequanux.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/gpio-fan.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
index 36abf814b8c7..c241f5b0b7cf 100644
--- a/drivers/hwmon/gpio-fan.c
+++ b/drivers/hwmon/gpio-fan.c
@@ -404,10 +404,32 @@ static int gpio_fan_get_of_pdata(struct device *dev,
404 404
405 node = dev->of_node; 405 node = dev->of_node;
406 406
407 /* Alarm GPIO if one exists */
408 if (of_gpio_named_count(node, "alarm-gpios") > 0) {
409 struct gpio_fan_alarm *alarm;
410 int val;
411 enum of_gpio_flags flags;
412
413 alarm = devm_kzalloc(dev, sizeof(struct gpio_fan_alarm),
414 GFP_KERNEL);
415 if (!alarm)
416 return -ENOMEM;
417
418 val = of_get_named_gpio_flags(node, "alarm-gpios", 0, &flags);
419 if (val < 0)
420 return val;
421 alarm->gpio = val;
422 alarm->active_low = flags & OF_GPIO_ACTIVE_LOW;
423
424 pdata->alarm = alarm;
425 }
426
407 /* Fill GPIO pin array */ 427 /* Fill GPIO pin array */
408 pdata->num_ctrl = of_gpio_count(node); 428 pdata->num_ctrl = of_gpio_count(node);
409 if (pdata->num_ctrl <= 0) { 429 if (pdata->num_ctrl <= 0) {
410 dev_err(dev, "gpios DT property empty / missing"); 430 if (pdata->alarm)
431 return 0;
432 dev_err(dev, "DT properties empty / missing");
411 return -ENODEV; 433 return -ENODEV;
412 } 434 }
413 ctrl = devm_kzalloc(dev, pdata->num_ctrl * sizeof(unsigned), 435 ctrl = devm_kzalloc(dev, pdata->num_ctrl * sizeof(unsigned),
@@ -460,26 +482,6 @@ static int gpio_fan_get_of_pdata(struct device *dev,
460 } 482 }
461 pdata->speed = speed; 483 pdata->speed = speed;
462 484
463 /* Alarm GPIO if one exists */
464 if (of_gpio_named_count(node, "alarm-gpios") > 0) {
465 struct gpio_fan_alarm *alarm;
466 int val;
467 enum of_gpio_flags flags;
468
469 alarm = devm_kzalloc(dev, sizeof(struct gpio_fan_alarm),
470 GFP_KERNEL);
471 if (!alarm)
472 return -ENOMEM;
473
474 val = of_get_named_gpio_flags(node, "alarm-gpios", 0, &flags);
475 if (val < 0)
476 return val;
477 alarm->gpio = val;
478 alarm->active_low = flags & OF_GPIO_ACTIVE_LOW;
479
480 pdata->alarm = alarm;
481 }
482
483 return 0; 485 return 0;
484} 486}
485 487