Path: blob/master/arch/arm/common/bL_switcher_dummy_if.c
26295 views
// SPDX-License-Identifier: GPL-2.0-only1/*2* arch/arm/common/bL_switcher_dummy_if.c -- b.L switcher dummy interface3*4* Created by: Nicolas Pitre, November 20125* Copyright: (C) 2012-2013 Linaro Limited6*7* Dummy interface to user space for debugging purpose only.8*/910#include <linux/init.h>11#include <linux/module.h>12#include <linux/fs.h>13#include <linux/miscdevice.h>14#include <linux/uaccess.h>15#include <asm/bL_switcher.h>1617static ssize_t bL_switcher_write(struct file *file, const char __user *buf,18size_t len, loff_t *pos)19{20unsigned char val[3];21unsigned int cpu, cluster;22int ret;2324pr_debug("%s\n", __func__);2526if (len < 3)27return -EINVAL;2829if (copy_from_user(val, buf, 3))30return -EFAULT;3132/* format: <cpu#>,<cluster#> */33if (val[0] < '0' || val[0] > '9' ||34val[1] != ',' ||35val[2] < '0' || val[2] > '1')36return -EINVAL;3738cpu = val[0] - '0';39cluster = val[2] - '0';40ret = bL_switch_request(cpu, cluster);4142return ret ? : len;43}4445static const struct file_operations bL_switcher_fops = {46.write = bL_switcher_write,47.owner = THIS_MODULE,48};4950static struct miscdevice bL_switcher_device = {51MISC_DYNAMIC_MINOR,52"b.L_switcher",53&bL_switcher_fops54};55module_misc_device(bL_switcher_device);5657MODULE_AUTHOR("Nicolas Pitre <[email protected]>");58MODULE_LICENSE("GPL v2");59MODULE_DESCRIPTION("big.LITTLE switcher dummy user interface");606162