devfreq.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. /*
  2. * devfreq: Generic Dynamic Voltage and Frequency Scaling (DVFS) Framework
  3. * for Non-CPU Devices.
  4. *
  5. * Copyright (C) 2011 Samsung Electronics
  6. * MyungJoo Ham <myungjoo.ham@samsung.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/sched.h>
  14. #include <linux/errno.h>
  15. #include <linux/err.h>
  16. #include <linux/init.h>
  17. #include <linux/module.h>
  18. #include <linux/slab.h>
  19. #include <linux/stat.h>
  20. #include <linux/opp.h>
  21. #include <linux/devfreq.h>
  22. #include <linux/workqueue.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/list.h>
  25. #include <linux/printk.h>
  26. #include <linux/hrtimer.h>
  27. #include "governor.h"
  28. struct class *devfreq_class;
  29. /*
  30. * devfreq core provides delayed work based load monitoring helper
  31. * functions. Governors can use these or can implement their own
  32. * monitoring mechanism.
  33. */
  34. static struct workqueue_struct *devfreq_wq;
  35. /* The list of all device-devfreq */
  36. static LIST_HEAD(devfreq_list);
  37. static DEFINE_MUTEX(devfreq_list_lock);
  38. /**
  39. * find_device_devfreq() - find devfreq struct using device pointer
  40. * @dev: device pointer used to lookup device devfreq.
  41. *
  42. * Search the list of device devfreqs and return the matched device's
  43. * devfreq info. devfreq_list_lock should be held by the caller.
  44. */
  45. static struct devfreq *find_device_devfreq(struct device *dev)
  46. {
  47. struct devfreq *tmp_devfreq;
  48. if (unlikely(IS_ERR_OR_NULL(dev))) {
  49. pr_err("DEVFREQ: %s: Invalid parameters\n", __func__);
  50. return ERR_PTR(-EINVAL);
  51. }
  52. WARN(!mutex_is_locked(&devfreq_list_lock),
  53. "devfreq_list_lock must be locked.");
  54. list_for_each_entry(tmp_devfreq, &devfreq_list, node) {
  55. if (tmp_devfreq->dev.parent == dev)
  56. return tmp_devfreq;
  57. }
  58. return ERR_PTR(-ENODEV);
  59. }
  60. /* Load monitoring helper functions for governors use */
  61. /**
  62. * update_devfreq() - Reevaluate the device and configure frequency.
  63. * @devfreq: the devfreq instance.
  64. *
  65. * Note: Lock devfreq->lock before calling update_devfreq
  66. * This function is exported for governors.
  67. */
  68. int update_devfreq(struct devfreq *devfreq)
  69. {
  70. unsigned long freq;
  71. int err = 0;
  72. u32 flags = 0;
  73. if (!mutex_is_locked(&devfreq->lock)) {
  74. WARN(true, "devfreq->lock must be locked by the caller.\n");
  75. return -EINVAL;
  76. }
  77. /* Reevaluate the proper frequency */
  78. err = devfreq->governor->get_target_freq(devfreq, &freq);
  79. if (err)
  80. return err;
  81. /*
  82. * Adjust the freuqency with user freq and QoS.
  83. *
  84. * List from the highest proiority
  85. * max_freq (probably called by thermal when it's too hot)
  86. * min_freq
  87. */
  88. if (devfreq->min_freq && freq < devfreq->min_freq) {
  89. freq = devfreq->min_freq;
  90. flags &= ~DEVFREQ_FLAG_LEAST_UPPER_BOUND; /* Use GLB */
  91. }
  92. if (devfreq->max_freq && freq > devfreq->max_freq) {
  93. freq = devfreq->max_freq;
  94. flags |= DEVFREQ_FLAG_LEAST_UPPER_BOUND; /* Use LUB */
  95. }
  96. err = devfreq->profile->target(devfreq->dev.parent, &freq, flags);
  97. if (err)
  98. return err;
  99. devfreq->previous_freq = freq;
  100. return err;
  101. }
  102. /**
  103. * devfreq_monitor() - Periodically poll devfreq objects.
  104. * @work: the work struct used to run devfreq_monitor periodically.
  105. *
  106. */
  107. static void devfreq_monitor(struct work_struct *work)
  108. {
  109. int err;
  110. struct devfreq *devfreq = container_of(work,
  111. struct devfreq, work.work);
  112. mutex_lock(&devfreq->lock);
  113. err = update_devfreq(devfreq);
  114. if (err)
  115. dev_err(&devfreq->dev, "dvfs failed with (%d) error\n", err);
  116. queue_delayed_work(devfreq_wq, &devfreq->work,
  117. msecs_to_jiffies(devfreq->profile->polling_ms));
  118. mutex_unlock(&devfreq->lock);
  119. }
  120. /**
  121. * devfreq_monitor_start() - Start load monitoring of devfreq instance
  122. * @devfreq: the devfreq instance.
  123. *
  124. * Helper function for starting devfreq device load monitoing. By
  125. * default delayed work based monitoring is supported. Function
  126. * to be called from governor in response to DEVFREQ_GOV_START
  127. * event when device is added to devfreq framework.
  128. */
  129. void devfreq_monitor_start(struct devfreq *devfreq)
  130. {
  131. INIT_DEFERRABLE_WORK(&devfreq->work, devfreq_monitor);
  132. if (devfreq->profile->polling_ms)
  133. queue_delayed_work(devfreq_wq, &devfreq->work,
  134. msecs_to_jiffies(devfreq->profile->polling_ms));
  135. }
  136. /**
  137. * devfreq_monitor_stop() - Stop load monitoring of a devfreq instance
  138. * @devfreq: the devfreq instance.
  139. *
  140. * Helper function to stop devfreq device load monitoing. Function
  141. * to be called from governor in response to DEVFREQ_GOV_STOP
  142. * event when device is removed from devfreq framework.
  143. */
  144. void devfreq_monitor_stop(struct devfreq *devfreq)
  145. {
  146. cancel_delayed_work_sync(&devfreq->work);
  147. }
  148. /**
  149. * devfreq_monitor_suspend() - Suspend load monitoring of a devfreq instance
  150. * @devfreq: the devfreq instance.
  151. *
  152. * Helper function to suspend devfreq device load monitoing. Function
  153. * to be called from governor in response to DEVFREQ_GOV_SUSPEND
  154. * event or when polling interval is set to zero.
  155. *
  156. * Note: Though this function is same as devfreq_monitor_stop(),
  157. * intentionally kept separate to provide hooks for collecting
  158. * transition statistics.
  159. */
  160. void devfreq_monitor_suspend(struct devfreq *devfreq)
  161. {
  162. mutex_lock(&devfreq->lock);
  163. if (devfreq->stop_polling) {
  164. mutex_unlock(&devfreq->lock);
  165. return;
  166. }
  167. devfreq->stop_polling = true;
  168. mutex_unlock(&devfreq->lock);
  169. cancel_delayed_work_sync(&devfreq->work);
  170. }
  171. /**
  172. * devfreq_monitor_resume() - Resume load monitoring of a devfreq instance
  173. * @devfreq: the devfreq instance.
  174. *
  175. * Helper function to resume devfreq device load monitoing. Function
  176. * to be called from governor in response to DEVFREQ_GOV_RESUME
  177. * event or when polling interval is set to non-zero.
  178. */
  179. void devfreq_monitor_resume(struct devfreq *devfreq)
  180. {
  181. mutex_lock(&devfreq->lock);
  182. if (!devfreq->stop_polling)
  183. goto out;
  184. if (!delayed_work_pending(&devfreq->work) &&
  185. devfreq->profile->polling_ms)
  186. queue_delayed_work(devfreq_wq, &devfreq->work,
  187. msecs_to_jiffies(devfreq->profile->polling_ms));
  188. devfreq->stop_polling = false;
  189. out:
  190. mutex_unlock(&devfreq->lock);
  191. }
  192. /**
  193. * devfreq_interval_update() - Update device devfreq monitoring interval
  194. * @devfreq: the devfreq instance.
  195. * @delay: new polling interval to be set.
  196. *
  197. * Helper function to set new load monitoring polling interval. Function
  198. * to be called from governor in response to DEVFREQ_GOV_INTERVAL event.
  199. */
  200. void devfreq_interval_update(struct devfreq *devfreq, unsigned int *delay)
  201. {
  202. unsigned int cur_delay = devfreq->profile->polling_ms;
  203. unsigned int new_delay = *delay;
  204. mutex_lock(&devfreq->lock);
  205. devfreq->profile->polling_ms = new_delay;
  206. if (devfreq->stop_polling)
  207. goto out;
  208. /* if new delay is zero, stop polling */
  209. if (!new_delay) {
  210. mutex_unlock(&devfreq->lock);
  211. cancel_delayed_work_sync(&devfreq->work);
  212. return;
  213. }
  214. /* if current delay is zero, start polling with new delay */
  215. if (!cur_delay) {
  216. queue_delayed_work(devfreq_wq, &devfreq->work,
  217. msecs_to_jiffies(devfreq->profile->polling_ms));
  218. goto out;
  219. }
  220. /* if current delay is greater than new delay, restart polling */
  221. if (cur_delay > new_delay) {
  222. mutex_unlock(&devfreq->lock);
  223. cancel_delayed_work_sync(&devfreq->work);
  224. mutex_lock(&devfreq->lock);
  225. if (!devfreq->stop_polling)
  226. queue_delayed_work(devfreq_wq, &devfreq->work,
  227. msecs_to_jiffies(devfreq->profile->polling_ms));
  228. }
  229. out:
  230. mutex_unlock(&devfreq->lock);
  231. }
  232. /**
  233. * devfreq_notifier_call() - Notify that the device frequency requirements
  234. * has been changed out of devfreq framework.
  235. * @nb the notifier_block (supposed to be devfreq->nb)
  236. * @type not used
  237. * @devp not used
  238. *
  239. * Called by a notifier that uses devfreq->nb.
  240. */
  241. static int devfreq_notifier_call(struct notifier_block *nb, unsigned long type,
  242. void *devp)
  243. {
  244. struct devfreq *devfreq = container_of(nb, struct devfreq, nb);
  245. int ret;
  246. mutex_lock(&devfreq->lock);
  247. ret = update_devfreq(devfreq);
  248. mutex_unlock(&devfreq->lock);
  249. return ret;
  250. }
  251. /**
  252. * _remove_devfreq() - Remove devfreq from the list and release its resources.
  253. * @devfreq: the devfreq struct
  254. * @skip: skip calling device_unregister().
  255. */
  256. static void _remove_devfreq(struct devfreq *devfreq, bool skip)
  257. {
  258. mutex_lock(&devfreq_list_lock);
  259. if (IS_ERR(find_device_devfreq(devfreq->dev.parent))) {
  260. mutex_unlock(&devfreq_list_lock);
  261. dev_warn(&devfreq->dev, "releasing devfreq which doesn't exist\n");
  262. return;
  263. }
  264. list_del(&devfreq->node);
  265. mutex_unlock(&devfreq_list_lock);
  266. devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_STOP, NULL);
  267. if (devfreq->profile->exit)
  268. devfreq->profile->exit(devfreq->dev.parent);
  269. if (!skip && get_device(&devfreq->dev)) {
  270. device_unregister(&devfreq->dev);
  271. put_device(&devfreq->dev);
  272. }
  273. mutex_destroy(&devfreq->lock);
  274. kfree(devfreq);
  275. }
  276. /**
  277. * devfreq_dev_release() - Callback for struct device to release the device.
  278. * @dev: the devfreq device
  279. *
  280. * This calls _remove_devfreq() if _remove_devfreq() is not called.
  281. * Note that devfreq_dev_release() could be called by _remove_devfreq() as
  282. * well as by others unregistering the device.
  283. */
  284. static void devfreq_dev_release(struct device *dev)
  285. {
  286. struct devfreq *devfreq = to_devfreq(dev);
  287. _remove_devfreq(devfreq, true);
  288. }
  289. /**
  290. * devfreq_add_device() - Add devfreq feature to the device
  291. * @dev: the device to add devfreq feature.
  292. * @profile: device-specific profile to run devfreq.
  293. * @governor: the policy to choose frequency.
  294. * @data: private data for the governor. The devfreq framework does not
  295. * touch this value.
  296. */
  297. struct devfreq *devfreq_add_device(struct device *dev,
  298. struct devfreq_dev_profile *profile,
  299. const struct devfreq_governor *governor,
  300. void *data)
  301. {
  302. struct devfreq *devfreq;
  303. int err = 0;
  304. if (!dev || !profile || !governor) {
  305. dev_err(dev, "%s: Invalid parameters.\n", __func__);
  306. return ERR_PTR(-EINVAL);
  307. }
  308. mutex_lock(&devfreq_list_lock);
  309. devfreq = find_device_devfreq(dev);
  310. mutex_unlock(&devfreq_list_lock);
  311. if (!IS_ERR(devfreq)) {
  312. dev_err(dev, "%s: Unable to create devfreq for the device. It already has one.\n", __func__);
  313. err = -EINVAL;
  314. goto err_out;
  315. }
  316. devfreq = kzalloc(sizeof(struct devfreq), GFP_KERNEL);
  317. if (!devfreq) {
  318. dev_err(dev, "%s: Unable to create devfreq for the device\n",
  319. __func__);
  320. err = -ENOMEM;
  321. goto err_out;
  322. }
  323. mutex_init(&devfreq->lock);
  324. mutex_lock(&devfreq->lock);
  325. devfreq->dev.parent = dev;
  326. devfreq->dev.class = devfreq_class;
  327. devfreq->dev.release = devfreq_dev_release;
  328. devfreq->profile = profile;
  329. devfreq->governor = governor;
  330. devfreq->previous_freq = profile->initial_freq;
  331. devfreq->data = data;
  332. devfreq->nb.notifier_call = devfreq_notifier_call;
  333. dev_set_name(&devfreq->dev, dev_name(dev));
  334. err = device_register(&devfreq->dev);
  335. if (err) {
  336. put_device(&devfreq->dev);
  337. mutex_unlock(&devfreq->lock);
  338. goto err_dev;
  339. }
  340. mutex_unlock(&devfreq->lock);
  341. mutex_lock(&devfreq_list_lock);
  342. list_add(&devfreq->node, &devfreq_list);
  343. mutex_unlock(&devfreq_list_lock);
  344. err = devfreq->governor->event_handler(devfreq,
  345. DEVFREQ_GOV_START, NULL);
  346. if (err) {
  347. dev_err(dev, "%s: Unable to start governor for the device\n",
  348. __func__);
  349. goto err_init;
  350. }
  351. return devfreq;
  352. err_init:
  353. list_del(&devfreq->node);
  354. device_unregister(&devfreq->dev);
  355. err_dev:
  356. kfree(devfreq);
  357. err_out:
  358. return ERR_PTR(err);
  359. }
  360. EXPORT_SYMBOL(devfreq_add_device);
  361. /**
  362. * devfreq_remove_device() - Remove devfreq feature from a device.
  363. * @devfreq the devfreq instance to be removed
  364. */
  365. int devfreq_remove_device(struct devfreq *devfreq)
  366. {
  367. if (!devfreq)
  368. return -EINVAL;
  369. _remove_devfreq(devfreq, false);
  370. return 0;
  371. }
  372. EXPORT_SYMBOL(devfreq_remove_device);
  373. /**
  374. * devfreq_suspend_device() - Suspend devfreq of a device.
  375. * @devfreq: the devfreq instance to be suspended
  376. */
  377. int devfreq_suspend_device(struct devfreq *devfreq)
  378. {
  379. if (!devfreq)
  380. return -EINVAL;
  381. return devfreq->governor->event_handler(devfreq,
  382. DEVFREQ_GOV_SUSPEND, NULL);
  383. }
  384. EXPORT_SYMBOL(devfreq_suspend_device);
  385. /**
  386. * devfreq_resume_device() - Resume devfreq of a device.
  387. * @devfreq: the devfreq instance to be resumed
  388. */
  389. int devfreq_resume_device(struct devfreq *devfreq)
  390. {
  391. if (!devfreq)
  392. return -EINVAL;
  393. return devfreq->governor->event_handler(devfreq,
  394. DEVFREQ_GOV_RESUME, NULL);
  395. }
  396. EXPORT_SYMBOL(devfreq_resume_device);
  397. static ssize_t show_governor(struct device *dev,
  398. struct device_attribute *attr, char *buf)
  399. {
  400. return sprintf(buf, "%s\n", to_devfreq(dev)->governor->name);
  401. }
  402. static ssize_t show_freq(struct device *dev,
  403. struct device_attribute *attr, char *buf)
  404. {
  405. return sprintf(buf, "%lu\n", to_devfreq(dev)->previous_freq);
  406. }
  407. static ssize_t show_polling_interval(struct device *dev,
  408. struct device_attribute *attr, char *buf)
  409. {
  410. return sprintf(buf, "%d\n", to_devfreq(dev)->profile->polling_ms);
  411. }
  412. static ssize_t store_polling_interval(struct device *dev,
  413. struct device_attribute *attr,
  414. const char *buf, size_t count)
  415. {
  416. struct devfreq *df = to_devfreq(dev);
  417. unsigned int value;
  418. int ret;
  419. ret = sscanf(buf, "%u", &value);
  420. if (ret != 1)
  421. goto out;
  422. df->governor->event_handler(df, DEVFREQ_GOV_INTERVAL, &value);
  423. ret = count;
  424. out:
  425. return ret;
  426. }
  427. static ssize_t store_min_freq(struct device *dev, struct device_attribute *attr,
  428. const char *buf, size_t count)
  429. {
  430. struct devfreq *df = to_devfreq(dev);
  431. unsigned long value;
  432. int ret;
  433. unsigned long max;
  434. ret = sscanf(buf, "%lu", &value);
  435. if (ret != 1)
  436. goto out;
  437. mutex_lock(&df->lock);
  438. max = df->max_freq;
  439. if (value && max && value > max) {
  440. ret = -EINVAL;
  441. goto unlock;
  442. }
  443. df->min_freq = value;
  444. update_devfreq(df);
  445. ret = count;
  446. unlock:
  447. mutex_unlock(&df->lock);
  448. out:
  449. return ret;
  450. }
  451. static ssize_t show_min_freq(struct device *dev, struct device_attribute *attr,
  452. char *buf)
  453. {
  454. return sprintf(buf, "%lu\n", to_devfreq(dev)->min_freq);
  455. }
  456. static ssize_t store_max_freq(struct device *dev, struct device_attribute *attr,
  457. const char *buf, size_t count)
  458. {
  459. struct devfreq *df = to_devfreq(dev);
  460. unsigned long value;
  461. int ret;
  462. unsigned long min;
  463. ret = sscanf(buf, "%lu", &value);
  464. if (ret != 1)
  465. goto out;
  466. mutex_lock(&df->lock);
  467. min = df->min_freq;
  468. if (value && min && value < min) {
  469. ret = -EINVAL;
  470. goto unlock;
  471. }
  472. df->max_freq = value;
  473. update_devfreq(df);
  474. ret = count;
  475. unlock:
  476. mutex_unlock(&df->lock);
  477. out:
  478. return ret;
  479. }
  480. static ssize_t show_max_freq(struct device *dev, struct device_attribute *attr,
  481. char *buf)
  482. {
  483. return sprintf(buf, "%lu\n", to_devfreq(dev)->max_freq);
  484. }
  485. static struct device_attribute devfreq_attrs[] = {
  486. __ATTR(governor, S_IRUGO, show_governor, NULL),
  487. __ATTR(cur_freq, S_IRUGO, show_freq, NULL),
  488. __ATTR(polling_interval, S_IRUGO | S_IWUSR, show_polling_interval,
  489. store_polling_interval),
  490. __ATTR(min_freq, S_IRUGO | S_IWUSR, show_min_freq, store_min_freq),
  491. __ATTR(max_freq, S_IRUGO | S_IWUSR, show_max_freq, store_max_freq),
  492. { },
  493. };
  494. static int __init devfreq_init(void)
  495. {
  496. devfreq_class = class_create(THIS_MODULE, "devfreq");
  497. if (IS_ERR(devfreq_class)) {
  498. pr_err("%s: couldn't create class\n", __FILE__);
  499. return PTR_ERR(devfreq_class);
  500. }
  501. devfreq_wq = create_freezable_workqueue("devfreq_wq");
  502. if (IS_ERR(devfreq_wq)) {
  503. class_destroy(devfreq_class);
  504. pr_err("%s: couldn't create workqueue\n", __FILE__);
  505. return PTR_ERR(devfreq_wq);
  506. }
  507. devfreq_class->dev_attrs = devfreq_attrs;
  508. return 0;
  509. }
  510. subsys_initcall(devfreq_init);
  511. static void __exit devfreq_exit(void)
  512. {
  513. class_destroy(devfreq_class);
  514. destroy_workqueue(devfreq_wq);
  515. }
  516. module_exit(devfreq_exit);
  517. /*
  518. * The followings are helper functions for devfreq user device drivers with
  519. * OPP framework.
  520. */
  521. /**
  522. * devfreq_recommended_opp() - Helper function to get proper OPP for the
  523. * freq value given to target callback.
  524. * @dev The devfreq user device. (parent of devfreq)
  525. * @freq The frequency given to target function
  526. * @flags Flags handed from devfreq framework.
  527. *
  528. */
  529. struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq,
  530. u32 flags)
  531. {
  532. struct opp *opp;
  533. if (flags & DEVFREQ_FLAG_LEAST_UPPER_BOUND) {
  534. /* The freq is an upper bound. opp should be lower */
  535. opp = opp_find_freq_floor(dev, freq);
  536. /* If not available, use the closest opp */
  537. if (opp == ERR_PTR(-ENODEV))
  538. opp = opp_find_freq_ceil(dev, freq);
  539. } else {
  540. /* The freq is an lower bound. opp should be higher */
  541. opp = opp_find_freq_ceil(dev, freq);
  542. /* If not available, use the closest opp */
  543. if (opp == ERR_PTR(-ENODEV))
  544. opp = opp_find_freq_floor(dev, freq);
  545. }
  546. return opp;
  547. }
  548. /**
  549. * devfreq_register_opp_notifier() - Helper function to get devfreq notified
  550. * for any changes in the OPP availability
  551. * changes
  552. * @dev The devfreq user device. (parent of devfreq)
  553. * @devfreq The devfreq object.
  554. */
  555. int devfreq_register_opp_notifier(struct device *dev, struct devfreq *devfreq)
  556. {
  557. struct srcu_notifier_head *nh = opp_get_notifier(dev);
  558. if (IS_ERR(nh))
  559. return PTR_ERR(nh);
  560. return srcu_notifier_chain_register(nh, &devfreq->nb);
  561. }
  562. /**
  563. * devfreq_unregister_opp_notifier() - Helper function to stop getting devfreq
  564. * notified for any changes in the OPP
  565. * availability changes anymore.
  566. * @dev The devfreq user device. (parent of devfreq)
  567. * @devfreq The devfreq object.
  568. *
  569. * At exit() callback of devfreq_dev_profile, this must be included if
  570. * devfreq_recommended_opp is used.
  571. */
  572. int devfreq_unregister_opp_notifier(struct device *dev, struct devfreq *devfreq)
  573. {
  574. struct srcu_notifier_head *nh = opp_get_notifier(dev);
  575. if (IS_ERR(nh))
  576. return PTR_ERR(nh);
  577. return srcu_notifier_chain_unregister(nh, &devfreq->nb);
  578. }
  579. MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>");
  580. MODULE_DESCRIPTION("devfreq class support");
  581. MODULE_LICENSE("GPL");