0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/init.h>
0012 #include <linux/module.h>
0013 #include <linux/fs.h>
0014 #include <linux/miscdevice.h>
0015 #include <linux/uaccess.h>
0016 #include <asm/bL_switcher.h>
0017
0018 static ssize_t bL_switcher_write(struct file *file, const char __user *buf,
0019 size_t len, loff_t *pos)
0020 {
0021 unsigned char val[3];
0022 unsigned int cpu, cluster;
0023 int ret;
0024
0025 pr_debug("%s\n", __func__);
0026
0027 if (len < 3)
0028 return -EINVAL;
0029
0030 if (copy_from_user(val, buf, 3))
0031 return -EFAULT;
0032
0033
0034 if (val[0] < '0' || val[0] > '9' ||
0035 val[1] != ',' ||
0036 val[2] < '0' || val[2] > '1')
0037 return -EINVAL;
0038
0039 cpu = val[0] - '0';
0040 cluster = val[2] - '0';
0041 ret = bL_switch_request(cpu, cluster);
0042
0043 return ret ? : len;
0044 }
0045
0046 static const struct file_operations bL_switcher_fops = {
0047 .write = bL_switcher_write,
0048 .owner = THIS_MODULE,
0049 };
0050
0051 static struct miscdevice bL_switcher_device = {
0052 MISC_DYNAMIC_MINOR,
0053 "b.L_switcher",
0054 &bL_switcher_fops
0055 };
0056 module_misc_device(bL_switcher_device);
0057
0058 MODULE_AUTHOR("Nicolas Pitre <nico@linaro.org>");
0059 MODULE_LICENSE("GPL v2");
0060 MODULE_DESCRIPTION("big.LITTLE switcher dummy user interface");