* [PATCH] PM / devfreq: Remove list_for_each_entry() in devfreq_add_governor()
@ 2019-07-29 9:26 Yue Hu
0 siblings, 0 replies; only message in thread
From: Yue Hu @ 2019-07-29 9:26 UTC (permalink / raw)
To: myungjoo.ham, kyungmin.park, cw00.choi; +Cc: linux-pm, huyue2
From: Yue Hu <huyue2@yulong.com>
We will call try_then_request_governor() to find a governor from a list
of devfreq_governor_list in devfreq_add_device(). Only if the governor
has been registered in this list, the devfreq adding will be successful,
fails if not. That means we should do the governor registration charged
by devfreq_add_governor() before adding devfreq for a device with this
governor. So, the devfreq_list would not contains the device which has
the governor to be added when registering governor.
Moreover, use EEXIST instead of EINVAL in devfreq_add_{governor,device},
update message existing related also.
Signed-off-by: Yue Hu <huyue2@yulong.com>
---
drivers/devfreq/devfreq.c | 39 +++------------------------------------
1 file changed, 3 insertions(+), 36 deletions(-)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 784c08e..104f03d 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -625,9 +625,9 @@ struct devfreq *devfreq_add_device(struct device *dev,
devfreq = find_device_devfreq(dev);
mutex_unlock(&devfreq_list_lock);
if (!IS_ERR(devfreq)) {
- dev_err(dev, "%s: Unable to create devfreq for the device.\n",
+ dev_err(dev, "%s: Existing devfreq for the device.\n",
__func__);
- err = -EINVAL;
+ err = -EEXIST;
goto err_out;
}
@@ -998,7 +998,6 @@ void devfreq_resume(void)
int devfreq_add_governor(struct devfreq_governor *governor)
{
struct devfreq_governor *g;
- struct devfreq *devfreq;
int err = 0;
if (!governor) {
@@ -1011,44 +1010,12 @@ int devfreq_add_governor(struct devfreq_governor *governor)
if (!IS_ERR(g)) {
pr_err("%s: governor %s already registered\n", __func__,
g->name);
- err = -EINVAL;
+ err = -EEXIST;
goto err_out;
}
list_add(&governor->node, &devfreq_governor_list);
- list_for_each_entry(devfreq, &devfreq_list, node) {
- int ret = 0;
- struct device *dev = devfreq->dev.parent;
-
- if (!strncmp(devfreq->governor_name, governor->name,
- DEVFREQ_NAME_LEN)) {
- /* The following should never occur */
- if (devfreq->governor) {
- dev_warn(dev,
- "%s: Governor %s already present\n",
- __func__, devfreq->governor->name);
- ret = devfreq->governor->event_handler(devfreq,
- DEVFREQ_GOV_STOP, NULL);
- if (ret) {
- dev_warn(dev,
- "%s: Governor %s stop = %d\n",
- __func__,
- devfreq->governor->name, ret);
- }
- /* Fall through */
- }
- devfreq->governor = governor;
- ret = devfreq->governor->event_handler(devfreq,
- DEVFREQ_GOV_START, NULL);
- if (ret) {
- dev_warn(dev, "%s: Governor %s start=%d\n",
- __func__, devfreq->governor->name,
- ret);
- }
- }
- }
-
err_out:
mutex_unlock(&devfreq_list_lock);
--
1.9.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-07-29 9:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 9:26 [PATCH] PM / devfreq: Remove list_for_each_entry() in devfreq_add_governor() Yue Hu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).