PM / devfreq: Core updates to support devices which can idle
[cascardo/linux.git] / drivers / devfreq / governor_powersave.c
1 /*
2  *  linux/drivers/devfreq/governor_powersave.c
3  *
4  *  Copyright (C) 2011 Samsung Electronics
5  *      MyungJoo Ham <myungjoo.ham@samsung.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11
12 #include <linux/devfreq.h>
13 #include "governor.h"
14
15 static int devfreq_powersave_func(struct devfreq *df,
16                                   unsigned long *freq)
17 {
18         /*
19          * target callback should be able to get ceiling value as
20          * said in devfreq.h
21          */
22         *freq = df->min_freq;
23         return 0;
24 }
25
26 static int devfreq_powersave_handler(struct devfreq *devfreq,
27                                 unsigned int event, void *data)
28 {
29         int ret = 0;
30
31         if (event == DEVFREQ_GOV_START) {
32                 mutex_lock(&devfreq->lock);
33                 ret = update_devfreq(devfreq);
34                 mutex_unlock(&devfreq->lock);
35         }
36
37         return ret;
38 }
39
40 const struct devfreq_governor devfreq_powersave = {
41         .name = "powersave",
42         .get_target_freq = devfreq_powersave_func,
43         .event_handler = devfreq_powersave_handler,
44 };