brintos

brintos / linux-shallow public Read only

0
0
Text · 3.3 KiB · b7d5f4f Raw
113 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/* The industrial I/O core function defs.3 *4 * Copyright (c) 2008 Jonathan Cameron5 *6 * These definitions are meant for use only within the IIO core, not individual7 * drivers.8 */9 10#ifndef _IIO_CORE_H_11#define _IIO_CORE_H_12#include <linux/kernel.h>13#include <linux/device.h>14 15struct iio_buffer;16struct iio_chan_spec;17struct iio_dev;18 19extern const struct device_type iio_device_type;20 21struct iio_dev_buffer_pair {22	struct iio_dev		*indio_dev;23	struct iio_buffer	*buffer;24};25 26#define IIO_IOCTL_UNHANDLED	127struct 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);31};32 33void iio_device_ioctl_handler_register(struct iio_dev *indio_dev,34				       struct iio_ioctl_handler *h);35void iio_device_ioctl_handler_unregister(struct iio_ioctl_handler *h);36 37ssize_t do_iio_read_channel_label(struct iio_dev *indio_dev,38				  const struct iio_chan_spec *c,39				  char *buf);40 41int __iio_add_chan_devattr(const char *postfix,42			   struct iio_chan_spec const *chan,43			   ssize_t (*func)(struct device *dev,44					   struct device_attribute *attr,45					   char *buf),46			   ssize_t (*writefunc)(struct device *dev,47						struct device_attribute *attr,48						const char *buf,49						size_t len),50			   u64 mask,51			   enum iio_shared_by shared_by,52			   struct device *dev,53			   struct iio_buffer *buffer,54			   struct list_head *attr_list);55void iio_free_chan_devattr_list(struct list_head *attr_list);56 57int iio_device_register_sysfs_group(struct iio_dev *indio_dev,58				    const struct attribute_group *group);59 60ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);61 62/* Event interface flags */63#define IIO_BUSY_BIT_POS 164 65#ifdef CONFIG_IIO_BUFFER66struct poll_table_struct;67 68__poll_t iio_buffer_poll_wrapper(struct file *filp,69				 struct poll_table_struct *wait);70ssize_t iio_buffer_read_wrapper(struct file *filp, char __user *buf,71				size_t n, loff_t *f_ps);72ssize_t iio_buffer_write_wrapper(struct file *filp, const char __user *buf,73				 size_t n, loff_t *f_ps);74 75int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev);76void iio_buffers_free_sysfs_and_mask(struct iio_dev *indio_dev);77 78#define iio_buffer_poll_addr (&iio_buffer_poll_wrapper)79#define iio_buffer_read_outer_addr (&iio_buffer_read_wrapper)80#define iio_buffer_write_outer_addr (&iio_buffer_write_wrapper)81 82void iio_disable_all_buffers(struct iio_dev *indio_dev);83void iio_buffer_wakeup_poll(struct iio_dev *indio_dev);84void iio_device_detach_buffers(struct iio_dev *indio_dev);85 86#else87 88#define iio_buffer_poll_addr NULL89#define iio_buffer_read_outer_addr NULL90#define iio_buffer_write_outer_addr NULL91 92static inline int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev)93{94	return 0;95}96 97static inline void iio_buffers_free_sysfs_and_mask(struct iio_dev *indio_dev) {}98 99static inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {}100static inline void iio_buffer_wakeup_poll(struct iio_dev *indio_dev) {}101static inline void iio_device_detach_buffers(struct iio_dev *indio_dev) {}102 103#endif104 105int iio_device_register_eventset(struct iio_dev *indio_dev);106void iio_device_unregister_eventset(struct iio_dev *indio_dev);107void iio_device_wakeup_eventset(struct iio_dev *indio_dev);108 109struct iio_event_interface;110bool iio_event_enabled(const struct iio_event_interface *ev_int);111 112#endif113