Lines Matching full:governor
31 #include "governor.h"
256 * find_devfreq_governor() - find devfreq governor from name
257 * @name: name of the governor
260 * governor's pointer. devfreq_list_lock should be held by the caller.
282 * try_then_request_governor() - Try to find the governor and request the
284 * @name: name of the governor
287 * if is not found. This can happen when both drivers (the governor driver
290 * governor's pointer or an error pointer.
294 struct devfreq_governor *governor; in try_then_request_governor() local
304 governor = find_devfreq_governor(name); in try_then_request_governor()
305 if (IS_ERR(governor)) { in try_then_request_governor()
318 governor = find_devfreq_governor(name); in try_then_request_governor()
321 return governor; in try_then_request_governor()
398 * is only used for devfreq device using passive governor.
411 if (!devfreq->governor) in devfreq_update_target()
415 err = devfreq->governor->get_target_freq(devfreq, &freq); in devfreq_update_target()
482 * called by devfreq governor in response to the DEVFREQ_GOV_START event
487 if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN)) in devfreq_monitor_start()
520 * to be called from governor in response to DEVFREQ_GOV_STOP
525 if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN)) in devfreq_monitor_stop()
545 * to be called from governor in response to DEVFREQ_GOV_SUSPEND
564 if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN)) in devfreq_monitor_suspend()
576 * to be called from governor in response to DEVFREQ_GOV_RESUME
585 if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN)) in devfreq_monitor_resume()
615 * to be called from governor in response to DEVFREQ_GOV_UPDATE_INTERVAL event.
625 if (IS_SUPPORTED_FLAG(devfreq->governor->flags, IRQ_DRIVEN)) in devfreq_update_interval()
801 * @data: devfreq driver pass to governors, governor should not change it.
809 struct devfreq_governor *governor; in devfreq_add_device() local
947 governor = try_then_request_governor(governor_name); in devfreq_add_device()
948 if (IS_ERR(governor)) { in devfreq_add_device()
949 dev_err(dev, "%s: Unable to find governor for the device\n", in devfreq_add_device()
951 err = PTR_ERR(governor); in devfreq_add_device()
955 devfreq->governor = governor; in devfreq_add_device()
956 err = devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_START, in devfreq_add_device()
960 "%s: Unable to start governor for the device\n", in devfreq_add_device()
964 create_sysfs_files(devfreq, devfreq->governor); in devfreq_add_device()
1003 if (devfreq->governor) { in devfreq_remove_device()
1004 devfreq->governor->event_handler(devfreq, in devfreq_remove_device()
1006 remove_sysfs_files(devfreq, devfreq->governor); in devfreq_remove_device()
1035 * @data: devfreq driver pass to governors, governor should not change it.
1167 if (devfreq->governor) { in devfreq_suspend_device()
1168 ret = devfreq->governor->event_handler(devfreq, in devfreq_suspend_device()
1212 if (devfreq->governor) { in devfreq_resume_device()
1213 ret = devfreq->governor->event_handler(devfreq, in devfreq_resume_device()
1268 * devfreq_add_governor() - Add devfreq governor
1269 * @governor: the devfreq governor to be added
1271 int devfreq_add_governor(struct devfreq_governor *governor) in devfreq_add_governor() argument
1277 if (!governor) { in devfreq_add_governor()
1283 g = find_devfreq_governor(governor->name); in devfreq_add_governor()
1285 pr_err("%s: governor %s already registered\n", __func__, in devfreq_add_governor()
1291 list_add(&governor->node, &devfreq_governor_list); in devfreq_add_governor()
1297 if (!strncmp(devfreq->governor->name, governor->name, in devfreq_add_governor()
1300 if (devfreq->governor) { in devfreq_add_governor()
1302 "%s: Governor %s already present\n", in devfreq_add_governor()
1303 __func__, devfreq->governor->name); in devfreq_add_governor()
1304 ret = devfreq->governor->event_handler(devfreq, in devfreq_add_governor()
1308 "%s: Governor %s stop = %d\n", in devfreq_add_governor()
1310 devfreq->governor->name, ret); in devfreq_add_governor()
1314 devfreq->governor = governor; in devfreq_add_governor()
1315 ret = devfreq->governor->event_handler(devfreq, in devfreq_add_governor()
1318 dev_warn(dev, "%s: Governor %s start=%d\n", in devfreq_add_governor()
1319 __func__, devfreq->governor->name, in devfreq_add_governor()
1332 static void devm_devfreq_remove_governor(void *governor) in devm_devfreq_remove_governor() argument
1334 WARN_ON(devfreq_remove_governor(governor)); in devm_devfreq_remove_governor()
1338 * devm_devfreq_add_governor() - Add devfreq governor
1339 * @dev: device which adds devfreq governor
1340 * @governor: the devfreq governor to be added
1345 struct devfreq_governor *governor) in devm_devfreq_add_governor() argument
1349 err = devfreq_add_governor(governor); in devm_devfreq_add_governor()
1354 governor); in devm_devfreq_add_governor()
1360 * @governor: the devfreq governor to be removed
1362 int devfreq_remove_governor(struct devfreq_governor *governor) in devfreq_remove_governor() argument
1368 if (!governor) { in devfreq_remove_governor()
1374 g = find_devfreq_governor(governor->name); in devfreq_remove_governor()
1376 pr_err("%s: governor %s not registered\n", __func__, in devfreq_remove_governor()
1377 governor->name); in devfreq_remove_governor()
1385 if (!strncmp(devfreq->governor->name, governor->name, in devfreq_remove_governor()
1387 /* we should have a devfreq governor! */ in devfreq_remove_governor()
1388 if (!devfreq->governor) { in devfreq_remove_governor()
1389 dev_warn(dev, "%s: Governor %s NOT present\n", in devfreq_remove_governor()
1390 __func__, governor->name); in devfreq_remove_governor()
1394 ret = devfreq->governor->event_handler(devfreq, in devfreq_remove_governor()
1397 dev_warn(dev, "%s: Governor %s stop=%d\n", in devfreq_remove_governor()
1398 __func__, devfreq->governor->name, in devfreq_remove_governor()
1401 devfreq->governor = NULL; in devfreq_remove_governor()
1405 list_del(&governor->node); in devfreq_remove_governor()
1426 if (!df->governor) in governor_show()
1429 return sprintf(buf, "%s\n", df->governor->name); in governor_show()
1438 const struct devfreq_governor *governor, *prev_governor; in governor_store() local
1440 if (!df->governor) in governor_store()
1448 governor = try_then_request_governor(str_governor); in governor_store()
1449 if (IS_ERR(governor)) { in governor_store()
1450 ret = PTR_ERR(governor); in governor_store()
1453 if (df->governor == governor) { in governor_store()
1456 } else if (IS_SUPPORTED_FLAG(df->governor->flags, IMMUTABLE) in governor_store()
1457 || IS_SUPPORTED_FLAG(governor->flags, IMMUTABLE)) { in governor_store()
1463 * Stop the current governor and remove the specific sysfs files in governor_store()
1464 * which depend on current governor. in governor_store()
1466 ret = df->governor->event_handler(df, DEVFREQ_GOV_STOP, NULL); in governor_store()
1468 dev_warn(dev, "%s: Governor %s not stopped(%d)\n", in governor_store()
1469 __func__, df->governor->name, ret); in governor_store()
1472 remove_sysfs_files(df, df->governor); in governor_store()
1475 * Start the new governor and create the specific sysfs files in governor_store()
1476 * which depend on the new governor. in governor_store()
1478 prev_governor = df->governor; in governor_store()
1479 df->governor = governor; in governor_store()
1480 ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL); in governor_store()
1482 dev_warn(dev, "%s: Governor %s not started(%d)\n", in governor_store()
1483 __func__, df->governor->name, ret); in governor_store()
1485 /* Restore previous governor */ in governor_store()
1486 df->governor = prev_governor; in governor_store()
1487 ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL); in governor_store()
1490 "%s: reverting to Governor %s failed (%d)\n", in governor_store()
1492 df->governor = NULL; in governor_store()
1498 * Create the sysfs files for the new governor. But if failed to start in governor_store()
1499 * the new governor, restore the sysfs files of previous governor. in governor_store()
1501 create_sysfs_files(df, df->governor); in governor_store()
1510 static DEVICE_ATTR_RW(governor);
1519 if (!df->governor) in available_governors_show()
1525 * The devfreq with immutable governor (e.g., passive) shows in available_governors_show()
1526 * only own governor. in available_governors_show()
1528 if (IS_SUPPORTED_FLAG(df->governor->flags, IMMUTABLE)) { in available_governors_show()
1530 "%s ", df->governor->name); in available_governors_show()
1532 * The devfreq device shows the registered governor except for in available_governors_show()
1533 * immutable governors such as passive governor . in available_governors_show()
1536 struct devfreq_governor *governor; in available_governors_show() local
1538 list_for_each_entry(governor, &devfreq_governor_list, node) { in available_governors_show()
1539 if (IS_SUPPORTED_FLAG(governor->flags, IMMUTABLE)) in available_governors_show()
1542 "%s ", governor->name); in available_governors_show()
1843 if (!df->governor) in polling_interval_store()
1850 df->governor->event_handler(df, DEVFREQ_GOV_UPDATE_INTERVAL, &value); in polling_interval_store()
1876 if (!df->governor || !df->profile) in timer_store()
1904 ret = df->governor->event_handler(df, DEVFREQ_GOV_STOP, NULL); in timer_store()
1906 dev_warn(dev, "%s: Governor %s not stopped(%d)\n", in timer_store()
1907 __func__, df->governor->name, ret); in timer_store()
1911 ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL); in timer_store()
1913 dev_warn(dev, "%s: Governor %s not started(%d)\n", in timer_store()
1914 __func__, df->governor->name, ret); in timer_store()
1930 /* Create the specific sysfs files which depend on each governor. */
1940 /* Remove the specific sysfs files which depend on each governor. */
1972 "governor", in devfreq_summary_show()
1992 if (!strncmp(devfreq->governor->name, DEVFREQ_GOV_PASSIVE, in devfreq_summary_show()
2008 if (IS_SUPPORTED_ATTR(devfreq->governor->attrs, POLLING_INTERVAL)) in devfreq_summary_show()
2018 devfreq->governor->name, in devfreq_summary_show()