PM / devfreq: Unify frequency change to devfreq_update_target func
The update_devfreq() and update_passive_devfreq() have the duplicate code when changing the target frequency on final stage. So, unify frequency change code to devfreq_update_target() to remove the duplicate code and to centralize the frequency change code. Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
This commit is contained in:
Родитель
4281461c01
Коммит
b4365423bb
|
@ -382,18 +382,19 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load monitoring helper functions for governors use */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update_devfreq() - Reevaluate the device and configure frequency.
|
* devfreq_update_target() - Reevaluate the device and configure frequency
|
||||||
|
* on the final stage.
|
||||||
* @devfreq: the devfreq instance.
|
* @devfreq: the devfreq instance.
|
||||||
|
* @freq: the new frequency of parent device. This argument
|
||||||
|
* is only used for devfreq device using passive governor.
|
||||||
*
|
*
|
||||||
* Note: Lock devfreq->lock before calling update_devfreq
|
* Note: Lock devfreq->lock before calling devfreq_update_target. This function
|
||||||
* This function is exported for governors.
|
* should be only used by both update_devfreq() and devfreq governors.
|
||||||
*/
|
*/
|
||||||
int update_devfreq(struct devfreq *devfreq)
|
int devfreq_update_target(struct devfreq *devfreq, unsigned long freq)
|
||||||
{
|
{
|
||||||
unsigned long freq, min_freq, max_freq;
|
unsigned long min_freq, max_freq;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
u32 flags = 0;
|
u32 flags = 0;
|
||||||
|
|
||||||
|
@ -418,7 +419,21 @@ int update_devfreq(struct devfreq *devfreq)
|
||||||
}
|
}
|
||||||
|
|
||||||
return devfreq_set_target(devfreq, freq, flags);
|
return devfreq_set_target(devfreq, freq, flags);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(devfreq_update_target);
|
||||||
|
|
||||||
|
/* Load monitoring helper functions for governors use */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update_devfreq() - Reevaluate the device and configure frequency.
|
||||||
|
* @devfreq: the devfreq instance.
|
||||||
|
*
|
||||||
|
* Note: Lock devfreq->lock before calling update_devfreq
|
||||||
|
* This function is exported for governors.
|
||||||
|
*/
|
||||||
|
int update_devfreq(struct devfreq *devfreq)
|
||||||
|
{
|
||||||
|
return devfreq_update_target(devfreq, 0L);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(update_devfreq);
|
EXPORT_SYMBOL(update_devfreq);
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ int devfreq_add_governor(struct devfreq_governor *governor);
|
||||||
int devfreq_remove_governor(struct devfreq_governor *governor);
|
int devfreq_remove_governor(struct devfreq_governor *governor);
|
||||||
|
|
||||||
int devfreq_update_status(struct devfreq *devfreq, unsigned long freq);
|
int devfreq_update_status(struct devfreq *devfreq, unsigned long freq);
|
||||||
|
int devfreq_update_target(struct devfreq *devfreq, unsigned long freq);
|
||||||
|
|
||||||
static inline int devfreq_update_stats(struct devfreq *df)
|
static inline int devfreq_update_stats(struct devfreq *df)
|
||||||
{
|
{
|
||||||
|
|
|
@ -92,36 +92,6 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int update_devfreq_passive(struct devfreq *devfreq, unsigned long freq)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!devfreq->governor)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
mutex_lock_nested(&devfreq->lock, SINGLE_DEPTH_NESTING);
|
|
||||||
|
|
||||||
ret = devfreq->governor->get_target_freq(devfreq, &freq);
|
|
||||||
if (ret < 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
ret = devfreq->profile->target(devfreq->dev.parent, &freq, 0);
|
|
||||||
if (ret < 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
if (devfreq->profile->freq_table
|
|
||||||
&& (devfreq_update_status(devfreq, freq)))
|
|
||||||
dev_err(&devfreq->dev,
|
|
||||||
"Couldn't update frequency transition information.\n");
|
|
||||||
|
|
||||||
devfreq->previous_freq = freq;
|
|
||||||
|
|
||||||
out:
|
|
||||||
mutex_unlock(&devfreq->lock);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int devfreq_passive_notifier_call(struct notifier_block *nb,
|
static int devfreq_passive_notifier_call(struct notifier_block *nb,
|
||||||
unsigned long event, void *ptr)
|
unsigned long event, void *ptr)
|
||||||
{
|
{
|
||||||
|
@ -131,17 +101,25 @@ static int devfreq_passive_notifier_call(struct notifier_block *nb,
|
||||||
struct devfreq *parent = (struct devfreq *)data->parent;
|
struct devfreq *parent = (struct devfreq *)data->parent;
|
||||||
struct devfreq_freqs *freqs = (struct devfreq_freqs *)ptr;
|
struct devfreq_freqs *freqs = (struct devfreq_freqs *)ptr;
|
||||||
unsigned long freq = freqs->new;
|
unsigned long freq = freqs->new;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
mutex_lock_nested(&devfreq->lock, SINGLE_DEPTH_NESTING);
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEVFREQ_PRECHANGE:
|
case DEVFREQ_PRECHANGE:
|
||||||
if (parent->previous_freq > freq)
|
if (parent->previous_freq > freq)
|
||||||
update_devfreq_passive(devfreq, freq);
|
ret = devfreq_update_target(devfreq, freq);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DEVFREQ_POSTCHANGE:
|
case DEVFREQ_POSTCHANGE:
|
||||||
if (parent->previous_freq < freq)
|
if (parent->previous_freq < freq)
|
||||||
update_devfreq_passive(devfreq, freq);
|
ret = devfreq_update_target(devfreq, freq);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&devfreq->lock);
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
dev_warn(&devfreq->dev,
|
||||||
|
"failed to update devfreq using passive governor\n");
|
||||||
|
|
||||||
return NOTIFY_DONE;
|
return NOTIFY_DONE;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче