bL_switcher_dummy_if.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * arch/arm/common/bL_switcher_dummy_if.c -- b.L switcher dummy interface
  3. *
  4. * Created by: Nicolas Pitre, November 2012
  5. * Copyright: (C) 2012-2013 Linaro Limited
  6. *
  7. * Dummy interface to user space for debugging purpose only.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/module.h>
  15. #include <linux/fs.h>
  16. #include <linux/miscdevice.h>
  17. #include <asm/uaccess.h>
  18. #include <asm/bL_switcher.h>
  19. static ssize_t bL_switcher_write(struct file *file, const char __user *buf,
  20. size_t len, loff_t *pos)
  21. {
  22. unsigned char val[3];
  23. unsigned int cpu, cluster;
  24. int ret;
  25. pr_debug("%s\n", __func__);
  26. if (len < 3)
  27. return -EINVAL;
  28. if (copy_from_user(val, buf, 3))
  29. return -EFAULT;
  30. /* format: <cpu#>,<cluster#> */
  31. if (val[0] < '0' || val[0] > '9' ||
  32. val[1] != ',' ||
  33. val[2] < '0' || val[2] > '1')
  34. return -EINVAL;
  35. cpu = val[0] - '0';
  36. cluster = val[2] - '0';
  37. ret = bL_switch_request(cpu, cluster);
  38. return ret ? : len;
  39. }
  40. static const struct file_operations bL_switcher_fops = {
  41. .write = bL_switcher_write,
  42. .owner = THIS_MODULE,
  43. };
  44. static struct miscdevice bL_switcher_device = {
  45. MISC_DYNAMIC_MINOR,
  46. "b.L_switcher",
  47. &bL_switcher_fops
  48. };
  49. module_misc_device(bL_switcher_device);
  50. MODULE_AUTHOR("Nicolas Pitre <nico@linaro.org>");
  51. MODULE_LICENSE("GPL v2");
  52. MODULE_DESCRIPTION("big.LITTLE switcher dummy user interface");