// SPDX-License-Identifier: GPL-2.0 /* uio_pci_generic - generic UIO driver for PCI 2.3 devices * * Copyright (C) 2009 Red Hat, Inc. * Author: Michael S. Tsirkin <[email protected]> * * Since the driver does not declare any device ids, you must allocate * id and bind the device to the driver yourself. For example: * * # echo "8086 10f5" > /sys/bus/pci/drivers/uio_pci_generic/new_id * # echo -n 0000:00:19.0 > /sys/bus/pci/drivers/e1000e/unbind * # echo -n 0000:00:19.0 > /sys/bus/pci/drivers/uio_pci_generic/bind * # ls -l /sys/bus/pci/devices/0000:00:19.0/driver * .../0000:00:19.0/driver -> ../../../bus/pci/drivers/uio_pci_generic * * Driver won't bind to devices which do not support the Interrupt Disable Bit * in the command register. All devices compliant to PCI 2.3 (circa 2002) and * all compliant PCI Express devices should support this bit. */ #include <linux/device.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/slab.h> #include <linux/uio_driver.h> #define DRIVER_VERSION … #define DRIVER_AUTHOR … #define DRIVER_DESC … struct uio_pci_generic_dev { … }; static inline struct uio_pci_generic_dev * to_uio_pci_generic_dev(struct uio_info *info) { … } static int release(struct uio_info *info, struct inode *inode) { … } /* Interrupt handler. Read/modify/write the command register to disable * the interrupt. */ static irqreturn_t irqhandler(int irq, struct uio_info *info) { … } static int probe(struct pci_dev *pdev, const struct pci_device_id *id) { … } static struct pci_driver uio_pci_driver = …; module_pci_driver(…) …; MODULE_VERSION(…); MODULE_LICENSE(…) …; MODULE_AUTHOR(…); MODULE_DESCRIPTION(…);