extcon.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef __LINUX_EXTCON_INTERNAL_H__
  2. #define __LINUX_EXTCON_INTERNAL_H__
  3. #include <linux/extcon.h>
  4. /**
  5. * struct extcon_dev - An extcon device represents one external connector.
  6. * @name: The name of this extcon device. Parent device name is
  7. * used if NULL.
  8. * @supported_cable: Array of supported cable names ending with EXTCON_NONE.
  9. * If supported_cable is NULL, cable name related APIs
  10. * are disabled.
  11. * @mutually_exclusive: Array of mutually exclusive set of cables that cannot
  12. * be attached simultaneously. The array should be
  13. * ending with NULL or be NULL (no mutually exclusive
  14. * cables). For example, if it is { 0x7, 0x30, 0}, then,
  15. * {0, 1}, {0, 1, 2}, {0, 2}, {1, 2}, or {4, 5} cannot
  16. * be attached simulataneously. {0x7, 0} is equivalent to
  17. * {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there
  18. * can be no simultaneous connections.
  19. * @dev: Device of this extcon.
  20. * @state: Attach/detach state of this extcon. Do not provide at
  21. * register-time.
  22. * @nh_all: Notifier for the state change events for all supported
  23. * external connectors from this extcon.
  24. * @nh: Notifier for the state change events from this extcon
  25. * @entry: To support list of extcon devices so that users can
  26. * search for extcon devices based on the extcon name.
  27. * @lock:
  28. * @max_supported: Internal value to store the number of cables.
  29. * @extcon_dev_type: Device_type struct to provide attribute_groups
  30. * customized for each extcon device.
  31. * @cables: Sysfs subdirectories. Each represents one cable.
  32. *
  33. * In most cases, users only need to provide "User initializing data" of
  34. * this struct when registering an extcon. In some exceptional cases,
  35. * optional callbacks may be needed. However, the values in "internal data"
  36. * are overwritten by register function.
  37. */
  38. struct extcon_dev {
  39. /* Optional user initializing data */
  40. const char *name;
  41. const unsigned int *supported_cable;
  42. const u32 *mutually_exclusive;
  43. /* Internal data. Please do not set. */
  44. struct device dev;
  45. struct raw_notifier_head nh_all;
  46. struct raw_notifier_head *nh;
  47. struct list_head entry;
  48. int max_supported;
  49. spinlock_t lock; /* could be called by irq handler */
  50. u32 state;
  51. /* /sys/class/extcon/.../cable.n/... */
  52. struct device_type extcon_dev_type;
  53. struct extcon_cable *cables;
  54. /* /sys/class/extcon/.../mutually_exclusive/... */
  55. struct attribute_group attr_g_muex;
  56. struct attribute **attrs_muex;
  57. struct device_attribute *d_attrs_muex;
  58. };
  59. #endif /* __LINUX_EXTCON_INTERNAL_H__ */