Commit 6d20a6c060c41a7a9c8f5bd4b9d44b8f13b78694

Authored by Rafael J. Wysocki
Committed by Guenter Roeck
1 parent c248f24cff

hwmon: (gpio-fan) Use struct dev_pm_ops for power management

Make the gpio-fan driver define its PM callbacks through
a struct dev_pm_ops object rather than by using legacy PM hooks
in struct platform_driver.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
[linux@roeck-us.net: CONFIG_PM->CONFIG_PM_SLEEP, and remove unnecessary ()]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Showing 1 changed file with 11 additions and 10 deletions Side-by-side Diff

drivers/hwmon/gpio-fan.c
... ... @@ -41,7 +41,7 @@
41 41 int num_speed;
42 42 struct gpio_fan_speed *speed;
43 43 int speed_index;
44   -#ifdef CONFIG_PM
  44 +#ifdef CONFIG_PM_SLEEP
45 45 int resume_speed;
46 46 #endif
47 47 bool pwm_enable;
48 48  
... ... @@ -476,10 +476,10 @@
476 476 return 0;
477 477 }
478 478  
479   -#ifdef CONFIG_PM
480   -static int gpio_fan_suspend(struct platform_device *pdev, pm_message_t state)
  479 +#ifdef CONFIG_PM_SLEEP
  480 +static int gpio_fan_suspend(struct device *dev)
481 481 {
482   - struct gpio_fan_data *fan_data = platform_get_drvdata(pdev);
  482 + struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
483 483  
484 484 if (fan_data->ctrl) {
485 485 fan_data->resume_speed = fan_data->speed_index;
486 486  
487 487  
488 488  
489 489  
490 490  
... ... @@ -489,27 +489,28 @@
489 489 return 0;
490 490 }
491 491  
492   -static int gpio_fan_resume(struct platform_device *pdev)
  492 +static int gpio_fan_resume(struct device *dev)
493 493 {
494   - struct gpio_fan_data *fan_data = platform_get_drvdata(pdev);
  494 + struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
495 495  
496 496 if (fan_data->ctrl)
497 497 set_fan_speed(fan_data, fan_data->resume_speed);
498 498  
499 499 return 0;
500 500 }
  501 +
  502 +static SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);
  503 +#define GPIO_FAN_PM &gpio_fan_pm
501 504 #else
502   -#define gpio_fan_suspend NULL
503   -#define gpio_fan_resume NULL
  505 +#define GPIO_FAN_PM NULL
504 506 #endif
505 507  
506 508 static struct platform_driver gpio_fan_driver = {
507 509 .probe = gpio_fan_probe,
508 510 .remove = __devexit_p(gpio_fan_remove),
509   - .suspend = gpio_fan_suspend,
510   - .resume = gpio_fan_resume,
511 511 .driver = {
512 512 .name = "gpio-fan",
  513 + .pm = GPIO_FAN_PM,
513 514 },
514 515 };
515 516