cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

iio_core.h (3427B)


      1/* SPDX-License-Identifier: GPL-2.0-only */
      2/* The industrial I/O core function defs.
      3 *
      4 * Copyright (c) 2008 Jonathan Cameron
      5 *
      6 * These definitions are meant for use only within the IIO core, not individual
      7 * 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	1
     27struct 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
     33long iio_device_ioctl(struct iio_dev *indio_dev, struct file *filp,
     34		      unsigned int cmd, unsigned long arg);
     35
     36void iio_device_ioctl_handler_register(struct iio_dev *indio_dev,
     37				       struct iio_ioctl_handler *h);
     38void iio_device_ioctl_handler_unregister(struct iio_ioctl_handler *h);
     39
     40int __iio_add_chan_devattr(const char *postfix,
     41			   struct iio_chan_spec const *chan,
     42			   ssize_t (*func)(struct device *dev,
     43					   struct device_attribute *attr,
     44					   char *buf),
     45			   ssize_t (*writefunc)(struct device *dev,
     46						struct device_attribute *attr,
     47						const char *buf,
     48						size_t len),
     49			   u64 mask,
     50			   enum iio_shared_by shared_by,
     51			   struct device *dev,
     52			   struct iio_buffer *buffer,
     53			   struct list_head *attr_list);
     54void iio_free_chan_devattr_list(struct list_head *attr_list);
     55
     56int iio_device_register_sysfs_group(struct iio_dev *indio_dev,
     57				    const struct attribute_group *group);
     58
     59ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);
     60
     61/* Event interface flags */
     62#define IIO_BUSY_BIT_POS 1
     63
     64#ifdef CONFIG_IIO_BUFFER
     65struct poll_table_struct;
     66
     67__poll_t iio_buffer_poll_wrapper(struct file *filp,
     68				 struct poll_table_struct *wait);
     69ssize_t iio_buffer_read_wrapper(struct file *filp, char __user *buf,
     70				size_t n, loff_t *f_ps);
     71ssize_t iio_buffer_write_wrapper(struct file *filp, const char __user *buf,
     72				 size_t n, loff_t *f_ps);
     73
     74int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev);
     75void iio_buffers_free_sysfs_and_mask(struct iio_dev *indio_dev);
     76
     77#define iio_buffer_poll_addr (&iio_buffer_poll_wrapper)
     78#define iio_buffer_read_outer_addr (&iio_buffer_read_wrapper)
     79#define iio_buffer_write_outer_addr (&iio_buffer_write_wrapper)
     80
     81void iio_disable_all_buffers(struct iio_dev *indio_dev);
     82void iio_buffer_wakeup_poll(struct iio_dev *indio_dev);
     83void iio_device_detach_buffers(struct iio_dev *indio_dev);
     84
     85#else
     86
     87#define iio_buffer_poll_addr NULL
     88#define iio_buffer_read_outer_addr NULL
     89#define iio_buffer_write_outer_addr NULL
     90
     91static inline int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
     92{
     93	return 0;
     94}
     95
     96static inline void iio_buffers_free_sysfs_and_mask(struct iio_dev *indio_dev) {}
     97
     98static inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {}
     99static inline void iio_buffer_wakeup_poll(struct iio_dev *indio_dev) {}
    100static inline void iio_device_detach_buffers(struct iio_dev *indio_dev) {}
    101
    102#endif
    103
    104int iio_device_register_eventset(struct iio_dev *indio_dev);
    105void iio_device_unregister_eventset(struct iio_dev *indio_dev);
    106void iio_device_wakeup_eventset(struct iio_dev *indio_dev);
    107
    108struct iio_event_interface;
    109bool iio_event_enabled(const struct iio_event_interface *ev_int);
    110
    111#endif