diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-01-31 07:18:06 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-01-31 07:18:06 -0500 |
commit | 23b017a623a0bd19c24e6c1c41fe587c644e9dbc (patch) | |
tree | beb477ac919f1a2911bd43681f310354bd0045a8 /drivers/devfreq/devfreq.c | |
parent | 566cf877a1fcb6d6dc0126b076aad062054c2637 (diff) | |
parent | 4585fbcb5331fc910b7e553ad3efd0dd7b320d14 (diff) |
Merge tag 'pullreq_20170131' of https://git.kernel.org/pub/scm/linux/kernel/git/mzx/devfreq into pm-devfreq
Pull devfreq changes for v4.11 from MyungJoo Ham.
* tag 'pullreq_20170131' of https://git.kernel.org/pub/scm/linux/kernel/git/mzx/devfreq:
PM / devfreq: Modify the device name as devfreq(X) for sysfs
PM / devfreq: Simplify the sysfs name of devfreq-event device
PM / devfreq: Remove unnecessary separate _remove_devfreq()
PM / devfreq: Fix wrong trans_stat of passive devfreq device
PM / devfreq: Fix available_governor sysfs
PM / devfreq: exynos-ppmu: Show the registred device for ppmu device
PM / devfreq: Fix the wrong description for userspace governor
PM / devfreq: Fix the checkpatch warnings
PM / devfreq: exynos-bus: Print the real clock rate of bus
PM / devfreq: exynos-ppmu: Use the regmap interface to handle the registers
PM / devfreq: exynos-bus: Add the detailed correlation for Exynos5433
PM / devfreq: Don't delete sysfs group twice
Diffstat (limited to 'drivers/devfreq/devfreq.c')
-rw-r--r-- | drivers/devfreq/devfreq.c | 74 |
1 files changed, 46 insertions, 28 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 47206a21bb90..4aa72b5ed660 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c | |||
@@ -130,7 +130,7 @@ static void devfreq_set_freq_table(struct devfreq *devfreq) | |||
130 | * @devfreq: the devfreq instance | 130 | * @devfreq: the devfreq instance |
131 | * @freq: the update target frequency | 131 | * @freq: the update target frequency |
132 | */ | 132 | */ |
133 | static int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) | 133 | int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) |
134 | { | 134 | { |
135 | int lev, prev_lev, ret = 0; | 135 | int lev, prev_lev, ret = 0; |
136 | unsigned long cur_time; | 136 | unsigned long cur_time; |
@@ -166,6 +166,7 @@ out: | |||
166 | devfreq->last_stat_updated = cur_time; | 166 | devfreq->last_stat_updated = cur_time; |
167 | return ret; | 167 | return ret; |
168 | } | 168 | } |
169 | EXPORT_SYMBOL(devfreq_update_status); | ||
169 | 170 | ||
170 | /** | 171 | /** |
171 | * find_devfreq_governor() - find devfreq governor from name | 172 | * find_devfreq_governor() - find devfreq governor from name |
@@ -474,11 +475,15 @@ static int devfreq_notifier_call(struct notifier_block *nb, unsigned long type, | |||
474 | } | 475 | } |
475 | 476 | ||
476 | /** | 477 | /** |
477 | * _remove_devfreq() - Remove devfreq from the list and release its resources. | 478 | * devfreq_dev_release() - Callback for struct device to release the device. |
478 | * @devfreq: the devfreq struct | 479 | * @dev: the devfreq device |
480 | * | ||
481 | * Remove devfreq from the list and release its resources. | ||
479 | */ | 482 | */ |
480 | static void _remove_devfreq(struct devfreq *devfreq) | 483 | static void devfreq_dev_release(struct device *dev) |
481 | { | 484 | { |
485 | struct devfreq *devfreq = to_devfreq(dev); | ||
486 | |||
482 | mutex_lock(&devfreq_list_lock); | 487 | mutex_lock(&devfreq_list_lock); |
483 | if (IS_ERR(find_device_devfreq(devfreq->dev.parent))) { | 488 | if (IS_ERR(find_device_devfreq(devfreq->dev.parent))) { |
484 | mutex_unlock(&devfreq_list_lock); | 489 | mutex_unlock(&devfreq_list_lock); |
@@ -500,19 +505,6 @@ static void _remove_devfreq(struct devfreq *devfreq) | |||
500 | } | 505 | } |
501 | 506 | ||
502 | /** | 507 | /** |
503 | * devfreq_dev_release() - Callback for struct device to release the device. | ||
504 | * @dev: the devfreq device | ||
505 | * | ||
506 | * This calls _remove_devfreq() if _remove_devfreq() is not called. | ||
507 | */ | ||
508 | static void devfreq_dev_release(struct device *dev) | ||
509 | { | ||
510 | struct devfreq *devfreq = to_devfreq(dev); | ||
511 | |||
512 | _remove_devfreq(devfreq); | ||
513 | } | ||
514 | |||
515 | /** | ||
516 | * devfreq_add_device() - Add devfreq feature to the device | 508 | * devfreq_add_device() - Add devfreq feature to the device |
517 | * @dev: the device to add devfreq feature. | 509 | * @dev: the device to add devfreq feature. |
518 | * @profile: device-specific profile to run devfreq. | 510 | * @profile: device-specific profile to run devfreq. |
@@ -527,6 +519,7 @@ struct devfreq *devfreq_add_device(struct device *dev, | |||
527 | { | 519 | { |
528 | struct devfreq *devfreq; | 520 | struct devfreq *devfreq; |
529 | struct devfreq_governor *governor; | 521 | struct devfreq_governor *governor; |
522 | static atomic_t devfreq_no = ATOMIC_INIT(-1); | ||
530 | int err = 0; | 523 | int err = 0; |
531 | 524 | ||
532 | if (!dev || !profile || !governor_name) { | 525 | if (!dev || !profile || !governor_name) { |
@@ -538,15 +531,14 @@ struct devfreq *devfreq_add_device(struct device *dev, | |||
538 | devfreq = find_device_devfreq(dev); | 531 | devfreq = find_device_devfreq(dev); |
539 | mutex_unlock(&devfreq_list_lock); | 532 | mutex_unlock(&devfreq_list_lock); |
540 | if (!IS_ERR(devfreq)) { | 533 | if (!IS_ERR(devfreq)) { |
541 | dev_err(dev, "%s: Unable to create devfreq for the device. It already has one.\n", __func__); | 534 | dev_err(dev, "%s: Unable to create devfreq for the device.\n", |
535 | __func__); | ||
542 | err = -EINVAL; | 536 | err = -EINVAL; |
543 | goto err_out; | 537 | goto err_out; |
544 | } | 538 | } |
545 | 539 | ||
546 | devfreq = kzalloc(sizeof(struct devfreq), GFP_KERNEL); | 540 | devfreq = kzalloc(sizeof(struct devfreq), GFP_KERNEL); |
547 | if (!devfreq) { | 541 | if (!devfreq) { |
548 | dev_err(dev, "%s: Unable to create devfreq for the device\n", | ||
549 | __func__); | ||
550 | err = -ENOMEM; | 542 | err = -ENOMEM; |
551 | goto err_out; | 543 | goto err_out; |
552 | } | 544 | } |
@@ -569,18 +561,21 @@ struct devfreq *devfreq_add_device(struct device *dev, | |||
569 | mutex_lock(&devfreq->lock); | 561 | mutex_lock(&devfreq->lock); |
570 | } | 562 | } |
571 | 563 | ||
572 | dev_set_name(&devfreq->dev, "%s", dev_name(dev)); | 564 | dev_set_name(&devfreq->dev, "devfreq%d", |
565 | atomic_inc_return(&devfreq_no)); | ||
573 | err = device_register(&devfreq->dev); | 566 | err = device_register(&devfreq->dev); |
574 | if (err) { | 567 | if (err) { |
575 | mutex_unlock(&devfreq->lock); | 568 | mutex_unlock(&devfreq->lock); |
576 | goto err_out; | 569 | goto err_out; |
577 | } | 570 | } |
578 | 571 | ||
579 | devfreq->trans_table = devm_kzalloc(&devfreq->dev, sizeof(unsigned int) * | 572 | devfreq->trans_table = devm_kzalloc(&devfreq->dev, |
573 | sizeof(unsigned int) * | ||
580 | devfreq->profile->max_state * | 574 | devfreq->profile->max_state * |
581 | devfreq->profile->max_state, | 575 | devfreq->profile->max_state, |
582 | GFP_KERNEL); | 576 | GFP_KERNEL); |
583 | devfreq->time_in_state = devm_kzalloc(&devfreq->dev, sizeof(unsigned long) * | 577 | devfreq->time_in_state = devm_kzalloc(&devfreq->dev, |
578 | sizeof(unsigned long) * | ||
584 | devfreq->profile->max_state, | 579 | devfreq->profile->max_state, |
585 | GFP_KERNEL); | 580 | GFP_KERNEL); |
586 | devfreq->last_stat_updated = jiffies; | 581 | devfreq->last_stat_updated = jiffies; |
@@ -939,6 +934,9 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr, | |||
939 | if (df->governor == governor) { | 934 | if (df->governor == governor) { |
940 | ret = 0; | 935 | ret = 0; |
941 | goto out; | 936 | goto out; |
937 | } else if (df->governor->immutable || governor->immutable) { | ||
938 | ret = -EINVAL; | ||
939 | goto out; | ||
942 | } | 940 | } |
943 | 941 | ||
944 | if (df->governor) { | 942 | if (df->governor) { |
@@ -968,13 +966,33 @@ static ssize_t available_governors_show(struct device *d, | |||
968 | struct device_attribute *attr, | 966 | struct device_attribute *attr, |
969 | char *buf) | 967 | char *buf) |
970 | { | 968 | { |
971 | struct devfreq_governor *tmp_governor; | 969 | struct devfreq *df = to_devfreq(d); |
972 | ssize_t count = 0; | 970 | ssize_t count = 0; |
973 | 971 | ||
974 | mutex_lock(&devfreq_list_lock); | 972 | mutex_lock(&devfreq_list_lock); |
975 | list_for_each_entry(tmp_governor, &devfreq_governor_list, node) | 973 | |
976 | count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), | 974 | /* |
977 | "%s ", tmp_governor->name); | 975 | * The devfreq with immutable governor (e.g., passive) shows |
976 | * only own governor. | ||
977 | */ | ||
978 | if (df->governor->immutable) { | ||
979 | count = scnprintf(&buf[count], DEVFREQ_NAME_LEN, | ||
980 | "%s ", df->governor_name); | ||
981 | /* | ||
982 | * The devfreq device shows the registered governor except for | ||
983 | * immutable governors such as passive governor . | ||
984 | */ | ||
985 | } else { | ||
986 | struct devfreq_governor *governor; | ||
987 | |||
988 | list_for_each_entry(governor, &devfreq_governor_list, node) { | ||
989 | if (governor->immutable) | ||
990 | continue; | ||
991 | count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), | ||
992 | "%s ", governor->name); | ||
993 | } | ||
994 | } | ||
995 | |||
978 | mutex_unlock(&devfreq_list_lock); | 996 | mutex_unlock(&devfreq_list_lock); |
979 | 997 | ||
980 | /* Truncate the trailing space */ | 998 | /* Truncate the trailing space */ |
@@ -995,7 +1013,7 @@ static ssize_t cur_freq_show(struct device *dev, struct device_attribute *attr, | |||
995 | 1013 | ||
996 | if (devfreq->profile->get_cur_freq && | 1014 | if (devfreq->profile->get_cur_freq && |
997 | !devfreq->profile->get_cur_freq(devfreq->dev.parent, &freq)) | 1015 | !devfreq->profile->get_cur_freq(devfreq->dev.parent, &freq)) |
998 | return sprintf(buf, "%lu\n", freq); | 1016 | return sprintf(buf, "%lu\n", freq); |
999 | 1017 | ||
1000 | return sprintf(buf, "%lu\n", devfreq->previous_freq); | 1018 | return sprintf(buf, "%lu\n", devfreq->previous_freq); |
1001 | } | 1019 | } |