fix 2.6.24 device creation (and hopefully later kernels)
This commit is contained in:
@@ -71,30 +71,33 @@
|
||||
#include <linux/mm.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/pci.h>
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,46) && \
|
||||
LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,17) || \
|
||||
defined(DEVFS_SUPPORT)
|
||||
#include <linux/devfs_fs_kernel.h>
|
||||
#define HAVE_DEVFS 1
|
||||
#include <linux/devfs_fs_kernel.h>
|
||||
#define HAVE_DEVFS 1
|
||||
#else
|
||||
#define HAVE_DEVFS 0
|
||||
#define HAVE_DEVFS 0
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
|
||||
#include <linux/device.h>
|
||||
#include <linux/err.h>
|
||||
#define HAVE_CLASS_DEVICE 1
|
||||
#include <linux/device.h>
|
||||
#include <linux/err.h>
|
||||
#define HAVE_CLASS_DEVICE 1
|
||||
#else
|
||||
#define HAVE_CLASS_DEVICE 0
|
||||
#define HAVE_CLASS_DEVICE 0
|
||||
#endif
|
||||
|
||||
#include <asm/segment.h>
|
||||
#include <asm/ioctl.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include <asm/processor.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
#ifdef CONFIG_MTRR
|
||||
#include <asm/mtrr.h>
|
||||
#include <asm/mtrr.h>
|
||||
#endif
|
||||
|
||||
#define MAJOR_3DFX 107
|
||||
@@ -119,44 +122,44 @@
|
||||
#define SC_DATA 0x3c5
|
||||
|
||||
#ifndef PCI_VENDOR_ID_3DFX
|
||||
#define PCI_VENDOR_ID_3DFX 0x121a
|
||||
#define PCI_VENDOR_ID_3DFX 0x121a
|
||||
#endif
|
||||
|
||||
#ifndef PCI_VENDOR_ID_ALLIANCE
|
||||
#define PCI_VENDOR_ID_ALLIANCE 0x1142
|
||||
#define PCI_VENDOR_ID_ALLIANCE 0x1142
|
||||
#endif
|
||||
|
||||
#ifndef PCI_VENDOR_ID_MACRONIX
|
||||
#define PCI_VENDOR_ID_MACRONIX 0x10d9
|
||||
#define PCI_VENDOR_ID_MACRONIX 0x10d9
|
||||
#endif
|
||||
|
||||
#ifndef PCI_DEVICE_ID_3DFX_VOODOO2
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO2 2
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO2 2
|
||||
#endif
|
||||
|
||||
#ifndef PCI_DEVICE_ID_ALLIANCE_AT3D
|
||||
#define PCI_DEVICE_ID_ALLIANCE_AT3D 0x643d
|
||||
#define PCI_DEVICE_ID_ALLIANCE_AT3D 0x643d
|
||||
#endif
|
||||
|
||||
#ifndef PCI_DEVICE_ID_MACRONIX_MX86251
|
||||
#define PCI_DEVICE_ID_MACRONIX_MX86251 0x8626
|
||||
#define PCI_DEVICE_ID_MACRONIX_MX86251 0x8626
|
||||
#endif
|
||||
|
||||
#ifndef PCI_DEVICE_ID_3DFX_BANSHEE
|
||||
#define PCI_DEVICE_ID_3DFX_BANSHEE 3
|
||||
#define PCI_DEVICE_ID_3DFX_BANSHEE 3
|
||||
#endif
|
||||
|
||||
#ifndef PCI_DEVICE_ID_3DFX_VOODOO3
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO3 5
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO3 5
|
||||
#endif
|
||||
|
||||
#ifndef PCI_DEVICE_ID_3DFX_VOODOO4
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO4 9
|
||||
#define PCI_DEVICE_ID_3DFX_VOODOO4 9
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,73)
|
||||
#define pci_get_device pci_find_device
|
||||
#define pci_dev_put(dev)
|
||||
#define pci_get_device pci_find_device
|
||||
#define pci_dev_put(dev)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
|
||||
@@ -205,22 +208,22 @@ static struct pci_card {
|
||||
* on kernel version.
|
||||
*/
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,14)
|
||||
#define VM_OFFSET(vma) (vma->vm_offset)
|
||||
#define VM_OFFSET_ALIGNED(vma) ((vma->vm_offset) & ~PAGE_MASK)
|
||||
#define VM_OFFSET(vma) (vma->vm_offset)
|
||||
#define VM_OFFSET_ALIGNED(vma) ((vma->vm_offset) & ~PAGE_MASK)
|
||||
#else
|
||||
#define VM_OFFSET(vma) (vma->vm_pgoff << PAGE_SHIFT)
|
||||
#define VM_OFFSET_ALIGNED(vma) ((vma->vm_pgoff) & ~PAGE_MASK)
|
||||
#define VM_OFFSET(vma) (vma->vm_pgoff << PAGE_SHIFT)
|
||||
#define VM_OFFSET_ALIGNED(vma) ((vma->vm_pgoff) & ~PAGE_MASK)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
|
||||
#define my_remap_page_range(vma, start, ofs, len, prot) \
|
||||
remap_pfn_range(vma, start, ofs >> PAGE_SHIFT, len, prot)
|
||||
#define my_remap_page_range(vma, start, ofs, len, prot) \
|
||||
remap_pfn_range(vma, start, ofs >> PAGE_SHIFT, len, prot)
|
||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
|
||||
#define my_remap_page_range(vma, start, ofs, len, prot) \
|
||||
remap_page_range(vma, start, ofs, len, prot)
|
||||
#define my_remap_page_range(vma, start, ofs, len, prot) \
|
||||
remap_page_range(vma, start, ofs, len, prot)
|
||||
#else
|
||||
#define my_remap_page_range(vma, start, ofs, len, prot) \
|
||||
remap_page_range(start, ofs, len, prot)
|
||||
#define my_remap_page_range(vma, start, ofs, len, prot) \
|
||||
remap_page_range(start, ofs, len, prot)
|
||||
#endif
|
||||
|
||||
struct pioData_t {
|
||||
@@ -313,7 +316,8 @@ static struct pci_driver driver_3dfx;
|
||||
static int findCards(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
|
||||
numCards = 0;
|
||||
error = pci_register_driver(&driver_3dfx);
|
||||
|
||||
if (error)
|
||||
@@ -810,6 +814,11 @@ static struct file_operations fops_3dfx = {
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
|
||||
static int probe_3dfx(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
{
|
||||
if (numCards >= MAXCARDS) {
|
||||
printk("3dfx: too many cards, MAXCARDS=%d\n", MAXCARDS);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &cards[numCards].addr0);
|
||||
pci_read_config_dword(dev, PCI_BASE_ADDRESS_1, &cards[numCards].addr1);
|
||||
pci_read_config_dword(dev, PCI_BASE_ADDRESS_2, &cards[numCards].addr2);
|
||||
@@ -854,10 +863,16 @@ static int create_device_3dfx(void)
|
||||
printk("3dfx: class_create() failed, returned %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
|
||||
device_3dfx = device_create(class_3dfx, NULL,
|
||||
MKDEV(MAJOR_3DFX, DEVICE_VOODOO),
|
||||
NULL, "3dfx");
|
||||
#else
|
||||
device_3dfx = device_create(class_3dfx, NULL,
|
||||
MKDEV(MAJOR_3DFX, DEVICE_VOODOO),
|
||||
"3dfx");
|
||||
#endif
|
||||
|
||||
if (IS_ERR(device_3dfx)) {
|
||||
int ret = PTR_ERR(device_3dfx);
|
||||
device_3dfx = NULL;
|
||||
@@ -888,9 +903,18 @@ int init_module(void)
|
||||
int ret;
|
||||
|
||||
DEBUGMSG(("3dfx: Entering init_module()\n"));
|
||||
|
||||
ret = findCards();
|
||||
if (ret < 0) {
|
||||
printk("3dfx: findCards() failed, returned %d\n", ret);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if ((ret = register_chrdev(MAJOR_3DFX, "3dfx", &fops_3dfx)) < 0) {
|
||||
printk("3dfx: Unable to register character device with major %d\n", MAJOR_3DFX);
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
|
||||
pci_unregister_driver(&driver_3dfx);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -910,29 +934,17 @@ int init_module(void)
|
||||
ret = create_device_3dfx();
|
||||
if (ret < 0) {
|
||||
unregister_chrdev(MAJOR_3DFX, "3dfx");
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
|
||||
pci_unregister_driver(&driver_3dfx);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
DEBUGMSG(("3dfx: Successfully registered device 3dfx\n"));
|
||||
ret = findCards();
|
||||
if (ret < 0) {
|
||||
printk("3dfx: findCards() failed, returned %d\n", ret);
|
||||
#if HAVE_CLASS_DEVICE
|
||||
destroy_device_3dfx();
|
||||
#endif
|
||||
unregister_chrdev(MAJOR_3DFX, "3dfx");
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MTRR
|
||||
ret = setmtrr_3dfx();
|
||||
if (ret < 0) {
|
||||
DEBUGMSG(("setmtrr_3dfx() failed, returned %d\n", ret));
|
||||
/*
|
||||
unregister_chrdev(MAJOR_3DFX, "3dfx");
|
||||
return ret;
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -968,16 +980,17 @@ long init_3dfx(long mem_start, long mem_end)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (register_chrdev(MAJOR_3DFX, "3dfx", &fops_3dfx)) {
|
||||
DEBUGMSG(("3dfx: Unable to register_chrdev with major %d\n", MAJOR_3DFX));
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = findCards();
|
||||
if (ret < 0) {
|
||||
printk("3dfx: findCards() failed, returned %d\n", ret);
|
||||
return 0;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (ret=register_chrdev(MAJOR_3DFX, "3dfx", &fops_3dfx)) {
|
||||
DEBUGMSG(("3dfx: Unable to register_chrdev with major %d\n", MAJOR_3DFX));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
return mem_start;
|
||||
}
|
||||
@@ -988,7 +1001,7 @@ MODULE_AUTHOR("Daryll Strauss et al.");
|
||||
MODULE_DESCRIPTION("3dfx glide kernel device driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
#ifdef MODULE_VERSION
|
||||
MODULE_VERSION("2011.05.27");
|
||||
MODULE_VERSION("2026.03.24");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user