merisc_sysfs.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Merisc sysfs exports
  3. *
  4. * Copyright (C) 2008 Martinsson Elektronik AB
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/list.h>
  14. #include <linux/spinlock.h>
  15. #include <linux/device.h>
  16. #include <linux/timer.h>
  17. #include <linux/err.h>
  18. #include <linux/ctype.h>
  19. #include "merisc.h"
  20. static ssize_t merisc_model_show(struct class *class, char *buf)
  21. {
  22. ssize_t ret = 0;
  23. sprintf(buf, "%s\n", merisc_model());
  24. ret = strlen(buf) + 1;
  25. return ret;
  26. }
  27. static ssize_t merisc_revision_show(struct class *class, char *buf)
  28. {
  29. ssize_t ret = 0;
  30. sprintf(buf, "%s\n", merisc_revision());
  31. ret = strlen(buf) + 1;
  32. return ret;
  33. }
  34. static struct class_attribute merisc_class_attrs[] = {
  35. __ATTR(model, S_IRUGO, merisc_model_show, NULL),
  36. __ATTR(revision, S_IRUGO, merisc_revision_show, NULL),
  37. __ATTR_NULL,
  38. };
  39. struct class merisc_class = {
  40. .name = "merisc",
  41. .owner = THIS_MODULE,
  42. .class_attrs = merisc_class_attrs,
  43. };
  44. static int __init merisc_sysfs_init(void)
  45. {
  46. int status;
  47. status = class_register(&merisc_class);
  48. if (status < 0)
  49. return status;
  50. return 0;
  51. }
  52. postcore_initcall(merisc_sysfs_init);