Fixes for compilation against recent kernels; disable helper module, change configuration file loading...

This commit is contained in:
Ryan McGrath 2011-02-24 00:31:25 -08:00
parent 00bae13bba
commit ed9bb8f71a
15 changed files with 206 additions and 73 deletions

View file

@ -25,7 +25,7 @@ else
endif
CLASS_SIMPLE := $(shell grep class_simple_create $(KDIR)/include/linux/device.h)
CLASS_SIMPLE := $(shell grep -s class_simple_create $(KDIR)/include/linux/device.h)
ifneq ($(CLASS_SIMPLE),)
CLASS_CFLAGS = -DCLASS_SIMPLE=1
@ -49,18 +49,9 @@ clean:
svgalib_helper.o: $(svgalib_helper-objs)
$(LD) -r -o $@ $(svgalib_helper-objs)
device:
rm -f /dev/svga /dev/svga?
mknod -m 666 /dev/svga c $(SVGALIB_HELPER_MAJOR) 0
mknod -m 666 /dev/svga1 c $(SVGALIB_HELPER_MAJOR) 1
mknod -m 666 /dev/svga2 c $(SVGALIB_HELPER_MAJOR) 2
mknod -m 666 /dev/svga3 c $(SVGALIB_HELPER_MAJOR) 3
mknod -m 666 /dev/svga4 c $(SVGALIB_HELPER_MAJOR) 4
install: device modules_install
install: modules_install
modules_install: $(MODNAME)
mkdir -p /lib/modules/$(VER)/kernel/misc
install -m 0644 -c $(TARGET).ko /lib/modules/$(VER)/kernel/misc || install -m 0644 -c $(TARGET).o /lib/modules/$(VER)/kernel/misc
depmod -a $(VER)
mkdir -p $(TOPDIR)/lib/modules/$(VER)/kernel/misc
install -m 0644 -c $(TARGET).ko $(TOPDIR)/lib/modules/$(VER)/kernel/misc || install -m 0644 -c $(TARGET).o $(TOPDIR)/lib/modules/$(VER)/kernel/misc

View file

@ -37,7 +37,7 @@ CFLAGS += $(INCLUDES)
CFLAGS += -DSVGALIB_HELPER_MAJOR=$(SVGALIB_HELPER_MAJOR)
ifeq (1,$(findstring 1,$(MODVER)))
CFLAGS += -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h
CFLAGS += -DMODVERSIONS -DCONFIG_MODVERSIONS=1
endif
TARGET = svgalib_helper
@ -50,7 +50,8 @@ ifeq (2,$(VER_MAJOR))
endif
endif
all: .depend $(OBJS)
modules: $(OBJS)
all: .depend modules
$(TARGET).o: $(SRC:.c=.o)
$(LD) -r $^ -o $@
@ -61,8 +62,8 @@ $(TARGET).ko: $(TARGET).o
install: device modules_install
modules_install: $(OBJS)
mkdir -p /lib/modules/$(VER)/kernel/misc
install -m 0644 -c $(OBJS) /lib/modules/$(VER)/kernel/misc
mkdir -p $(TOPDIR)/lib/modules/$(VER)/kernel/misc
install -m 0644 -c $(OBJS) $(TOPDIR)/lib/modules/$(VER)/kernel/misc
device:
rm -f /dev/svgalib_helper* /dev/svga_helper* /dev/svga /dev/svga?

View file

@ -10,7 +10,7 @@
# define PCI_GET_CLASS pci_find_class
# define PCI_GET_DEVICE pci_find_device
# if defined (PG_chainlock)
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,3)
# define my_io_remap_page_range(vma, start, ofs, len, prot) \
io_remap_page_range(vma,start,ofs,len,prot)
# else
@ -70,6 +70,7 @@ typedef void* devfs_handle_t;
/* These are also not present in 2.6 kernels ... */
#if (!defined _LINUX_DEVFS_FS_KERNEL_H) || (defined KERNEL_2_6)
#include <linux/fs.h>
static inline int devfs_register_chrdev (unsigned int major, const char *name,
struct file_operations *fops)
{
@ -77,7 +78,12 @@ static inline int devfs_register_chrdev (unsigned int major, const char *name,
}
static inline int devfs_unregister_chrdev (unsigned int major,const char *name)
{
return unregister_chrdev (major, name);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
return unregister_chrdev (major, name);
#else
unregister_chrdev (major, name);
return 0;
#endif
}
#endif
@ -99,7 +105,8 @@ static inline int devfs_unregister_chrdev (unsigned int major,const char *name)
class_device_create(svgalib_helper_class, \
MKDEV(SVGALIB_HELPER_MAJOR, _minor), \
&sh_pci_devs[_minor]->dev->dev, _name);
#else /* 2.6.15 changed class_device_create */
/* 2.6.15 changed class_device_create */
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
# define SLH_SYSFS_ADD_CONTROL \
class_device_create(svgalib_helper_class, NULL, \
MKDEV(SVGALIB_HELPER_MAJOR, 0), \
@ -109,7 +116,42 @@ static inline int devfs_unregister_chrdev (unsigned int major,const char *name)
class_device_create(svgalib_helper_class, NULL, \
MKDEV(SVGALIB_HELPER_MAJOR, _minor), \
&sh_pci_devs[_minor]->dev->dev, _name);
#endif /* 2.6.15 */
/* 2.6.26 changed class_device_create to device_create */
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
# define SLH_SYSFS_ADD_CONTROL \
device_create(svgalib_helper_class, NULL, \
MKDEV(SVGALIB_HELPER_MAJOR, 0), \
"svga");
# define SLH_SYSFS_ADD_DEVICE(_name, _minor) \
device_create(svgalib_helper_class, &sh_pci_devs[_minor]->dev->dev, \
MKDEV(SVGALIB_HELPER_MAJOR, _minor), \
_name);
/* 2.6.27 changed device_create to device_create_drvdata */
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
# define SLH_SYSFS_ADD_CONTROL \
device_create_drvdata(svgalib_helper_class, NULL, \
MKDEV(SVGALIB_HELPER_MAJOR, 0), \
"%s%d", "svga", 0);
# define SLH_SYSFS_ADD_DEVICE(_name, _minor) \
device_create_drvdata(svgalib_helper_class, \
&sh_pci_devs[_minor]->dev->dev, \
MKDEV(SVGALIB_HELPER_MAJOR, _minor), \
"%s%d", _name, _minor);
/* 2.6.28 changed device_create_drvdata back to device_create */
#else
# define SLH_SYSFS_ADD_CONTROL \
device_create(svgalib_helper_class, NULL, \
MKDEV(SVGALIB_HELPER_MAJOR, 0), NULL, \
"%s%d", "svga", 0);
# define SLH_SYSFS_ADD_DEVICE(_name, _minor) \
device_create(svgalib_helper_class, \
&sh_pci_devs[_minor]->dev->dev, \
MKDEV(SVGALIB_HELPER_MAJOR, _minor), NULL, \
"%s%d", _name, _minor);
#endif
# define SLH_SYSFS_REMOVE_DEVICE(i) \
class_destroy(svgalib_helper_class);
@ -161,3 +203,7 @@ static inline int devfs_unregister_chrdev (unsigned int major,const char *name)
#ifndef PCI_VENDOR_ID_RENDITION
#define PCI_VENDOR_ID_RENDITION 0x1163
#endif
#ifndef IRQF_SHARED
# define IRQF_SHARED SA_SHIRQ
#endif

View file

@ -1,5 +1,3 @@
#include <linux/config.h>
#if defined (CONFIG_MODVERSIONS) && !defined (MODVERSIONS)
# define MODVERSIONS
#endif
@ -17,15 +15,22 @@
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
#include <linux/devfs_fs_kernel.h>
#endif
#include <linux/mm.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
#include <linux/thread_info.h>
#endif
#include <linux/smp.h>
#include <linux/smp_lock.h>
#include <linux/sched.h>
#include <linux/wait.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
#include <linux/syscalls.h>
#endif
#define __KERNEL_SYSCALLS__
#include <linux/unistd.h>
@ -50,7 +55,7 @@ asmlinkage long (*s_ioperm)(unsigned long from, unsigned long num, int turn_on);
#include "displaystart.h"
int debug=0;
static int all_devices=0;
int all_devices=0;
int num_devices=0;
static char *sdev_id="svgalib_helper";
@ -98,7 +103,11 @@ static int get_dev(int pcipos, int minor) {
static volatile int vsync=0;
static wait_queue_head_t vsync_wait;
static irqreturn_t vsync_interrupt(int irq, void *dev_id, struct pt_regs *regs)
static irqreturn_t vsync_interrupt(int irq, void *dev_id
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
, struct pt_regs *regs
#endif
)
{
struct sh_pci_device *dev = (struct sh_pci_device *)dev_id;
@ -153,9 +162,15 @@ static void task_startad(void *data) {
get_user(pciv.address, &user_pciv->address); \
get_user(pciv.val, &user_pciv->val);
#define PUT_PCIV \
put_user(pciv.val, &user_pciv->val);
put_user(pciv.val, &user_pciv->val);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
static int svgalib_helper_ioctl( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg) {
#else
static int svgalib_helper_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg) {
struct inode *inode=filp->f_dentry->d_inode;
#endif
io_t iov, *user_iov=(io_t *)arg;
pcic_t pciv, *user_pciv=(pcic_t *)arg;
@ -355,7 +370,7 @@ static int svgalib_helper_ioctl( struct inode *inode, struct file *filp,
vsync=1;
i=0;
while(irqs[i]!=-1)
request_irq(irqs[i++], vsync_interrupt, SA_SHIRQ, "svgalib_helper", sdev_id);
request_irq(irqs[i++], vsync_interrupt, IRQF_SHARED, "svgalib_helper", sdev_id);
vga_enable_vsync((void *)sdev_id);
wait_event_interruptible(vsync_wait, !vsync);
i=0;
@ -443,7 +458,7 @@ static int svgalib_helper_open( struct inode *inode, struct file * filp) {
int i=sh_pci_devs[minor]->dev->irq;
sh_pci_devs[minor]->opencount++;
if(sh_pci_devs[minor]->opencount==1 && i!=0 && i!=-1 && i!=255)
request_irq(i, vsync_interrupt, SA_SHIRQ, "svgalib_helper", sh_pci_devs[minor]);
request_irq(i, vsync_interrupt, IRQF_SHARED, "svgalib_helper", sh_pci_devs[minor]);
}
#ifndef KERNEL_2_6
@ -586,7 +601,11 @@ struct file_operations svgalib_helper_fops = {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
.owner = THIS_MODULE,
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
.ioctl = svgalib_helper_ioctl,
#else
.unlocked_ioctl = svgalib_helper_ioctl,
#endif
.mmap = svgalib_helper_mmap,
.open = svgalib_helper_open,
.release = svgalib_helper_release,
@ -763,10 +782,15 @@ void cleanup_module(void)
}
#ifdef KERNEL_2_6
module_param(debug, int, 0);
module_param(all_devices, int, 0);
#else
MODULE_PARM(debug, "i");
MODULE_PARM_DESC(debug, "Debug output level.");
MODULE_PARM(all_devices, "i");
#endif
MODULE_PARM_DESC(debug, "Debug output level.");
MODULE_PARM_DESC(all_devices, "Give access to all PCI devices, regardless of class.");