Lines Matching +full:devfreq +full:- +full:event

1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/drivers/devfreq/governor_userspace.c
11 #include <linux/devfreq.h>
22 static int devfreq_userspace_func(struct devfreq *df, unsigned long *freq) in devfreq_userspace_func()
24 struct userspace_data *data = df->governor_data; in devfreq_userspace_func()
26 if (data->valid) in devfreq_userspace_func()
27 *freq = data->user_frequency; in devfreq_userspace_func()
29 *freq = df->previous_freq; /* No user freq specified yet */ in devfreq_userspace_func()
37 struct devfreq *devfreq = to_devfreq(dev); in set_freq_store() local
42 mutex_lock(&devfreq->lock); in set_freq_store()
43 data = devfreq->governor_data; in set_freq_store()
46 data->user_frequency = wanted; in set_freq_store()
47 data->valid = true; in set_freq_store()
48 err = update_devfreq(devfreq); in set_freq_store()
51 mutex_unlock(&devfreq->lock); in set_freq_store()
58 struct devfreq *devfreq = to_devfreq(dev); in set_freq_show() local
62 mutex_lock(&devfreq->lock); in set_freq_show()
63 data = devfreq->governor_data; in set_freq_show()
65 if (data->valid) in set_freq_show()
66 err = sprintf(buf, "%lu\n", data->user_frequency); in set_freq_show()
69 mutex_unlock(&devfreq->lock); in set_freq_show()
83 static int userspace_init(struct devfreq *devfreq) in userspace_init() argument
90 err = -ENOMEM; in userspace_init()
93 data->valid = false; in userspace_init()
94 devfreq->governor_data = data; in userspace_init()
96 err = sysfs_create_group(&devfreq->dev.kobj, &dev_attr_group); in userspace_init()
101 static void userspace_exit(struct devfreq *devfreq) in userspace_exit() argument
107 if (devfreq->dev.kobj.sd) in userspace_exit()
108 sysfs_remove_group(&devfreq->dev.kobj, &dev_attr_group); in userspace_exit()
110 kfree(devfreq->governor_data); in userspace_exit()
111 devfreq->governor_data = NULL; in userspace_exit()
114 static int devfreq_userspace_handler(struct devfreq *devfreq, in devfreq_userspace_handler() argument
115 unsigned int event, void *data) in devfreq_userspace_handler() argument
119 switch (event) { in devfreq_userspace_handler()
121 ret = userspace_init(devfreq); in devfreq_userspace_handler()
124 userspace_exit(devfreq); in devfreq_userspace_handler()
156 MODULE_DESCRIPTION("DEVFREQ Userspace governor");