Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* The industrial I/O core function defs.
0003  *
0004  * Copyright (c) 2008 Jonathan Cameron
0005  *
0006  * These definitions are meant for use only within the IIO core, not individual
0007  * drivers.
0008  */
0009 
0010 #ifndef _IIO_CORE_H_
0011 #define _IIO_CORE_H_
0012 #include <linux/kernel.h>
0013 #include <linux/device.h>
0014 
0015 struct iio_buffer;
0016 struct iio_chan_spec;
0017 struct iio_dev;
0018 
0019 extern const struct device_type iio_device_type;
0020 
0021 struct iio_dev_buffer_pair {
0022     struct iio_dev      *indio_dev;
0023     struct iio_buffer   *buffer;
0024 };
0025 
0026 #define IIO_IOCTL_UNHANDLED 1
0027 struct iio_ioctl_handler {
0028     struct list_head entry;
0029     long (*ioctl)(struct iio_dev *indio_dev, struct file *filp,
0030               unsigned int cmd, unsigned long arg);
0031 };
0032 
0033 long iio_device_ioctl(struct iio_dev *indio_dev, struct file *filp,
0034               unsigned int cmd, unsigned long arg);
0035 
0036 void iio_device_ioctl_handler_register(struct iio_dev *indio_dev,
0037                        struct iio_ioctl_handler *h);
0038 void iio_device_ioctl_handler_unregister(struct iio_ioctl_handler *h);
0039 
0040 int __iio_add_chan_devattr(const char *postfix,
0041                struct iio_chan_spec const *chan,
0042                ssize_t (*func)(struct device *dev,
0043                        struct device_attribute *attr,
0044                        char *buf),
0045                ssize_t (*writefunc)(struct device *dev,
0046                         struct device_attribute *attr,
0047                         const char *buf,
0048                         size_t len),
0049                u64 mask,
0050                enum iio_shared_by shared_by,
0051                struct device *dev,
0052                struct iio_buffer *buffer,
0053                struct list_head *attr_list);
0054 void iio_free_chan_devattr_list(struct list_head *attr_list);
0055 
0056 int iio_device_register_sysfs_group(struct iio_dev *indio_dev,
0057                     const struct attribute_group *group);
0058 
0059 ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);
0060 
0061 /* Event interface flags */
0062 #define IIO_BUSY_BIT_POS 1
0063 
0064 #ifdef CONFIG_IIO_BUFFER
0065 struct poll_table_struct;
0066 
0067 __poll_t iio_buffer_poll_wrapper(struct file *filp,
0068                  struct poll_table_struct *wait);
0069 ssize_t iio_buffer_read_wrapper(struct file *filp, char __user *buf,
0070                 size_t n, loff_t *f_ps);
0071 ssize_t iio_buffer_write_wrapper(struct file *filp, const char __user *buf,
0072                  size_t n, loff_t *f_ps);
0073 
0074 int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev);
0075 void iio_buffers_free_sysfs_and_mask(struct iio_dev *indio_dev);
0076 
0077 #define iio_buffer_poll_addr (&iio_buffer_poll_wrapper)
0078 #define iio_buffer_read_outer_addr (&iio_buffer_read_wrapper)
0079 #define iio_buffer_write_outer_addr (&iio_buffer_write_wrapper)
0080 
0081 void iio_disable_all_buffers(struct iio_dev *indio_dev);
0082 void iio_buffer_wakeup_poll(struct iio_dev *indio_dev);
0083 void iio_device_detach_buffers(struct iio_dev *indio_dev);
0084 
0085 #else
0086 
0087 #define iio_buffer_poll_addr NULL
0088 #define iio_buffer_read_outer_addr NULL
0089 #define iio_buffer_write_outer_addr NULL
0090 
0091 static inline int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
0092 {
0093     return 0;
0094 }
0095 
0096 static inline void iio_buffers_free_sysfs_and_mask(struct iio_dev *indio_dev) {}
0097 
0098 static inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {}
0099 static inline void iio_buffer_wakeup_poll(struct iio_dev *indio_dev) {}
0100 static inline void iio_device_detach_buffers(struct iio_dev *indio_dev) {}
0101 
0102 #endif
0103 
0104 int iio_device_register_eventset(struct iio_dev *indio_dev);
0105 void iio_device_unregister_eventset(struct iio_dev *indio_dev);
0106 void iio_device_wakeup_eventset(struct iio_dev *indio_dev);
0107 
0108 struct iio_event_interface;
0109 bool iio_event_enabled(const struct iio_event_interface *ev_int);
0110 
0111 #endif