attribute_container.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * class_container.h - a generic container for all classes
  3. *
  4. * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
  5. *
  6. * This file is licensed under GPLv2
  7. */
  8. #ifndef _ATTRIBUTE_CONTAINER_H_
  9. #define _ATTRIBUTE_CONTAINER_H_
  10. #include <linux/device.h>
  11. #include <linux/list.h>
  12. #include <linux/klist.h>
  13. struct attribute_container {
  14. struct list_head node;
  15. struct klist containers;
  16. struct class *class;
  17. struct class_device_attribute **attrs;
  18. int (*match)(struct attribute_container *, struct device *);
  19. #define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01
  20. unsigned long flags;
  21. };
  22. static inline int
  23. attribute_container_no_classdevs(struct attribute_container *atc)
  24. {
  25. return atc->flags & ATTRIBUTE_CONTAINER_NO_CLASSDEVS;
  26. }
  27. static inline void
  28. attribute_container_set_no_classdevs(struct attribute_container *atc)
  29. {
  30. atc->flags |= ATTRIBUTE_CONTAINER_NO_CLASSDEVS;
  31. }
  32. int attribute_container_register(struct attribute_container *cont);
  33. int attribute_container_unregister(struct attribute_container *cont);
  34. void attribute_container_create_device(struct device *dev,
  35. int (*fn)(struct attribute_container *,
  36. struct device *,
  37. struct class_device *));
  38. void attribute_container_add_device(struct device *dev,
  39. int (*fn)(struct attribute_container *,
  40. struct device *,
  41. struct class_device *));
  42. void attribute_container_remove_device(struct device *dev,
  43. void (*fn)(struct attribute_container *,
  44. struct device *,
  45. struct class_device *));
  46. void attribute_container_device_trigger(struct device *dev,
  47. int (*fn)(struct attribute_container *,
  48. struct device *,
  49. struct class_device *));
  50. void attribute_container_trigger(struct device *dev,
  51. int (*fn)(struct attribute_container *,
  52. struct device *));
  53. int attribute_container_add_attrs(struct class_device *classdev);
  54. int attribute_container_add_class_device(struct class_device *classdev);
  55. int attribute_container_add_class_device_adapter(struct attribute_container *cont,
  56. struct device *dev,
  57. struct class_device *classdev);
  58. void attribute_container_remove_attrs(struct class_device *classdev);
  59. void attribute_container_class_device_del(struct class_device *classdev);
  60. struct attribute_container *attribute_container_classdev_to_container(struct class_device *);
  61. struct class_device *attribute_container_find_class_device(struct attribute_container *, struct device *);
  62. struct class_device_attribute **attribute_container_classdev_to_attrs(const struct class_device *classdev);
  63. #endif