Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'pm-devfreq'

* pm-devfreq:
MAINTAINERS: Add devfreq-event entry
MAINTAINERS: Add missing git repository and directory for devfreq
PM / devfreq: Do not show statistics if it's not ready.
PM / devfreq: Modify the indentation of trans_stat sysfs for readability
PM / devfreq: Set the freq_table of devfreq device
PM / devfreq: Add show_one macro to delete the duplicate code
PM / devfreq: event: Fix the error and warning from script/checkpatch.pl
PM / devfreq: event: Remove the error log of devfreq_event_get_edev_by_phandle()

+81 -28
+13
MAINTAINERS
··· 3421 3421 M: MyungJoo Ham <myungjoo.ham@samsung.com> 3422 3422 M: Kyungmin Park <kyungmin.park@samsung.com> 3423 3423 L: linux-pm@vger.kernel.org 3424 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/mzx/devfreq.git 3424 3425 S: Maintained 3425 3426 F: drivers/devfreq/ 3427 + F: include/linux/devfreq.h 3428 + F: Documentation/devicetree/bindings/devfreq/ 3429 + 3430 + DEVICE FREQUENCY EVENT (DEVFREQ-EVENT) 3431 + M: Chanwoo Choi <cw00.choi@samsung.com> 3432 + L: linux-pm@vger.kernel.org 3433 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/mzx/devfreq.git 3434 + S: Supported 3435 + F: drivers/devfreq/event/ 3436 + F: drivers/devfreq/devfreq-event.c 3437 + F: include/linux/devfreq-event.h 3438 + F: Documentation/devicetree/bindings/devfreq/event/ 3426 3439 3427 3440 DEVICE NUMBER REGISTRY 3428 3441 M: Torben Mathiasen <device@lanana.org>
+5 -11
drivers/devfreq/devfreq-event.c
··· 226 226 struct device_node *node; 227 227 struct devfreq_event_dev *edev; 228 228 229 - if (!dev->of_node) { 230 - dev_err(dev, "device does not have a device node entry\n"); 229 + if (!dev->of_node) 231 230 return ERR_PTR(-EINVAL); 232 - } 233 231 234 232 node = of_parse_phandle(dev->of_node, "devfreq-events", index); 235 - if (!node) { 236 - dev_err(dev, "failed to get phandle in %s node\n", 237 - dev->of_node->full_name); 233 + if (!node) 238 234 return ERR_PTR(-ENODEV); 239 - } 240 235 241 236 mutex_lock(&devfreq_event_list_lock); 242 237 list_for_each_entry(edev, &devfreq_event_list, node) { ··· 243 248 mutex_unlock(&devfreq_event_list_lock); 244 249 245 250 if (!edev) { 246 - dev_err(dev, "unable to get devfreq-event device : %s\n", 247 - node->name); 248 251 of_node_put(node); 249 252 return ERR_PTR(-ENODEV); 250 253 } ··· 270 277 271 278 count = of_property_count_elems_of_size(dev->of_node, "devfreq-events", 272 279 sizeof(u32)); 273 - if (count < 0 ) { 280 + if (count < 0) { 274 281 dev_err(dev, 275 282 "failed to get the count of devfreq-event in %s node\n", 276 283 dev->of_node->full_name); ··· 395 402 { 396 403 struct devfreq_event_dev **ptr, *edev; 397 404 398 - ptr = devres_alloc(devm_devfreq_event_release, sizeof(*ptr), GFP_KERNEL); 405 + ptr = devres_alloc(devm_devfreq_event_release, sizeof(*ptr), 406 + GFP_KERNEL); 399 407 if (!ptr) 400 408 return ERR_PTR(-ENOMEM); 401 409
+62 -16
drivers/devfreq/devfreq.c
··· 85 85 } 86 86 87 87 /** 88 + * devfreq_set_freq_table() - Initialize freq_table for the frequency 89 + * @devfreq: the devfreq instance 90 + */ 91 + static void devfreq_set_freq_table(struct devfreq *devfreq) 92 + { 93 + struct devfreq_dev_profile *profile = devfreq->profile; 94 + struct dev_pm_opp *opp; 95 + unsigned long freq; 96 + int i, count; 97 + 98 + /* Initialize the freq_table from OPP table */ 99 + count = dev_pm_opp_get_opp_count(devfreq->dev.parent); 100 + if (count <= 0) 101 + return; 102 + 103 + profile->max_state = count; 104 + profile->freq_table = devm_kcalloc(devfreq->dev.parent, 105 + profile->max_state, 106 + sizeof(*profile->freq_table), 107 + GFP_KERNEL); 108 + if (!profile->freq_table) { 109 + profile->max_state = 0; 110 + return; 111 + } 112 + 113 + rcu_read_lock(); 114 + for (i = 0, freq = 0; i < profile->max_state; i++, freq++) { 115 + opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &freq); 116 + if (IS_ERR(opp)) { 117 + devm_kfree(devfreq->dev.parent, profile->freq_table); 118 + profile->max_state = 0; 119 + rcu_read_unlock(); 120 + return; 121 + } 122 + profile->freq_table[i] = freq; 123 + } 124 + rcu_read_unlock(); 125 + } 126 + 127 + /** 88 128 * devfreq_update_status() - Update statistics of devfreq behavior 89 129 * @devfreq: the devfreq instance 90 130 * @freq: the update target frequency ··· 517 477 devfreq->previous_freq = profile->initial_freq; 518 478 devfreq->data = data; 519 479 devfreq->nb.notifier_call = devfreq_notifier_call; 480 + 481 + if (!devfreq->profile->max_state && !devfreq->profile->freq_table) { 482 + mutex_unlock(&devfreq->lock); 483 + devfreq_set_freq_table(devfreq); 484 + mutex_lock(&devfreq->lock); 485 + } 520 486 521 487 devfreq->trans_table = devm_kzalloc(dev, sizeof(unsigned int) * 522 488 devfreq->profile->max_state * ··· 967 921 return ret; 968 922 } 969 923 970 - static ssize_t min_freq_show(struct device *dev, struct device_attribute *attr, 971 - char *buf) 972 - { 973 - return sprintf(buf, "%lu\n", to_devfreq(dev)->min_freq); 974 - } 975 - 976 924 static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr, 977 925 const char *buf, size_t count) 978 926 { ··· 993 953 mutex_unlock(&df->lock); 994 954 return ret; 995 955 } 996 - static DEVICE_ATTR_RW(min_freq); 997 956 998 - static ssize_t max_freq_show(struct device *dev, struct device_attribute *attr, 999 - char *buf) 1000 - { 1001 - return sprintf(buf, "%lu\n", to_devfreq(dev)->max_freq); 957 + #define show_one(name) \ 958 + static ssize_t name##_show \ 959 + (struct device *dev, struct device_attribute *attr, char *buf) \ 960 + { \ 961 + return sprintf(buf, "%lu\n", to_devfreq(dev)->name); \ 1002 962 } 963 + show_one(min_freq); 964 + show_one(max_freq); 965 + 966 + static DEVICE_ATTR_RW(min_freq); 1003 967 static DEVICE_ATTR_RW(max_freq); 1004 968 1005 969 static ssize_t available_frequencies_show(struct device *d, ··· 1049 1005 if (!devfreq->stop_polling && 1050 1006 devfreq_update_status(devfreq, devfreq->previous_freq)) 1051 1007 return 0; 1008 + if (max_state == 0) 1009 + return sprintf(buf, "Not Supported.\n"); 1052 1010 1053 - len = sprintf(buf, " From : To\n"); 1054 - len += sprintf(buf + len, " :"); 1011 + len = sprintf(buf, " From : To\n"); 1012 + len += sprintf(buf + len, " :"); 1055 1013 for (i = 0; i < max_state; i++) 1056 - len += sprintf(buf + len, "%8u", 1014 + len += sprintf(buf + len, "%10lu", 1057 1015 devfreq->profile->freq_table[i]); 1058 1016 1059 1017 len += sprintf(buf + len, " time(ms)\n"); ··· 1067 1021 } else { 1068 1022 len += sprintf(buf + len, " "); 1069 1023 } 1070 - len += sprintf(buf + len, "%8u:", 1024 + len += sprintf(buf + len, "%10lu:", 1071 1025 devfreq->profile->freq_table[i]); 1072 1026 for (j = 0; j < max_state; j++) 1073 - len += sprintf(buf + len, "%8u", 1027 + len += sprintf(buf + len, "%10u", 1074 1028 devfreq->trans_table[(i * max_state) + j]); 1075 1029 len += sprintf(buf + len, "%10u\n", 1076 1030 jiffies_to_msecs(devfreq->time_in_state[i]));
+1 -1
include/linux/devfreq.h
··· 89 89 int (*get_cur_freq)(struct device *dev, unsigned long *freq); 90 90 void (*exit)(struct device *dev); 91 91 92 - unsigned int *freq_table; 92 + unsigned long *freq_table; 93 93 unsigned int max_state; 94 94 }; 95 95