governor_performance.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * linux/drivers/devfreq/governor_performance.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_performance_func(struct devfreq *df,
  15. unsigned long *freq)
  16. {
  17. /*
  18. * target callback should be able to get floor value as
  19. * said in devfreq.h
  20. */
  21. if (!df->max_freq)
  22. *freq = UINT_MAX;
  23. else
  24. *freq = df->max_freq;
  25. return 0;
  26. }
  27. static int devfreq_performance_handler(struct devfreq *devfreq,
  28. unsigned int event, void *data)
  29. {
  30. int ret = 0;
  31. if (event == DEVFREQ_GOV_START) {
  32. mutex_lock(&devfreq->lock);
  33. ret = update_devfreq(devfreq);
  34. mutex_unlock(&devfreq->lock);
  35. }
  36. return ret;
  37. }
  38. static struct devfreq_governor devfreq_performance = {
  39. .name = "performance",
  40. .get_target_freq = devfreq_performance_func,
  41. .event_handler = devfreq_performance_handler,
  42. };
  43. static int __init devfreq_performance_init(void)
  44. {
  45. return devfreq_add_governor(&devfreq_performance);
  46. }
  47. subsys_initcall(devfreq_performance_init);
  48. static void __exit devfreq_performance_exit(void)
  49. {
  50. int ret;
  51. ret = devfreq_remove_governor(&devfreq_performance);
  52. if (ret)
  53. pr_err("%s: failed remove governor %d\n", __func__, ret);
  54. return;
  55. }
  56. module_exit(devfreq_performance_exit);
  57. MODULE_LICENSE("GPL");