sw_trigger.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Industrial I/O software trigger interface
  3. *
  4. * Copyright (c) 2015 Intel Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published by
  8. * the Free Software Foundation.
  9. */
  10. #ifndef __IIO_SW_TRIGGER
  11. #define __IIO_SW_TRIGGER
  12. #include <linux/module.h>
  13. #include <linux/device.h>
  14. #include <linux/iio/iio.h>
  15. #include <linux/configfs.h>
  16. #define module_iio_sw_trigger_driver(__iio_sw_trigger_type) \
  17. module_driver(__iio_sw_trigger_type, iio_register_sw_trigger_type, \
  18. iio_unregister_sw_trigger_type)
  19. struct iio_sw_trigger_ops;
  20. struct iio_sw_trigger_type {
  21. const char *name;
  22. struct module *owner;
  23. const struct iio_sw_trigger_ops *ops;
  24. struct list_head list;
  25. struct config_group *group;
  26. };
  27. struct iio_sw_trigger {
  28. struct iio_trigger *trigger;
  29. struct iio_sw_trigger_type *trigger_type;
  30. struct config_group group;
  31. };
  32. struct iio_sw_trigger_ops {
  33. struct iio_sw_trigger* (*probe)(const char *);
  34. int (*remove)(struct iio_sw_trigger *);
  35. };
  36. static inline
  37. struct iio_sw_trigger *to_iio_sw_trigger(struct config_item *item)
  38. {
  39. return container_of(to_config_group(item), struct iio_sw_trigger,
  40. group);
  41. }
  42. int iio_register_sw_trigger_type(struct iio_sw_trigger_type *tt);
  43. void iio_unregister_sw_trigger_type(struct iio_sw_trigger_type *tt);
  44. struct iio_sw_trigger *iio_sw_trigger_create(const char *, const char *);
  45. void iio_sw_trigger_destroy(struct iio_sw_trigger *);
  46. int iio_sw_trigger_type_configfs_register(struct iio_sw_trigger_type *tt);
  47. void iio_sw_trigger_type_configfs_unregister(struct iio_sw_trigger_type *tt);
  48. static inline
  49. void iio_swt_group_init_type_name(struct iio_sw_trigger *t,
  50. const char *name,
  51. struct config_item_type *type)
  52. {
  53. #if IS_ENABLED(CONFIG_CONFIGFS_FS)
  54. config_group_init_type_name(&t->group, name, type);
  55. #endif
  56. }
  57. #endif /* __IIO_SW_TRIGGER */