diff options
-rw-r--r-- | drivers/devfreq/devfreq.c | 31 | ||||
-rw-r--r-- | drivers/devfreq/governor_passive.c | 1 | ||||
-rw-r--r-- | include/linux/devfreq.h | 3 |
3 files changed, 31 insertions, 4 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 8e5938c9c7d6..ade279d29f1e 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c | |||
@@ -940,6 +940,9 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr, | |||
940 | if (df->governor == governor) { | 940 | if (df->governor == governor) { |
941 | ret = 0; | 941 | ret = 0; |
942 | goto out; | 942 | goto out; |
943 | } else if (df->governor->immutable || governor->immutable) { | ||
944 | ret = -EINVAL; | ||
945 | goto out; | ||
943 | } | 946 | } |
944 | 947 | ||
945 | if (df->governor) { | 948 | if (df->governor) { |
@@ -969,13 +972,33 @@ static ssize_t available_governors_show(struct device *d, | |||
969 | struct device_attribute *attr, | 972 | struct device_attribute *attr, |
970 | char *buf) | 973 | char *buf) |
971 | { | 974 | { |
972 | struct devfreq_governor *tmp_governor; | 975 | struct devfreq *df = to_devfreq(d); |
973 | ssize_t count = 0; | 976 | ssize_t count = 0; |
974 | 977 | ||
975 | mutex_lock(&devfreq_list_lock); | 978 | mutex_lock(&devfreq_list_lock); |
976 | list_for_each_entry(tmp_governor, &devfreq_governor_list, node) | 979 | |
977 | count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), | 980 | /* |
978 | "%s ", tmp_governor->name); | 981 | * The devfreq with immutable governor (e.g., passive) shows |
982 | * only own governor. | ||
983 | */ | ||
984 | if (df->governor->immutable) { | ||
985 | count = scnprintf(&buf[count], DEVFREQ_NAME_LEN, | ||
986 | "%s ", df->governor_name); | ||
987 | /* | ||
988 | * The devfreq device shows the registered governor except for | ||
989 | * immutable governors such as passive governor . | ||
990 | */ | ||
991 | } else { | ||
992 | struct devfreq_governor *governor; | ||
993 | |||
994 | list_for_each_entry(governor, &devfreq_governor_list, node) { | ||
995 | if (governor->immutable) | ||
996 | continue; | ||
997 | count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), | ||
998 | "%s ", governor->name); | ||
999 | } | ||
1000 | } | ||
1001 | |||
979 | mutex_unlock(&devfreq_list_lock); | 1002 | mutex_unlock(&devfreq_list_lock); |
980 | 1003 | ||
981 | /* Truncate the trailing space */ | 1004 | /* Truncate the trailing space */ |
diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index 9ef46e2592c4..93795b32dc09 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c | |||
@@ -179,6 +179,7 @@ static int devfreq_passive_event_handler(struct devfreq *devfreq, | |||
179 | 179 | ||
180 | static struct devfreq_governor devfreq_passive = { | 180 | static struct devfreq_governor devfreq_passive = { |
181 | .name = "passive", | 181 | .name = "passive", |
182 | .immutable = 1, | ||
182 | .get_target_freq = devfreq_passive_get_target_freq, | 183 | .get_target_freq = devfreq_passive_get_target_freq, |
183 | .event_handler = devfreq_passive_event_handler, | 184 | .event_handler = devfreq_passive_event_handler, |
184 | }; | 185 | }; |
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 2de4e2eea180..e0acb0e5243b 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h | |||
@@ -104,6 +104,8 @@ struct devfreq_dev_profile { | |||
104 | * struct devfreq_governor - Devfreq policy governor | 104 | * struct devfreq_governor - Devfreq policy governor |
105 | * @node: list node - contains registered devfreq governors | 105 | * @node: list node - contains registered devfreq governors |
106 | * @name: Governor's name | 106 | * @name: Governor's name |
107 | * @immutable: Immutable flag for governor. If the value is 1, | ||
108 | * this govenror is never changeable to other governor. | ||
107 | * @get_target_freq: Returns desired operating frequency for the device. | 109 | * @get_target_freq: Returns desired operating frequency for the device. |
108 | * Basically, get_target_freq will run | 110 | * Basically, get_target_freq will run |
109 | * devfreq_dev_profile.get_dev_status() to get the | 111 | * devfreq_dev_profile.get_dev_status() to get the |
@@ -121,6 +123,7 @@ struct devfreq_governor { | |||
121 | struct list_head node; | 123 | struct list_head node; |
122 | 124 | ||
123 | const char name[DEVFREQ_NAME_LEN]; | 125 | const char name[DEVFREQ_NAME_LEN]; |
126 | const unsigned int immutable; | ||
124 | int (*get_target_freq)(struct devfreq *this, unsigned long *freq); | 127 | int (*get_target_freq)(struct devfreq *this, unsigned long *freq); |
125 | int (*event_handler)(struct devfreq *devfreq, | 128 | int (*event_handler)(struct devfreq *devfreq, |
126 | unsigned int event, void *data); | 129 | unsigned int event, void *data); |