#define pr_fmt(fmt) …
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/sched/signal.h>
#include <linux/fcntl.h>
#include <linux/delay.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/comedi/comedidev.h>
#include <linux/cdev.h>
#include <linux/io.h>
#include <linux/uaccess.h>
#include <linux/compat.h>
#include "comedi_internal.h"
#define COMEDI_SRF_RT …
#define COMEDI_SRF_ERROR …
#define COMEDI_SRF_RUNNING …
#define COMEDI_SRF_FREE_SPRIV …
#define COMEDI_SRF_BUSY_MASK …
struct comedi_file { … };
#define COMEDI_NUM_MINORS …
#define COMEDI_NUM_SUBDEVICE_MINORS …
static unsigned short comedi_num_legacy_minors;
module_param(comedi_num_legacy_minors, ushort, 0444);
MODULE_PARM_DESC(…) …;
unsigned int comedi_default_buf_size_kb = …;
module_param(comedi_default_buf_size_kb, uint, 0644);
MODULE_PARM_DESC(…) …;
unsigned int comedi_default_buf_maxsize_kb = …;
module_param(comedi_default_buf_maxsize_kb, uint, 0644);
MODULE_PARM_DESC(…) …;
static DEFINE_MUTEX(comedi_board_minor_table_lock);
static struct comedi_device
*comedi_board_minor_table[COMEDI_NUM_BOARD_MINORS];
static DEFINE_MUTEX(comedi_subdevice_minor_table_lock);
static struct comedi_subdevice
*comedi_subdevice_minor_table[COMEDI_NUM_SUBDEVICE_MINORS];
static struct cdev comedi_cdev;
static void comedi_device_init(struct comedi_device *dev)
{ … }
static void comedi_dev_kref_release(struct kref *kref)
{ … }
int comedi_dev_put(struct comedi_device *dev)
{ … }
EXPORT_SYMBOL_GPL(…);
static struct comedi_device *comedi_dev_get(struct comedi_device *dev)
{ … }
static void comedi_device_cleanup(struct comedi_device *dev)
{ … }
static bool comedi_clear_board_dev(struct comedi_device *dev)
{ … }
static struct comedi_device *comedi_clear_board_minor(unsigned int minor)
{ … }
static struct comedi_subdevice *
comedi_subdevice_from_minor(const struct comedi_device *dev, unsigned int minor)
{ … }
static struct comedi_device *comedi_dev_get_from_board_minor(unsigned int minor)
{ … }
static struct comedi_device *
comedi_dev_get_from_subdevice_minor(unsigned int minor)
{ … }
struct comedi_device *comedi_dev_get_from_minor(unsigned int minor)
{ … }
EXPORT_SYMBOL_GPL(…);
static struct comedi_subdevice *
comedi_read_subdevice(const struct comedi_device *dev, unsigned int minor)
{ … }
static struct comedi_subdevice *
comedi_write_subdevice(const struct comedi_device *dev, unsigned int minor)
{ … }
static void comedi_file_reset(struct file *file)
{ … }
static void comedi_file_check(struct file *file)
{ … }
static struct comedi_subdevice *comedi_file_read_subdevice(struct file *file)
{ … }
static struct comedi_subdevice *comedi_file_write_subdevice(struct file *file)
{ … }
static int resize_async_buffer(struct comedi_device *dev,
struct comedi_subdevice *s,
unsigned int new_size)
{ … }
static ssize_t max_read_buffer_kb_show(struct device *csdev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t max_read_buffer_kb_store(struct device *csdev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(max_read_buffer_kb);
static ssize_t read_buffer_kb_show(struct device *csdev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t read_buffer_kb_store(struct device *csdev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(read_buffer_kb);
static ssize_t max_write_buffer_kb_show(struct device *csdev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t max_write_buffer_kb_store(struct device *csdev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(max_write_buffer_kb);
static ssize_t write_buffer_kb_show(struct device *csdev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t write_buffer_kb_store(struct device *csdev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(write_buffer_kb);
static struct attribute *comedi_dev_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static const struct class comedi_class = …;
static void comedi_free_board_dev(struct comedi_device *dev)
{ … }
static void __comedi_clear_subdevice_runflags(struct comedi_subdevice *s,
unsigned int bits)
{ … }
static void __comedi_set_subdevice_runflags(struct comedi_subdevice *s,
unsigned int bits)
{ … }
static void comedi_update_subdevice_runflags(struct comedi_subdevice *s,
unsigned int mask,
unsigned int bits)
{ … }
static unsigned int __comedi_get_subdevice_runflags(struct comedi_subdevice *s)
{ … }
static unsigned int comedi_get_subdevice_runflags(struct comedi_subdevice *s)
{ … }
static bool comedi_is_runflags_running(unsigned int runflags)
{ … }
static bool comedi_is_runflags_in_error(unsigned int runflags)
{ … }
bool comedi_is_subdevice_running(struct comedi_subdevice *s)
{ … }
EXPORT_SYMBOL_GPL(…);
static bool __comedi_is_subdevice_running(struct comedi_subdevice *s)
{ … }
bool comedi_can_auto_free_spriv(struct comedi_subdevice *s)
{ … }
void comedi_set_spriv_auto_free(struct comedi_subdevice *s)
{ … }
EXPORT_SYMBOL_GPL(…);
void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size)
{ … }
EXPORT_SYMBOL_GPL(…);
static void do_become_nonbusy(struct comedi_device *dev,
struct comedi_subdevice *s)
{ … }
static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{ … }
void comedi_device_cancel_all(struct comedi_device *dev)
{ … }
static int is_device_busy(struct comedi_device *dev)
{ … }
static int do_devconfig_ioctl(struct comedi_device *dev,
struct comedi_devconfig __user *arg)
{ … }
static int do_bufconfig_ioctl(struct comedi_device *dev,
struct comedi_bufconfig __user *arg)
{ … }
static int do_devinfo_ioctl(struct comedi_device *dev,
struct comedi_devinfo __user *arg,
struct file *file)
{ … }
static int do_subdinfo_ioctl(struct comedi_device *dev,
struct comedi_subdinfo __user *arg, void *file)
{ … }
static int do_chaninfo_ioctl(struct comedi_device *dev,
struct comedi_chaninfo *it)
{ … }
static int do_bufinfo_ioctl(struct comedi_device *dev,
struct comedi_bufinfo __user *arg, void *file)
{ … }
static int check_insn_config_length(struct comedi_insn *insn,
unsigned int *data)
{ … }
static int check_insn_device_config_length(struct comedi_insn *insn,
unsigned int *data)
{ … }
static int get_valid_routes(struct comedi_device *dev, unsigned int *data)
{ … }
static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn,
unsigned int *data, void *file)
{ … }
#define MIN_SAMPLES …
#define MAX_SAMPLES …
static int do_insnlist_ioctl(struct comedi_device *dev,
struct comedi_insn *insns,
unsigned int n_insns,
void *file)
{ … }
static int do_insn_ioctl(struct comedi_device *dev,
struct comedi_insn *insn, void *file)
{ … }
static int __comedi_get_user_cmd(struct comedi_device *dev,
struct comedi_cmd *cmd)
{ … }
static int __comedi_get_user_chanlist(struct comedi_device *dev,
struct comedi_subdevice *s,
unsigned int __user *user_chanlist,
struct comedi_cmd *cmd)
{ … }
static int do_cmd_ioctl(struct comedi_device *dev,
struct comedi_cmd *cmd, bool *copy, void *file)
{ … }
static int do_cmdtest_ioctl(struct comedi_device *dev,
struct comedi_cmd *cmd, bool *copy, void *file)
{ … }
static int do_lock_ioctl(struct comedi_device *dev, unsigned long arg,
void *file)
{ … }
static int do_unlock_ioctl(struct comedi_device *dev, unsigned long arg,
void *file)
{ … }
static int do_cancel_ioctl(struct comedi_device *dev, unsigned long arg,
void *file)
{ … }
static int do_poll_ioctl(struct comedi_device *dev, unsigned long arg,
void *file)
{ … }
static int do_setrsubd_ioctl(struct comedi_device *dev, unsigned long arg,
struct file *file)
{ … }
static int do_setwsubd_ioctl(struct comedi_device *dev, unsigned long arg,
struct file *file)
{ … }
static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{ … }
static void comedi_vm_open(struct vm_area_struct *area)
{ … }
static void comedi_vm_close(struct vm_area_struct *area)
{ … }
static int comedi_vm_access(struct vm_area_struct *vma, unsigned long addr,
void *buf, int len, int write)
{ … }
static const struct vm_operations_struct comedi_vm_ops = …;
static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
{ … }
static __poll_t comedi_poll(struct file *file, poll_table *wait)
{ … }
static ssize_t comedi_write(struct file *file, const char __user *buf,
size_t nbytes, loff_t *offset)
{ … }
static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *offset)
{ … }
static int comedi_open(struct inode *inode, struct file *file)
{ … }
static int comedi_fasync(int fd, struct file *file, int on)
{ … }
static int comedi_close(struct inode *inode, struct file *file)
{ … }
#ifdef CONFIG_COMPAT
#define COMEDI32_CHANINFO …
#define COMEDI32_RANGEINFO …
#define COMEDI32_CMD …
#define COMEDI32_CMDTEST …
#define COMEDI32_INSNLIST …
#define COMEDI32_INSN …
struct comedi32_chaninfo_struct { … };
struct comedi32_rangeinfo_struct { … };
struct comedi32_cmd_struct { … };
struct comedi32_insn_struct { … };
struct comedi32_insnlist_struct { … };
static int compat_chaninfo(struct file *file, unsigned long arg)
{ … }
static int compat_rangeinfo(struct file *file, unsigned long arg)
{ … }
static int get_compat_cmd(struct comedi_cmd *cmd,
struct comedi32_cmd_struct __user *cmd32)
{ … }
static int put_compat_cmd(struct comedi32_cmd_struct __user *cmd32,
struct comedi_cmd *cmd)
{ … }
static int compat_cmd(struct file *file, unsigned long arg)
{ … }
static int compat_cmdtest(struct file *file, unsigned long arg)
{ … }
static int get_compat_insn(struct comedi_insn *insn,
struct comedi32_insn_struct __user *insn32)
{ … }
static int compat_insnlist(struct file *file, unsigned long arg)
{ … }
static int compat_insn(struct file *file, unsigned long arg)
{ … }
static long comedi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{ … }
#else
#define comedi_compat_ioctl …
#endif
static const struct file_operations comedi_fops = …;
void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
{ … }
EXPORT_SYMBOL_GPL(…);
struct comedi_device *comedi_alloc_board_minor(struct device *hardware_device)
{ … }
void comedi_release_hardware_device(struct device *hardware_device)
{ … }
int comedi_alloc_subdevice_minor(struct comedi_subdevice *s)
{ … }
void comedi_free_subdevice_minor(struct comedi_subdevice *s)
{ … }
static void comedi_cleanup_board_minors(void)
{ … }
static int __init comedi_init(void)
{ … }
module_init(…) …;
static void __exit comedi_cleanup(void)
{ … }
module_exit(comedi_cleanup);
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;