#include <linux/init.h>
#include <linux/ioctl.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/list.h>
#include <linux/errno.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/property.h>
#include <linux/slab.h>
#include <linux/compat.h>
#include <linux/spi/spi.h>
#include <linux/spi/spidev.h>
#include <linux/uaccess.h>
#define SPIDEV_MAJOR …
#define N_SPI_MINORS …
static DECLARE_BITMAP(minors, N_SPI_MINORS);
static_assert(…);
#define SPI_MODE_MASK …
struct spidev_data { … };
static LIST_HEAD(device_list);
static DEFINE_MUTEX(device_list_lock);
static unsigned bufsiz = …;
module_param(bufsiz, uint, S_IRUGO);
MODULE_PARM_DESC(…) …;
static ssize_t
spidev_sync_unlocked(struct spi_device *spi, struct spi_message *message)
{ … }
static ssize_t
spidev_sync(struct spidev_data *spidev, struct spi_message *message)
{ … }
static inline ssize_t
spidev_sync_write(struct spidev_data *spidev, size_t len)
{ … }
static inline ssize_t
spidev_sync_read(struct spidev_data *spidev, size_t len)
{ … }
static ssize_t
spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
{ … }
static ssize_t
spidev_write(struct file *filp, const char __user *buf,
size_t count, loff_t *f_pos)
{ … }
static int spidev_message(struct spidev_data *spidev,
struct spi_ioc_transfer *u_xfers, unsigned n_xfers)
{ … }
static struct spi_ioc_transfer *
spidev_get_ioc_message(unsigned int cmd, struct spi_ioc_transfer __user *u_ioc,
unsigned *n_ioc)
{ … }
static long
spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{ … }
#ifdef CONFIG_COMPAT
static long
spidev_compat_ioc_message(struct file *filp, unsigned int cmd,
unsigned long arg)
{ … }
static long
spidev_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{ … }
#else
#define spidev_compat_ioctl …
#endif
static int spidev_open(struct inode *inode, struct file *filp)
{ … }
static int spidev_release(struct inode *inode, struct file *filp)
{ … }
static const struct file_operations spidev_fops = …;
static const struct class spidev_class = …;
static const struct spi_device_id spidev_spi_ids[] = …;
MODULE_DEVICE_TABLE(spi, spidev_spi_ids);
static int spidev_of_check(struct device *dev)
{ … }
static const struct of_device_id spidev_dt_ids[] = …;
MODULE_DEVICE_TABLE(of, spidev_dt_ids);
static int spidev_acpi_check(struct device *dev)
{ … }
static const struct acpi_device_id spidev_acpi_ids[] = …;
MODULE_DEVICE_TABLE(acpi, spidev_acpi_ids);
static int spidev_probe(struct spi_device *spi)
{ … }
static void spidev_remove(struct spi_device *spi)
{ … }
static struct spi_driver spidev_spi_driver = …;
static int __init spidev_init(void)
{ … }
module_init(…) …;
static void __exit spidev_exit(void)
{ … }
module_exit(spidev_exit);
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_ALIAS(…) …;