diff options
Diffstat (limited to 'drivers/hwmon/gpio-fan.c')
-rw-r--r-- | drivers/hwmon/gpio-fan.c | 25 |
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 | }; |
499 | MODULE_DEVICE_TABLE(of, of_gpio_fan_match); | 499 | MODULE_DEVICE_TABLE(of, of_gpio_fan_match); |
500 | 500 | ||
501 | static void gpio_fan_stop(void *data) | ||
502 | { | ||
503 | set_fan_speed(data, 0); | ||
504 | } | ||
505 | |||
501 | static int gpio_fan_probe(struct platform_device *pdev) | 506 | static 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 | ||
556 | static int gpio_fan_remove(struct platform_device *pdev) | 560 | static 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 | |||
569 | static 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 | ||
603 | static struct platform_driver gpio_fan_driver = { | 597 | static 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", |