aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/gpio-fan.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-05-16 10:56:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-16 10:56:57 -0400
commita455eda33faafcaac1effb31d682765b14ef868c (patch)
tree9a4ca7da47300ca9081445539ff337efcead4b6b /drivers/hwmon/gpio-fan.c
parentcc7ce90153e74f8266eefee9fba466faa1a2d5df (diff)
parent37bcec5d9f71bd13142a97d2196b293c9ac23823 (diff)
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal
Pull thermal soc updates from Eduardo Valentin: - thermal core has a new devm_* API for registering cooling devices. I took the entire series, that is why you see changes on drivers/hwmon in this pull (Guenter Roeck) - rockchip thermal driver gains support to PX30 SoC (Elaine Zhang) - the generic-adc thermal driver now considers the lookup table DT property as optional (Jean-Francois Dagenais) - Refactoring of tsens thermal driver (Amit Kucheria) - Cleanups on cpu cooling driver (Daniel Lezcano) - broadcom thermal driver dropped support to ACPI (Srinath Mannam) - tegra thermal driver gains support to OC hw throttle and GPU throtle (Wei Ni) - Fixes in several thermal drivers. * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal: (59 commits) hwmon: (pwm-fan) Use devm_thermal_of_cooling_device_register hwmon: (npcm750-pwm-fan) Use devm_thermal_of_cooling_device_register hwmon: (mlxreg-fan) Use devm_thermal_of_cooling_device_register hwmon: (gpio-fan) Use devm_thermal_of_cooling_device_register hwmon: (aspeed-pwm-tacho) Use devm_thermal_of_cooling_device_register thermal: rcar_gen3_thermal: Fix to show correct trip points number thermal: rcar_thermal: update calculation formula for R-Car Gen3 SoCs thermal: cpu_cooling: Actually trace CPU load in thermal_power_cpu_get_power thermal: rockchip: Support the PX30 SoC in thermal driver dt-bindings: rockchip-thermal: Support the PX30 SoC compatible thermal: rockchip: fix up the tsadc pinctrl setting error thermal: broadcom: Remove ACPI support thermal: Fix build error of missing devm_ioremap_resource on UM thermal/drivers/cpu_cooling: Remove pointless field thermal/drivers/cpu_cooling: Add Software Package Data Exchange (SPDX) thermal/drivers/cpu_cooling: Fixup the header and copyright thermal/drivers/cpu_cooling: Remove pointless test in power2state() thermal: rcar_gen3_thermal: disable interrupt in .remove thermal: rcar_gen3_thermal: fix interrupt type thermal: Introduce devm_thermal_of_cooling_device_register ...
Diffstat (limited to 'drivers/hwmon/gpio-fan.c')
-rw-r--r--drivers/hwmon/gpio-fan.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
index f1bf67aca9e8..3f6e5b4e3997 100644
--- a/drivers/hwmon/gpio-fan.c
+++ b/drivers/hwmon/gpio-fan.c
@@ -498,6 +498,11 @@ static const struct of_device_id of_gpio_fan_match[] = {
498}; 498};
499MODULE_DEVICE_TABLE(of, of_gpio_fan_match); 499MODULE_DEVICE_TABLE(of, of_gpio_fan_match);
500 500
501static void gpio_fan_stop(void *data)
502{
503 set_fan_speed(data, 0);
504}
505
501static int gpio_fan_probe(struct platform_device *pdev) 506static int gpio_fan_probe(struct platform_device *pdev)
502{ 507{
503 int err; 508 int err;
@@ -532,6 +537,7 @@ static int gpio_fan_probe(struct platform_device *pdev)
532 err = fan_ctrl_init(fan_data); 537 err = fan_ctrl_init(fan_data);
533 if (err) 538 if (err)
534 return err; 539 return err;
540 devm_add_action_or_reset(dev, gpio_fan_stop, fan_data);
535 } 541 }
536 542
537 /* Make this driver part of hwmon class. */ 543 /* Make this driver part of hwmon class. */
@@ -543,32 +549,20 @@ static int gpio_fan_probe(struct platform_device *pdev)
543 return PTR_ERR(fan_data->hwmon_dev); 549 return PTR_ERR(fan_data->hwmon_dev);
544 550
545 /* Optional cooling device register for Device tree platforms */ 551 /* Optional cooling device register for Device tree platforms */
546 fan_data->cdev = thermal_of_cooling_device_register(np, 552 fan_data->cdev = devm_thermal_of_cooling_device_register(dev, np,
547 "gpio-fan", 553 "gpio-fan", fan_data, &gpio_fan_cool_ops);
548 fan_data,
549 &gpio_fan_cool_ops);
550 554
551 dev_info(dev, "GPIO fan initialized\n"); 555 dev_info(dev, "GPIO fan initialized\n");
552 556
553 return 0; 557 return 0;
554} 558}
555 559
556static int gpio_fan_remove(struct platform_device *pdev) 560static void gpio_fan_shutdown(struct platform_device *pdev)
557{ 561{
558 struct gpio_fan_data *fan_data = platform_get_drvdata(pdev); 562 struct gpio_fan_data *fan_data = platform_get_drvdata(pdev);
559 563
560 if (!IS_ERR(fan_data->cdev))
561 thermal_cooling_device_unregister(fan_data->cdev);
562
563 if (fan_data->gpios) 564 if (fan_data->gpios)
564 set_fan_speed(fan_data, 0); 565 set_fan_speed(fan_data, 0);
565
566 return 0;
567}
568
569static void gpio_fan_shutdown(struct platform_device *pdev)
570{
571 gpio_fan_remove(pdev);
572} 566}
573 567
574#ifdef CONFIG_PM_SLEEP 568#ifdef CONFIG_PM_SLEEP
@@ -602,7 +596,6 @@ static SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);
602 596
603static struct platform_driver gpio_fan_driver = { 597static struct platform_driver gpio_fan_driver = {
604 .probe = gpio_fan_probe, 598 .probe = gpio_fan_probe,
605 .remove = gpio_fan_remove,
606 .shutdown = gpio_fan_shutdown, 599 .shutdown = gpio_fan_shutdown,
607 .driver = { 600 .driver = {
608 .name = "gpio-fan", 601 .name = "gpio-fan",