governor_powersave.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * linux/drivers/devfreq/governor_powersave.c
  3. *
  4. * Copyright (C) 2011 Samsung Electronics
  5. * MyungJoo Ham <myungjoo.ham@samsung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/devfreq.h>
  12. #include <linux/module.h>
  13. #include "governor.h"
  14. static int devfreq_powersave_func(struct devfreq *df,
  15. unsigned long *freq)
  16. {
  17. /*
  18. * target callback should be able to get ceiling value as
  19. * said in devfreq.h
  20. */
  21. *freq = df->min_freq;
  22. return 0;
  23. }
  24. static int devfreq_powersave_handler(struct devfreq *devfreq,
  25. unsigned int event, void *data)
  26. {
  27. int ret = 0;
  28. if (event == DEVFREQ_GOV_START) {
  29. mutex_lock(&devfreq->lock);
  30. ret = update_devfreq(devfreq);
  31. mutex_unlock(&devfreq->lock);
  32. }
  33. return ret;
  34. }
  35. static struct devfreq_governor devfreq_powersave = {
  36. .name = "powersave",
  37. .get_target_freq = devfreq_powersave_func,
  38. .event_handler = devfreq_powersave_handler,
  39. };
  40. static int __init devfreq_powersave_init(void)
  41. {
  42. return devfreq_add_governor(&devfreq_powersave);
  43. }
  44. subsys_initcall(devfreq_powersave_init);
  45. static void __exit devfreq_powersave_exit(void)
  46. {
  47. int ret;
  48. ret = devfreq_remove_governor(&devfreq_powersave);
  49. if (ret)
  50. pr_err("%s: failed remove governor %d\n", __func__, ret);
  51. return;
  52. }
  53. module_exit(devfreq_powersave_exit);
  54. MODULE_LICENSE("GPL");