aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/gpio-fan.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2017-09-25 19:09:07 -0400
committerGuenter Roeck <linux@roeck-us.net>2017-10-29 21:36:03 -0400
commita9b4c8afcd3d6c2b068e6ecf1a22ab26dd8c200e (patch)
treee63634771be0cf922289788402ea6f7eaf4ed3fa /drivers/hwmon/gpio-fan.c
parent8c0eb9bc52fad2fec7a5ff40d5da85b74232f5de (diff)
hwmon: (gpio-fan) Mandate OF_GPIO and cut pdata path
We have no users of platform data, we made platform data driver-local, so cut all #ifdefs for the platform data case, and depend on the Kconfig CONFIG_OF_GPIO symbol. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/gpio-fan.c')
-rw-r--r--drivers/hwmon/gpio-fan.c36
1 files changed, 10 insertions, 26 deletions
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
index ad7d8fdf4f81..55dbdb223e02 100644
--- a/drivers/hwmon/gpio-fan.c
+++ b/drivers/hwmon/gpio-fan.c
@@ -453,7 +453,6 @@ static const struct thermal_cooling_device_ops gpio_fan_cool_ops = {
453 .set_cur_state = gpio_fan_set_cur_state, 453 .set_cur_state = gpio_fan_set_cur_state,
454}; 454};
455 455
456#ifdef CONFIG_OF_GPIO
457/* 456/*
458 * Translate OpenFirmware node properties into platform_data 457 * Translate OpenFirmware node properties into platform_data
459 */ 458 */
@@ -556,7 +555,6 @@ static const struct of_device_id of_gpio_fan_match[] = {
556 {}, 555 {},
557}; 556};
558MODULE_DEVICE_TABLE(of, of_gpio_fan_match); 557MODULE_DEVICE_TABLE(of, of_gpio_fan_match);
559#endif /* CONFIG_OF_GPIO */
560 558
561static int gpio_fan_probe(struct platform_device *pdev) 559static int gpio_fan_probe(struct platform_device *pdev)
562{ 560{
@@ -564,29 +562,22 @@ static int gpio_fan_probe(struct platform_device *pdev)
564 struct gpio_fan_data *fan_data; 562 struct gpio_fan_data *fan_data;
565 struct device *dev = &pdev->dev; 563 struct device *dev = &pdev->dev;
566 struct device_node *np = dev->of_node; 564 struct device_node *np = dev->of_node;
567 struct gpio_fan_platform_data *pdata = dev_get_platdata(dev); 565 struct gpio_fan_platform_data *pdata;
568 566
569 fan_data = devm_kzalloc(dev, sizeof(struct gpio_fan_data), 567 fan_data = devm_kzalloc(dev, sizeof(struct gpio_fan_data),
570 GFP_KERNEL); 568 GFP_KERNEL);
571 if (!fan_data) 569 if (!fan_data)
572 return -ENOMEM; 570 return -ENOMEM;
573 571
574#ifdef CONFIG_OF_GPIO 572 pdata = devm_kzalloc(dev,
575 if (!pdata) { 573 sizeof(struct gpio_fan_platform_data),
576 pdata = devm_kzalloc(dev, 574 GFP_KERNEL);
577 sizeof(struct gpio_fan_platform_data),
578 GFP_KERNEL);
579 if (!pdata)
580 return -ENOMEM;
581
582 err = gpio_fan_get_of_pdata(dev, pdata);
583 if (err)
584 return err;
585 }
586#else /* CONFIG_OF_GPIO */
587 if (!pdata) 575 if (!pdata)
588 return -EINVAL; 576 return -ENOMEM;
589#endif /* CONFIG_OF_GPIO */ 577
578 err = gpio_fan_get_of_pdata(dev, pdata);
579 if (err)
580 return err;
590 581
591 fan_data->dev = dev; 582 fan_data->dev = dev;
592 platform_set_drvdata(pdev, fan_data); 583 platform_set_drvdata(pdev, fan_data);
@@ -615,17 +606,12 @@ static int gpio_fan_probe(struct platform_device *pdev)
615 gpio_fan_groups); 606 gpio_fan_groups);
616 if (IS_ERR(fan_data->hwmon_dev)) 607 if (IS_ERR(fan_data->hwmon_dev))
617 return PTR_ERR(fan_data->hwmon_dev); 608 return PTR_ERR(fan_data->hwmon_dev);
618#ifdef CONFIG_OF_GPIO 609
619 /* Optional cooling device register for Device tree platforms */ 610 /* Optional cooling device register for Device tree platforms */
620 fan_data->cdev = thermal_of_cooling_device_register(np, 611 fan_data->cdev = thermal_of_cooling_device_register(np,
621 "gpio-fan", 612 "gpio-fan",
622 fan_data, 613 fan_data,
623 &gpio_fan_cool_ops); 614 &gpio_fan_cool_ops);
624#else /* CONFIG_OF_GPIO */
625 /* Optional cooling device register for non Device tree platforms */
626 fan_data->cdev = thermal_cooling_device_register("gpio-fan", fan_data,
627 &gpio_fan_cool_ops);
628#endif /* CONFIG_OF_GPIO */
629 615
630 dev_info(dev, "GPIO fan initialized\n"); 616 dev_info(dev, "GPIO fan initialized\n");
631 617
@@ -686,9 +672,7 @@ static struct platform_driver gpio_fan_driver = {
686 .driver = { 672 .driver = {
687 .name = "gpio-fan", 673 .name = "gpio-fan",
688 .pm = GPIO_FAN_PM, 674 .pm = GPIO_FAN_PM,
689#ifdef CONFIG_OF_GPIO
690 .of_match_table = of_match_ptr(of_gpio_fan_match), 675 .of_match_table = of_match_ptr(of_gpio_fan_match),
691#endif
692 }, 676 },
693}; 677};
694 678