diff options
author | Chanwoo Choi <cw00.choi@samsung.com> | 2020-10-20 15:12:12 +0900 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2020-10-26 11:50:51 +0900 |
commit | 96ffcdf239de6f9970178bb7d643e16fd9e68ab9 (patch) | |
tree | 344e9362f8e0e5d3e46c4efba56ebf746a49017b /drivers/devfreq | |
parent | 5f1a9066fcb2cc1d41104c74884f6c6cf010124b (diff) |
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>
Diffstat (limited to 'drivers/devfreq')
-rw-r--r-- | drivers/devfreq/devfreq.c | 18 | ||||
-rw-r--r-- | drivers/devfreq/governor.h | 2 |
2 files changed, 9 insertions, 11 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 02cfc6552913..6aa10de792b3 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -811,7 +811,6 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->dev.release = devfreq_dev_release; INIT_LIST_HEAD(&devfreq->node); devfreq->profile = profile; - strscpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN); devfreq->previous_freq = profile->initial_freq; devfreq->last_status.current_frequency = profile->initial_freq; devfreq->data = data; @@ -907,7 +906,7 @@ struct devfreq *devfreq_add_device(struct device *dev, mutex_lock(&devfreq_list_lock); - governor = try_then_request_governor(devfreq->governor_name); + governor = try_then_request_governor(governor_name); if (IS_ERR(governor)) { dev_err(dev, "%s: Unable to find governor for the device\n", __func__); @@ -1249,7 +1248,7 @@ int devfreq_add_governor(struct devfreq_governor *governor) int ret = 0; struct device *dev = devfreq->dev.parent; - if (!strncmp(devfreq->governor_name, governor->name, + if (!strncmp(devfreq->governor->name, governor->name, DEVFREQ_NAME_LEN)) { /* The following should never occur */ if (devfreq->governor) { @@ -1311,7 +1310,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor) int ret; struct device *dev = devfreq->dev.parent; - if (!strncmp(devfreq->governor_name, governor->name, + if (!strncmp(devfreq->governor->name, governor->name, DEVFREQ_NAME_LEN)) { /* we should have a devfreq governor! */ if (!devfreq->governor) { @@ -1406,7 +1405,6 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr, */ prev_governor = df->governor; df->governor = governor; - strncpy(df->governor_name, governor->name, DEVFREQ_NAME_LEN); ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL); if (ret) { dev_warn(dev, "%s: Governor %s not started(%d)\n", @@ -1414,13 +1412,11 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr, /* Restore previous governor */ df->governor = prev_governor; - strncpy(df->governor_name, prev_governor->name, - DEVFREQ_NAME_LEN); ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL); if (ret) { dev_err(dev, "%s: reverting to Governor %s failed (%d)\n", - __func__, df->governor_name, ret); + __func__, prev_governor->name, ret); df->governor = NULL; goto out; } @@ -1459,7 +1455,7 @@ static ssize_t available_governors_show(struct device *d, */ if (IS_SUPPORTED_FLAG(df->governor->flags, IMMUTABLE)) { count = scnprintf(&buf[count], DEVFREQ_NAME_LEN, - "%s ", df->governor_name); + "%s ", df->governor->name); /* * The devfreq device shows the registered governor except for * immutable governors such as passive governor . @@ -1902,7 +1898,7 @@ static int devfreq_summary_show(struct seq_file *s, void *data) list_for_each_entry_reverse(devfreq, &devfreq_list, node) { #if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE) - if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE, + if (!strncmp(devfreq->governor->name, DEVFREQ_GOV_PASSIVE, DEVFREQ_NAME_LEN)) { struct devfreq_passive_data *data = devfreq->data; @@ -1928,7 +1924,7 @@ static int devfreq_summary_show(struct seq_file *s, void *data) "%-30s %-30s %-15s %-10s %10d %12ld %12ld %12ld\n", dev_name(&devfreq->dev), p_devfreq ? dev_name(&p_devfreq->dev) : "null", - devfreq->governor_name, + devfreq->governor->name, polling_ms ? timer_name[timer] : "null", polling_ms, cur_freq, diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h index df413b851bb2..2a52f97b542d 100644 --- a/drivers/devfreq/governor.h +++ b/drivers/devfreq/governor.h @@ -13,6 +13,8 @@ #include <linux/devfreq.h> +#define DEVFREQ_NAME_LEN 16 + #define to_devfreq(DEV) container_of((DEV), struct devfreq, dev) /* Devfreq events */ |