sw_trigger.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Industrial I/O software trigger interface
  4. *
  5. * Copyright (c) 2015 Intel Corporation
  6. */
  7. #ifndef __IIO_SW_TRIGGER
  8. #define __IIO_SW_TRIGGER
  9. #include <linux/module.h>
  10. #include <linux/device.h>
  11. #include <linux/iio/iio.h>
  12. #include <linux/configfs.h>
  13. #define module_iio_sw_trigger_driver(__iio_sw_trigger_type) \
  14. module_driver(__iio_sw_trigger_type, iio_register_sw_trigger_type, \
  15. iio_unregister_sw_trigger_type)
  16. struct iio_sw_trigger_ops;
  17. struct iio_sw_trigger_type {
  18. const char *name;
  19. struct module *owner;
  20. const struct iio_sw_trigger_ops *ops;
  21. struct list_head list;
  22. struct config_group *group;
  23. };
  24. struct iio_sw_trigger {
  25. struct iio_trigger *trigger;
  26. struct iio_sw_trigger_type *trigger_type;
  27. struct config_group group;
  28. };
  29. struct iio_sw_trigger_ops {
  30. struct iio_sw_trigger* (*probe)(const char *);
  31. int (*remove)(struct iio_sw_trigger *);
  32. };
  33. static inline
  34. struct iio_sw_trigger *to_iio_sw_trigger(struct config_item *item)
  35. {
  36. return container_of(to_config_group(item), struct iio_sw_trigger,
  37. group);
  38. }
  39. int iio_register_sw_trigger_type(struct iio_sw_trigger_type *tt);
  40. void iio_unregister_sw_trigger_type(struct iio_sw_trigger_type *tt);
  41. struct iio_sw_trigger *iio_sw_trigger_create(const char *, const char *);
  42. void iio_sw_trigger_destroy(struct iio_sw_trigger *);
  43. int iio_sw_trigger_type_configfs_register(struct iio_sw_trigger_type *tt);
  44. void iio_sw_trigger_type_configfs_unregister(struct iio_sw_trigger_type *tt);
  45. static inline
  46. void iio_swt_group_init_type_name(struct iio_sw_trigger *t,
  47. const char *name,
  48. const struct config_item_type *type)
  49. {
  50. #if IS_ENABLED(CONFIG_CONFIGFS_FS)
  51. config_group_init_type_name(&t->group, name, type);
  52. #endif
  53. }
  54. #endif /* __IIO_SW_TRIGGER */