summaryrefslogtreecommitdiff
path: root/drivers/devfreq/devfreq.c
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2015-07-14 18:45:27 +0900
committerSeung-Woo Kim <sw0312.kim@samsung.com>2016-12-14 13:46:48 +0900
commite295ac9b928e9fe0a33b9fee2ac27f210b78dbec (patch)
tree21e9295da3560f3a8ac7b119739734a406a9cfa9 /drivers/devfreq/devfreq.c
parentca88176a87dd14e3fe479341b6f4242b55f4ebe8 (diff)
PM: devfreq: Add the prototype of update_devfreq() to export
This patch add simply the protoptye of update_devfreq() to devfreq.h header file to export it. The some device driver (e.g., thermal cooling device) may use the update_devfreq() to update the range of supported frequency of devfreq device. Cc: MyungJoo Ham <myungjoo.ham@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/devfreq/devfreq.c')
-rw-r--r--drivers/devfreq/devfreq.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index ca1b362d77e2..2aa5e4e9df36 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -163,18 +163,17 @@ int update_devfreq(struct devfreq *devfreq)
int err = 0;
u32 flags = 0;
- if (!mutex_is_locked(&devfreq->lock)) {
- WARN(true, "devfreq->lock must be locked by the caller.\n");
- return -EINVAL;
- }
-
if (!devfreq->governor)
return -EINVAL;
+ mutex_lock(&devfreq->lock);
+
/* Reevaluate the proper frequency */
err = devfreq->governor->get_target_freq(devfreq, &freq);
- if (err)
+ if (err) {
+ mutex_unlock(&devfreq->lock);
return err;
+ }
/*
* Adjust the freuqency with user freq and QoS.
@@ -194,8 +193,10 @@ int update_devfreq(struct devfreq *devfreq)
}
err = devfreq->profile->target(devfreq->dev.parent, &freq, flags);
- if (err)
+ if (err) {
+ mutex_unlock(&devfreq->lock);
return err;
+ }
if (devfreq->profile->freq_table)
if (devfreq_update_status(devfreq, freq))
@@ -203,6 +204,9 @@ int update_devfreq(struct devfreq *devfreq)
"Couldn't update frequency transition information.\n");
devfreq->previous_freq = freq;
+
+ mutex_unlock(&devfreq->lock);
+
return err;
}
EXPORT_SYMBOL(update_devfreq);
@@ -218,14 +222,12 @@ static void devfreq_monitor(struct work_struct *work)
struct devfreq *devfreq = container_of(work,
struct devfreq, work.work);
- mutex_lock(&devfreq->lock);
err = update_devfreq(devfreq);
if (err)
dev_err(&devfreq->dev, "dvfs failed with (%d) error\n", err);
queue_delayed_work(devfreq_wq, &devfreq->work,
msecs_to_jiffies(devfreq->profile->polling_ms));
- mutex_unlock(&devfreq->lock);
}
/**
@@ -382,9 +384,7 @@ static int devfreq_notifier_call(struct notifier_block *nb, unsigned long type,
struct devfreq *devfreq = container_of(nb, struct devfreq, nb);
int ret;
- mutex_lock(&devfreq->lock);
ret = update_devfreq(devfreq);
- mutex_unlock(&devfreq->lock);
return ret;
}