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

PM / devfreq: Remove redundant governor_name from struct devfreq

The devfreq structure instance contains the governor_name and a governor
instance. When need to show the governor name, better to use the name
of devfreq_governor structure. So, governor_name variable in struct devfreq
is a redundant and unneeded variable. Remove the redundant governor_name
of struct devfreq and then use the name of devfreq_governor instance.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

+9 -15
+7 -11
drivers/devfreq/devfreq.c
··· 811 811 devfreq->dev.release = devfreq_dev_release; 812 812 INIT_LIST_HEAD(&devfreq->node); 813 813 devfreq->profile = profile; 814 - strscpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN); 815 814 devfreq->previous_freq = profile->initial_freq; 816 815 devfreq->last_status.current_frequency = profile->initial_freq; 817 816 devfreq->data = data; ··· 906 907 907 908 mutex_lock(&devfreq_list_lock); 908 909 909 - governor = try_then_request_governor(devfreq->governor_name); 910 + governor = try_then_request_governor(governor_name); 910 911 if (IS_ERR(governor)) { 911 912 dev_err(dev, "%s: Unable to find governor for the device\n", 912 913 __func__); ··· 1248 1249 int ret = 0; 1249 1250 struct device *dev = devfreq->dev.parent; 1250 1251 1251 - if (!strncmp(devfreq->governor_name, governor->name, 1252 + if (!strncmp(devfreq->governor->name, governor->name, 1252 1253 DEVFREQ_NAME_LEN)) { 1253 1254 /* The following should never occur */ 1254 1255 if (devfreq->governor) { ··· 1310 1311 int ret; 1311 1312 struct device *dev = devfreq->dev.parent; 1312 1313 1313 - if (!strncmp(devfreq->governor_name, governor->name, 1314 + if (!strncmp(devfreq->governor->name, governor->name, 1314 1315 DEVFREQ_NAME_LEN)) { 1315 1316 /* we should have a devfreq governor! */ 1316 1317 if (!devfreq->governor) { ··· 1405 1406 */ 1406 1407 prev_governor = df->governor; 1407 1408 df->governor = governor; 1408 - strncpy(df->governor_name, governor->name, DEVFREQ_NAME_LEN); 1409 1409 ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL); 1410 1410 if (ret) { 1411 1411 dev_warn(dev, "%s: Governor %s not started(%d)\n", ··· 1412 1414 1413 1415 /* Restore previous governor */ 1414 1416 df->governor = prev_governor; 1415 - strncpy(df->governor_name, prev_governor->name, 1416 - DEVFREQ_NAME_LEN); 1417 1417 ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL); 1418 1418 if (ret) { 1419 1419 dev_err(dev, 1420 1420 "%s: reverting to Governor %s failed (%d)\n", 1421 - __func__, df->governor_name, ret); 1421 + __func__, prev_governor->name, ret); 1422 1422 df->governor = NULL; 1423 1423 goto out; 1424 1424 } ··· 1455 1459 */ 1456 1460 if (IS_SUPPORTED_FLAG(df->governor->flags, IMMUTABLE)) { 1457 1461 count = scnprintf(&buf[count], DEVFREQ_NAME_LEN, 1458 - "%s ", df->governor_name); 1462 + "%s ", df->governor->name); 1459 1463 /* 1460 1464 * The devfreq device shows the registered governor except for 1461 1465 * immutable governors such as passive governor . ··· 1898 1902 1899 1903 list_for_each_entry_reverse(devfreq, &devfreq_list, node) { 1900 1904 #if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE) 1901 - if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE, 1905 + if (!strncmp(devfreq->governor->name, DEVFREQ_GOV_PASSIVE, 1902 1906 DEVFREQ_NAME_LEN)) { 1903 1907 struct devfreq_passive_data *data = devfreq->data; 1904 1908 ··· 1924 1928 "%-30s %-30s %-15s %-10s %10d %12ld %12ld %12ld\n", 1925 1929 dev_name(&devfreq->dev), 1926 1930 p_devfreq ? dev_name(&p_devfreq->dev) : "null", 1927 - devfreq->governor_name, 1931 + devfreq->governor->name, 1928 1932 polling_ms ? timer_name[timer] : "null", 1929 1933 polling_ms, 1930 1934 cur_freq,
+2
drivers/devfreq/governor.h
··· 13 13 14 14 #include <linux/devfreq.h> 15 15 16 + #define DEVFREQ_NAME_LEN 16 17 + 16 18 #define to_devfreq(DEV) container_of((DEV), struct devfreq, dev) 17 19 18 20 /* Devfreq events */
-4
include/linux/devfreq.h
··· 15 15 #include <linux/pm_opp.h> 16 16 #include <linux/pm_qos.h> 17 17 18 - #define DEVFREQ_NAME_LEN 16 19 - 20 18 /* DEVFREQ governor name */ 21 19 #define DEVFREQ_GOV_SIMPLE_ONDEMAND "simple_ondemand" 22 20 #define DEVFREQ_GOV_PERFORMANCE "performance" ··· 137 139 * using devfreq. 138 140 * @profile: device-specific devfreq profile 139 141 * @governor: method how to choose frequency based on the usage. 140 - * @governor_name: devfreq governor name for use with this devfreq 141 142 * @nb: notifier block used to notify devfreq object that it should 142 143 * reevaluate operable frequencies. Devfreq users may use 143 144 * devfreq.nb to the corresponding register notifier call chain. ··· 173 176 struct device dev; 174 177 struct devfreq_dev_profile *profile; 175 178 const struct devfreq_governor *governor; 176 - char governor_name[DEVFREQ_NAME_LEN]; 177 179 struct notifier_block nb; 178 180 struct delayed_work work; 179 181