1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* The industrial I/O core function defs.
4 * Copyright (c) 2008 Jonathan Cameron
6 * These definitions are meant for use only within the IIO core, not individual
12 #include <linux/kernel.h>
13 #include <linux/device.h>
19 extern const struct device_type iio_device_type;
21 struct iio_dev_buffer_pair {
22 struct iio_dev *indio_dev;
23 struct iio_buffer *buffer;
26 #define IIO_IOCTL_UNHANDLED 1
27 struct iio_ioctl_handler {
28 struct list_head entry;
29 long (*ioctl)(struct iio_dev *indio_dev, struct file *filp,
30 unsigned int cmd, unsigned long arg);
33 void iio_device_ioctl_handler_register(struct iio_dev *indio_dev,
34 struct iio_ioctl_handler *h);
35 void iio_device_ioctl_handler_unregister(struct iio_ioctl_handler *h);
37 int __iio_add_chan_devattr(const char *postfix,
38 struct iio_chan_spec const *chan,
39 ssize_t (*func)(struct device *dev,
40 struct device_attribute *attr,
42 ssize_t (*writefunc)(struct device *dev,
43 struct device_attribute *attr,
47 enum iio_shared_by shared_by,
49 struct iio_buffer *buffer,
50 struct list_head *attr_list);
51 void iio_free_chan_devattr_list(struct list_head *attr_list);
53 int iio_device_register_sysfs_group(struct iio_dev *indio_dev,
54 const struct attribute_group *group);
56 ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);
58 /* Event interface flags */
59 #define IIO_BUSY_BIT_POS 1
61 #ifdef CONFIG_IIO_BUFFER
62 struct poll_table_struct;
64 __poll_t iio_buffer_poll_wrapper(struct file *filp,
65 struct poll_table_struct *wait);
66 ssize_t iio_buffer_read_wrapper(struct file *filp, char __user *buf,
67 size_t n, loff_t *f_ps);
68 ssize_t iio_buffer_write_wrapper(struct file *filp, const char __user *buf,
69 size_t n, loff_t *f_ps);
71 int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev);
72 void iio_buffers_free_sysfs_and_mask(struct iio_dev *indio_dev);
74 #define iio_buffer_poll_addr (&iio_buffer_poll_wrapper)
75 #define iio_buffer_read_outer_addr (&iio_buffer_read_wrapper)
76 #define iio_buffer_write_outer_addr (&iio_buffer_write_wrapper)
78 void iio_disable_all_buffers(struct iio_dev *indio_dev);
79 void iio_buffer_wakeup_poll(struct iio_dev *indio_dev);
80 void iio_device_detach_buffers(struct iio_dev *indio_dev);
84 #define iio_buffer_poll_addr NULL
85 #define iio_buffer_read_outer_addr NULL
86 #define iio_buffer_write_outer_addr NULL
88 static inline int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
93 static inline void iio_buffers_free_sysfs_and_mask(struct iio_dev *indio_dev) {}
95 static inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {}
96 static inline void iio_buffer_wakeup_poll(struct iio_dev *indio_dev) {}
97 static inline void iio_device_detach_buffers(struct iio_dev *indio_dev) {}
101 int iio_device_register_eventset(struct iio_dev *indio_dev);
102 void iio_device_unregister_eventset(struct iio_dev *indio_dev);
103 void iio_device_wakeup_eventset(struct iio_dev *indio_dev);
105 struct iio_event_interface;
106 bool iio_event_enabled(const struct iio_event_interface *ev_int);