diff options
Diffstat (limited to 'drivers/hwmon/gpio-fan.c')
-rw-r--r-- | drivers/hwmon/gpio-fan.c | 44 |
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 | ||