superhyway-sysfs.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * drivers/sh/superhyway/superhyway-sysfs.c
  3. *
  4. * SuperHyway Bus sysfs interface
  5. *
  6. * Copyright (C) 2004, 2005 Paul Mundt <lethal@linux-sh.org>
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/device.h>
  14. #include <linux/types.h>
  15. #include <linux/superhyway.h>
  16. #define superhyway_ro_attr(name, fmt, field) \
  17. static ssize_t name##_show(struct device *dev, struct device_attribute *attr, char *buf) \
  18. { \
  19. struct superhyway_device *s = to_superhyway_device(dev); \
  20. return sprintf(buf, fmt, s->field); \
  21. } \
  22. static DEVICE_ATTR_RO(name);
  23. /* VCR flags */
  24. superhyway_ro_attr(perr_flags, "0x%02x\n", vcr.perr_flags);
  25. superhyway_ro_attr(merr_flags, "0x%02x\n", vcr.merr_flags);
  26. superhyway_ro_attr(mod_vers, "0x%04x\n", vcr.mod_vers);
  27. superhyway_ro_attr(mod_id, "0x%04x\n", vcr.mod_id);
  28. superhyway_ro_attr(bot_mb, "0x%02x\n", vcr.bot_mb);
  29. superhyway_ro_attr(top_mb, "0x%02x\n", vcr.top_mb);
  30. /* Misc */
  31. superhyway_ro_attr(resource, "0x%08lx\n", resource[0].start);
  32. static struct attribute *superhyway_dev_attrs[] = {
  33. &dev_attr_perr_flags.attr,
  34. &dev_attr_merr_flags.attr,
  35. &dev_attr_mod_vers.attr,
  36. &dev_attr_mod_id.attr,
  37. &dev_attr_bot_mb.attr,
  38. &dev_attr_top_mb.attr,
  39. &dev_attr_resource.attr,
  40. NULL,
  41. };
  42. static const struct attribute_group superhyway_dev_group = {
  43. .attrs = superhyway_dev_attrs,
  44. };
  45. const struct attribute_group *superhyway_dev_groups[] = {
  46. &superhyway_dev_group,
  47. NULL,
  48. };