0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __IIO_SW_TRIGGER
0009 #define __IIO_SW_TRIGGER
0010
0011 #include <linux/module.h>
0012 #include <linux/device.h>
0013 #include <linux/iio/iio.h>
0014 #include <linux/configfs.h>
0015
0016 #define module_iio_sw_trigger_driver(__iio_sw_trigger_type) \
0017 module_driver(__iio_sw_trigger_type, iio_register_sw_trigger_type, \
0018 iio_unregister_sw_trigger_type)
0019
0020 struct iio_sw_trigger_ops;
0021
0022 struct iio_sw_trigger_type {
0023 const char *name;
0024 struct module *owner;
0025 const struct iio_sw_trigger_ops *ops;
0026 struct list_head list;
0027 struct config_group *group;
0028 };
0029
0030 struct iio_sw_trigger {
0031 struct iio_trigger *trigger;
0032 struct iio_sw_trigger_type *trigger_type;
0033 struct config_group group;
0034 };
0035
0036 struct iio_sw_trigger_ops {
0037 struct iio_sw_trigger* (*probe)(const char *);
0038 int (*remove)(struct iio_sw_trigger *);
0039 };
0040
0041 static inline
0042 struct iio_sw_trigger *to_iio_sw_trigger(struct config_item *item)
0043 {
0044 return container_of(to_config_group(item), struct iio_sw_trigger,
0045 group);
0046 }
0047
0048 int iio_register_sw_trigger_type(struct iio_sw_trigger_type *tt);
0049 void iio_unregister_sw_trigger_type(struct iio_sw_trigger_type *tt);
0050
0051 struct iio_sw_trigger *iio_sw_trigger_create(const char *, const char *);
0052 void iio_sw_trigger_destroy(struct iio_sw_trigger *);
0053
0054 int iio_sw_trigger_type_configfs_register(struct iio_sw_trigger_type *tt);
0055 void iio_sw_trigger_type_configfs_unregister(struct iio_sw_trigger_type *tt);
0056
0057 static inline
0058 void iio_swt_group_init_type_name(struct iio_sw_trigger *t,
0059 const char *name,
0060 const struct config_item_type *type)
0061 {
0062 #if IS_ENABLED(CONFIG_CONFIGFS_FS)
0063 config_group_init_type_name(&t->group, name, type);
0064 #endif
0065 }
0066
0067 #endif