Daniel Baluta | b662f80 | 2015-11-09 09:14:00 +0200 | [diff] [blame^] | 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 | |
| 11 | #ifndef __IIO_SW_TRIGGER |
| 12 | #define __IIO_SW_TRIGGER |
| 13 | |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/device.h> |
| 16 | #include <linux/iio/iio.h> |
| 17 | #include <linux/configfs.h> |
| 18 | |
| 19 | #define module_iio_sw_trigger_driver(__iio_sw_trigger_type) \ |
| 20 | module_driver(__iio_sw_trigger_type, iio_register_sw_trigger_type, \ |
| 21 | iio_unregister_sw_trigger_type) |
| 22 | |
| 23 | extern struct configfs_subsystem iio_configfs_subsys; |
| 24 | struct iio_sw_trigger_ops; |
| 25 | |
| 26 | struct iio_sw_trigger_type { |
| 27 | const char *name; |
| 28 | struct module *owner; |
| 29 | const struct iio_sw_trigger_ops *ops; |
| 30 | struct list_head list; |
| 31 | struct config_group *group; |
| 32 | }; |
| 33 | |
| 34 | struct iio_sw_trigger { |
| 35 | struct iio_trigger *trigger; |
| 36 | struct iio_sw_trigger_type *trigger_type; |
| 37 | struct config_group group; |
| 38 | }; |
| 39 | |
| 40 | struct iio_sw_trigger_ops { |
| 41 | struct iio_sw_trigger* (*probe)(const char *); |
| 42 | int (*remove)(struct iio_sw_trigger *); |
| 43 | }; |
| 44 | |
| 45 | static inline |
| 46 | struct iio_sw_trigger *to_iio_sw_trigger(struct config_item *item) |
| 47 | { |
| 48 | return container_of(to_config_group(item), struct iio_sw_trigger, |
| 49 | group); |
| 50 | } |
| 51 | |
| 52 | int iio_register_sw_trigger_type(struct iio_sw_trigger_type *tt); |
| 53 | void iio_unregister_sw_trigger_type(struct iio_sw_trigger_type *tt); |
| 54 | |
| 55 | struct iio_sw_trigger *iio_sw_trigger_create(const char *, const char *); |
| 56 | void iio_sw_trigger_destroy(struct iio_sw_trigger *); |
| 57 | |
| 58 | int iio_sw_trigger_type_configfs_register(struct iio_sw_trigger_type *tt); |
| 59 | void iio_sw_trigger_type_configfs_unregister(struct iio_sw_trigger_type *tt); |
| 60 | |
| 61 | static inline |
| 62 | void iio_swt_group_init_type_name(struct iio_sw_trigger *t, |
| 63 | const char *name, |
| 64 | struct config_item_type *type) |
| 65 | { |
| 66 | #ifdef CONFIG_CONFIGFS_FS |
| 67 | config_group_init_type_name(&t->group, name, type); |
| 68 | #endif |
| 69 | } |
| 70 | |
| 71 | #endif /* __IIO_SW_TRIGGER */ |