Skip to content

Commit 96ffcdf

Browse files
committed
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 <[email protected]>
1 parent 5f1a906 commit 96ffcdf

3 files changed

Lines changed: 9 additions & 15 deletions

File tree

drivers/devfreq/devfreq.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,6 @@ struct devfreq *devfreq_add_device(struct device *dev,
811811
devfreq->dev.release = devfreq_dev_release;
812812
INIT_LIST_HEAD(&devfreq->node);
813813
devfreq->profile = profile;
814-
strscpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
815814
devfreq->previous_freq = profile->initial_freq;
816815
devfreq->last_status.current_frequency = profile->initial_freq;
817816
devfreq->data = data;
@@ -907,7 +906,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
907906

908907
mutex_lock(&devfreq_list_lock);
909908

910-
governor = try_then_request_governor(devfreq->governor_name);
909+
governor = try_then_request_governor(governor_name);
911910
if (IS_ERR(governor)) {
912911
dev_err(dev, "%s: Unable to find governor for the device\n",
913912
__func__);
@@ -1249,7 +1248,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
12491248
int ret = 0;
12501249
struct device *dev = devfreq->dev.parent;
12511250

1252-
if (!strncmp(devfreq->governor_name, governor->name,
1251+
if (!strncmp(devfreq->governor->name, governor->name,
12531252
DEVFREQ_NAME_LEN)) {
12541253
/* The following should never occur */
12551254
if (devfreq->governor) {
@@ -1311,7 +1310,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
13111310
int ret;
13121311
struct device *dev = devfreq->dev.parent;
13131312

1314-
if (!strncmp(devfreq->governor_name, governor->name,
1313+
if (!strncmp(devfreq->governor->name, governor->name,
13151314
DEVFREQ_NAME_LEN)) {
13161315
/* we should have a devfreq governor! */
13171316
if (!devfreq->governor) {
@@ -1406,21 +1405,18 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
14061405
*/
14071406
prev_governor = df->governor;
14081407
df->governor = governor;
1409-
strncpy(df->governor_name, governor->name, DEVFREQ_NAME_LEN);
14101408
ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL);
14111409
if (ret) {
14121410
dev_warn(dev, "%s: Governor %s not started(%d)\n",
14131411
__func__, df->governor->name, ret);
14141412

14151413
/* Restore previous governor */
14161414
df->governor = prev_governor;
1417-
strncpy(df->governor_name, prev_governor->name,
1418-
DEVFREQ_NAME_LEN);
14191415
ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL);
14201416
if (ret) {
14211417
dev_err(dev,
14221418
"%s: reverting to Governor %s failed (%d)\n",
1423-
__func__, df->governor_name, ret);
1419+
__func__, prev_governor->name, ret);
14241420
df->governor = NULL;
14251421
goto out;
14261422
}
@@ -1459,7 +1455,7 @@ static ssize_t available_governors_show(struct device *d,
14591455
*/
14601456
if (IS_SUPPORTED_FLAG(df->governor->flags, IMMUTABLE)) {
14611457
count = scnprintf(&buf[count], DEVFREQ_NAME_LEN,
1462-
"%s ", df->governor_name);
1458+
"%s ", df->governor->name);
14631459
/*
14641460
* The devfreq device shows the registered governor except for
14651461
* immutable governors such as passive governor .
@@ -1902,7 +1898,7 @@ static int devfreq_summary_show(struct seq_file *s, void *data)
19021898

19031899
list_for_each_entry_reverse(devfreq, &devfreq_list, node) {
19041900
#if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE)
1905-
if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
1901+
if (!strncmp(devfreq->governor->name, DEVFREQ_GOV_PASSIVE,
19061902
DEVFREQ_NAME_LEN)) {
19071903
struct devfreq_passive_data *data = devfreq->data;
19081904

@@ -1928,7 +1924,7 @@ static int devfreq_summary_show(struct seq_file *s, void *data)
19281924
"%-30s %-30s %-15s %-10s %10d %12ld %12ld %12ld\n",
19291925
dev_name(&devfreq->dev),
19301926
p_devfreq ? dev_name(&p_devfreq->dev) : "null",
1931-
devfreq->governor_name,
1927+
devfreq->governor->name,
19321928
polling_ms ? timer_name[timer] : "null",
19331929
polling_ms,
19341930
cur_freq,

drivers/devfreq/governor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
#include <linux/devfreq.h>
1515

16+
#define DEVFREQ_NAME_LEN 16
17+
1618
#define to_devfreq(DEV) container_of((DEV), struct devfreq, dev)
1719

1820
/* Devfreq events */

include/linux/devfreq.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include <linux/pm_opp.h>
1616
#include <linux/pm_qos.h>
1717

18-
#define DEVFREQ_NAME_LEN 16
19-
2018
/* DEVFREQ governor name */
2119
#define DEVFREQ_GOV_SIMPLE_ONDEMAND "simple_ondemand"
2220
#define DEVFREQ_GOV_PERFORMANCE "performance"
@@ -139,7 +137,6 @@ struct devfreq_stats {
139137
* using devfreq.
140138
* @profile: device-specific devfreq profile
141139
* @governor: method how to choose frequency based on the usage.
142-
* @governor_name: devfreq governor name for use with this devfreq
143140
* @nb: notifier block used to notify devfreq object that it should
144141
* reevaluate operable frequencies. Devfreq users may use
145142
* devfreq.nb to the corresponding register notifier call chain.
@@ -176,7 +173,6 @@ struct devfreq {
176173
struct device dev;
177174
struct devfreq_dev_profile *profile;
178175
const struct devfreq_governor *governor;
179-
char governor_name[DEVFREQ_NAME_LEN];
180176
struct notifier_block nb;
181177
struct delayed_work work;
182178

0 commit comments

Comments
 (0)