diff options
Diffstat (limited to 'include/linux/iio/sw_device.h')
-rw-r--r-- | include/linux/iio/sw_device.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/include/linux/iio/sw_device.h b/include/linux/iio/sw_device.h new file mode 100644 index 000000000000..23ca41515527 --- /dev/null +++ b/include/linux/iio/sw_device.h | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * Industrial I/O software device interface | ||
3 | * | ||
4 | * Copyright (c) 2016 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_DEVICE | ||
12 | #define __IIO_SW_DEVICE | ||
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_device_driver(__iio_sw_device_type) \ | ||
20 | module_driver(__iio_sw_device_type, iio_register_sw_device_type, \ | ||
21 | iio_unregister_sw_device_type) | ||
22 | |||
23 | struct iio_sw_device_ops; | ||
24 | |||
25 | struct iio_sw_device_type { | ||
26 | const char *name; | ||
27 | struct module *owner; | ||
28 | const struct iio_sw_device_ops *ops; | ||
29 | struct list_head list; | ||
30 | struct config_group *group; | ||
31 | }; | ||
32 | |||
33 | struct iio_sw_device { | ||
34 | struct iio_dev *device; | ||
35 | struct iio_sw_device_type *device_type; | ||
36 | struct config_group group; | ||
37 | }; | ||
38 | |||
39 | struct iio_sw_device_ops { | ||
40 | struct iio_sw_device* (*probe)(const char *); | ||
41 | int (*remove)(struct iio_sw_device *); | ||
42 | }; | ||
43 | |||
44 | static inline | ||
45 | struct iio_sw_device *to_iio_sw_device(struct config_item *item) | ||
46 | { | ||
47 | return container_of(to_config_group(item), struct iio_sw_device, | ||
48 | group); | ||
49 | } | ||
50 | |||
51 | int iio_register_sw_device_type(struct iio_sw_device_type *dt); | ||
52 | void iio_unregister_sw_device_type(struct iio_sw_device_type *dt); | ||
53 | |||
54 | struct iio_sw_device *iio_sw_device_create(const char *, const char *); | ||
55 | void iio_sw_device_destroy(struct iio_sw_device *); | ||
56 | |||
57 | int iio_sw_device_type_configfs_register(struct iio_sw_device_type *dt); | ||
58 | void iio_sw_device_type_configfs_unregister(struct iio_sw_device_type *dt); | ||
59 | |||
60 | static inline | ||
61 | void iio_swd_group_init_type_name(struct iio_sw_device *d, | ||
62 | const char *name, | ||
63 | struct config_item_type *type) | ||
64 | { | ||
65 | #ifdef CONFIG_CONFIGFS_FS | ||
66 | config_group_init_type_name(&d->group, name, type); | ||
67 | #endif | ||
68 | } | ||
69 | |||
70 | #endif /* __IIO_SW_DEVICE */ | ||