summaryrefslogtreecommitdiffstats
path: root/pci
diff options
context:
space:
mode:
Diffstat (limited to 'pci')
-rw-r--r--pci/Makefile11
-rw-r--r--pci/pci_skel.c63
2 files changed, 74 insertions, 0 deletions
diff --git a/pci/Makefile b/pci/Makefile
new file mode 100644
index 0000000..8b6a333
--- /dev/null
+++ b/pci/Makefile
@@ -0,0 +1,11 @@
+obj-m := pci_skel.o
+
+KERNELDIR ?= /lib/modules/$(shell uname -r)/build
+PWD := $(shell pwd)
+
+all:
+ $(MAKE) -C $(KERNELDIR) M=$(PWD)
+
+clean:
+ rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
+
diff --git a/pci/pci_skel.c b/pci/pci_skel.c
new file mode 100644
index 0000000..f115669
--- /dev/null
+++ b/pci/pci_skel.c
@@ -0,0 +1,63 @@
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+
+
+static struct pci_device_id ids[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_3), },
+ { 0, }
+};
+MODULE_DEVICE_TABLE(pci, ids);
+
+static unsigned char skel_get_revision(struct pci_dev *dev)
+{
+ u8 revision;
+
+ pci_read_config_byte(dev, PCI_REVISION_ID, &revision);
+ return revision;
+}
+
+static int probe(struct pci_dev *dev, const struct pci_device_id *id)
+{
+ /* Do probing type stuff here.
+ * Like calling request_region();
+ */
+ pci_enable_device(dev);
+
+ if (skel_get_revision(dev) == 0x42)
+ return -ENODEV;
+
+
+ return 0;
+}
+
+static void remove(struct pci_dev *dev)
+{
+ /* clean up any allocated resources and stuff here.
+ * like call release_region();
+ */
+}
+
+static struct pci_driver pci_driver = {
+ .name = "pci_skel",
+ .id_table = ids,
+ .probe = probe,
+ .remove = remove,
+};
+
+static int __init pci_skel_init(void)
+{
+ return pci_register_driver(&pci_driver);
+}
+
+static void __exit pci_skel_exit(void)
+{
+ pci_unregister_driver(&pci_driver);
+}
+
+MODULE_LICENSE("GPL");
+
+module_init(pci_skel_init);
+module_exit(pci_skel_exit);