#define pr_fmt(fmt) …
#include <linux/cdev.h>
#include <linux/compat.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/i2c-dev.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/notifier.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
struct i2c_dev { … };
#define I2C_MINORS …
static LIST_HEAD(i2c_dev_list);
static DEFINE_SPINLOCK(i2c_dev_list_lock);
static struct i2c_dev *i2c_dev_get_by_minor(unsigned index)
{ … }
static struct i2c_dev *get_free_i2c_dev(struct i2c_adapter *adap)
{ … }
static void put_i2c_dev(struct i2c_dev *i2c_dev, bool del_cdev)
{ … }
static ssize_t name_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(name);
static struct attribute *i2c_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static ssize_t i2cdev_read(struct file *file, char __user *buf, size_t count,
loff_t *offset)
{ … }
static ssize_t i2cdev_write(struct file *file, const char __user *buf,
size_t count, loff_t *offset)
{ … }
static int i2cdev_check(struct device *dev, void *addrp)
{ … }
static int i2cdev_check_mux_parents(struct i2c_adapter *adapter, int addr)
{ … }
static int i2cdev_check_mux_children(struct device *dev, void *addrp)
{ … }
static int i2cdev_check_addr(struct i2c_adapter *adapter, unsigned int addr)
{ … }
static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client,
unsigned nmsgs, struct i2c_msg *msgs)
{ … }
static noinline int i2cdev_ioctl_smbus(struct i2c_client *client,
u8 read_write, u8 command, u32 size,
union i2c_smbus_data __user *data)
{ … }
static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{ … }
#ifdef CONFIG_COMPAT
struct i2c_smbus_ioctl_data32 { … };
struct i2c_msg32 { … };
struct i2c_rdwr_ioctl_data32 { … };
static long compat_i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{ … }
#else
#define compat_i2cdev_ioctl …
#endif
static int i2cdev_open(struct inode *inode, struct file *file)
{ … }
static int i2cdev_release(struct inode *inode, struct file *file)
{ … }
static const struct file_operations i2cdev_fops = …;
static const struct class i2c_dev_class = …;
static void i2cdev_dev_release(struct device *dev)
{ … }
static int i2cdev_attach_adapter(struct device *dev)
{ … }
static int i2cdev_detach_adapter(struct device *dev)
{ … }
static int i2cdev_notifier_call(struct notifier_block *nb, unsigned long action,
void *data)
{ … }
static struct notifier_block i2cdev_notifier = …;
static int __init i2c_dev_attach_adapter(struct device *dev, void *dummy)
{ … }
static int __exit i2c_dev_detach_adapter(struct device *dev, void *dummy)
{ … }
static int __init i2c_dev_init(void)
{ … }
static void __exit i2c_dev_exit(void)
{ … }
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
module_init(…) …;
module_exit(i2c_dev_exit);