dio-sysfs.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * File Attributes for DIO Devices
  3. *
  4. * Copyright (C) 2004 Jochen Friedrich
  5. *
  6. * Loosely based on drivers/pci/pci-sysfs.c and drivers/zorro/zorro-sysfs.c
  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/dio.h>
  14. #include <linux/stat.h>
  15. /* show configuration fields */
  16. static ssize_t dio_show_id(struct device *dev, struct device_attribute *attr, char *buf)
  17. {
  18. struct dio_dev *d;
  19. d = to_dio_dev(dev);
  20. return sprintf(buf, "0x%02x\n", (d->id & 0xff));
  21. }
  22. static DEVICE_ATTR(id, S_IRUGO, dio_show_id, NULL);
  23. static ssize_t dio_show_ipl(struct device *dev, struct device_attribute *attr, char *buf)
  24. {
  25. struct dio_dev *d;
  26. d = to_dio_dev(dev);
  27. return sprintf(buf, "0x%02x\n", d->ipl);
  28. }
  29. static DEVICE_ATTR(ipl, S_IRUGO, dio_show_ipl, NULL);
  30. static ssize_t dio_show_secid(struct device *dev, struct device_attribute *attr, char *buf)
  31. {
  32. struct dio_dev *d;
  33. d = to_dio_dev(dev);
  34. return sprintf(buf, "0x%02x\n", ((d->id >> 8)& 0xff));
  35. }
  36. static DEVICE_ATTR(secid, S_IRUGO, dio_show_secid, NULL);
  37. static ssize_t dio_show_name(struct device *dev, struct device_attribute *attr, char *buf)
  38. {
  39. struct dio_dev *d;
  40. d = to_dio_dev(dev);
  41. return sprintf(buf, "%s\n", d->name);
  42. }
  43. static DEVICE_ATTR(name, S_IRUGO, dio_show_name, NULL);
  44. static ssize_t dio_show_resource(struct device *dev, struct device_attribute *attr, char *buf)
  45. {
  46. struct dio_dev *d = to_dio_dev(dev);
  47. return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
  48. dio_resource_start(d), dio_resource_end(d),
  49. dio_resource_flags(d));
  50. }
  51. static DEVICE_ATTR(resource, S_IRUGO, dio_show_resource, NULL);
  52. void dio_create_sysfs_dev_files(struct dio_dev *d)
  53. {
  54. struct device *dev = &d->dev;
  55. /* current configuration's attributes */
  56. device_create_file(dev, &dev_attr_id);
  57. device_create_file(dev, &dev_attr_ipl);
  58. device_create_file(dev, &dev_attr_secid);
  59. device_create_file(dev, &dev_attr_name);
  60. device_create_file(dev, &dev_attr_resource);
  61. }