Make change to allow to compile under kernel version > 2.6.36 (tested with a 3.2.9 kernel)
This commit is contained in:
parent
efd39ff55a
commit
789713fa0b
@ -44,6 +44,7 @@
|
|||||||
# define __KFUSD_H__
|
# define __KFUSD_H__
|
||||||
|
|
||||||
# include "fusd_msg.h"
|
# include "fusd_msg.h"
|
||||||
|
# include <linux/version.h>
|
||||||
|
|
||||||
/* magic numbers for structure checking; unique w.r.t
|
/* magic numbers for structure checking; unique w.r.t
|
||||||
* /usr/src/linux/Documentation/magic-number.txt */
|
* /usr/src/linux/Documentation/magic-number.txt */
|
||||||
@ -125,8 +126,11 @@ struct fusd_dev_t_s {
|
|||||||
char *dev_name;
|
char *dev_name;
|
||||||
struct CLASS *clazz;
|
struct CLASS *clazz;
|
||||||
int owns_class;
|
int owns_class;
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
|
||||||
|
struct class_device *device;
|
||||||
|
#else
|
||||||
struct device *device;
|
struct device *device;
|
||||||
|
#endif
|
||||||
void *private_data; /* User's private data */
|
void *private_data; /* User's private data */
|
||||||
struct cdev* handle;
|
struct cdev* handle;
|
||||||
dev_t dev_id;
|
dev_t dev_id;
|
||||||
@ -269,8 +273,11 @@ static void fusd_vfree(void *ptr);
|
|||||||
/* Functions like this should be in the kernel, but they are not. Sigh. */
|
/* Functions like this should be in the kernel, but they are not. Sigh. */
|
||||||
# ifdef CONFIG_SMP
|
# ifdef CONFIG_SMP
|
||||||
|
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
|
||||||
DECLARE_MUTEX(atomic_ops);
|
DECLARE_MUTEX(atomic_ops);
|
||||||
|
#else
|
||||||
|
DEFINE_SEMAPHORE(atomic_ops);
|
||||||
|
#endif
|
||||||
static __inline__ int atomic_inc_and_ret(int *i)
|
static __inline__ int atomic_inc_and_ret(int *i)
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
|
|||||||
100
kfusd/kfusd.c
100
kfusd/kfusd.c
@ -114,37 +114,22 @@
|
|||||||
# define CLASS_DEVICE_DESTROY(a, b) class_simple_device_remove(b)
|
# define CLASS_DEVICE_DESTROY(a, b) class_simple_device_remove(b)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
# define CLASS class
|
# define CLASS class
|
||||||
|
|
||||||
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
|
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
|
||||||
|
# define CLASS_DEVICE_CREATE(a, b, c, d, e) class_device_create(a, c, d, e)
|
||||||
# define CLASS_DEVICE_CREATE(a, b, c, d, e) device_create(a, c, d, e)
|
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
# if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)
|
# if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)
|
||||||
|
|
||||||
# define CLASS_DEVICE_CREATE(a, b, c, d, e) device_create(a, b, c, d, e)
|
# define CLASS_DEVICE_CREATE(a, b, c, d, e) device_create(a, b, c, d, e)
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
# define CLASS_DEVICE_CREATE(a, b, c, d, e) device_create(a, b, c, d, e)
|
# define CLASS_DEVICE_CREATE(a, b, c, d, e) device_create(a, b, c, d, e)
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)
|
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)
|
||||||
|
|
||||||
# define CLASS_DEVICE_DESTROY(a, b) device_destroy(a, b)
|
# define CLASS_DEVICE_DESTROY(a, b) device_destroy(a, b)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
# define CLASS_DEVICE_DESTROY(a, b) device_destroy(a, b)
|
# define CLASS_DEVICE_DESTROY(a, b) device_destroy(a, b)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19)
|
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19)
|
||||||
@ -242,8 +227,14 @@ STATIC dev_t status_id;
|
|||||||
|
|
||||||
static struct CLASS *fusd_class;
|
static struct CLASS *fusd_class;
|
||||||
|
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
|
||||||
|
static struct class_device *fusd_control_device;
|
||||||
|
static struct class_device *fusd_status_device;
|
||||||
|
#else
|
||||||
static struct device *fusd_control_device;
|
static struct device *fusd_control_device;
|
||||||
static struct device *fusd_status_device;
|
static struct device *fusd_status_device;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern struct CLASS *sound_class;
|
extern struct CLASS *sound_class;
|
||||||
|
|
||||||
@ -258,7 +249,11 @@ STATIC DECLARE_WAIT_QUEUE_HEAD (new_device_wait);
|
|||||||
|
|
||||||
/* the list of valid devices, and sem to protect it */
|
/* the list of valid devices, and sem to protect it */
|
||||||
LIST_HEAD (fusd_devlist_head);
|
LIST_HEAD (fusd_devlist_head);
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
|
||||||
DECLARE_MUTEX (fusd_devlist_sem);
|
DECLARE_MUTEX (fusd_devlist_sem);
|
||||||
|
#else
|
||||||
|
DEFINE_SEMAPHORE (fusd_devlist_sem);
|
||||||
|
#endif
|
||||||
|
|
||||||
//#ifdef MODULE_LICENSE
|
//#ifdef MODULE_LICENSE
|
||||||
MODULE_AUTHOR ("Jeremy Elson <jelson@acm.org> (c)2001");
|
MODULE_AUTHOR ("Jeremy Elson <jelson@acm.org> (c)2001");
|
||||||
@ -840,8 +835,10 @@ STATIC int fusd_fops_call_send (fusd_file_t *fusd_file_arg,
|
|||||||
|
|
||||||
/* fill the rest of the structure */
|
/* fill the rest of the structure */
|
||||||
fusd_msg->parm.fops_msg.pid = current->pid;
|
fusd_msg->parm.fops_msg.pid = current->pid;
|
||||||
// fusd_msg->parm.fops_msg.uid = current_uid();
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
|
||||||
// fusd_msg->parm.fops_msg.gid = current_gid();
|
fusd_msg->parm.fops_msg.uid = current_uid();
|
||||||
|
fusd_msg->parm.fops_msg.gid = current_gid();
|
||||||
|
#endif
|
||||||
fusd_msg->parm.fops_msg.flags = fusd_file->file->f_flags;
|
fusd_msg->parm.fops_msg.flags = fusd_file->file->f_flags;
|
||||||
fusd_msg->parm.fops_msg.offset = fusd_file->file->f_pos;
|
fusd_msg->parm.fops_msg.offset = fusd_file->file->f_pos;
|
||||||
fusd_msg->parm.fops_msg.device_info = fusd_dev->private_data;
|
fusd_msg->parm.fops_msg.device_info = fusd_dev->private_data;
|
||||||
@ -1140,8 +1137,13 @@ int fusd_dev_add_file (struct file *file, fusd_dev_t *fusd_dev, fusd_file_t **fu
|
|||||||
init_waitqueue_head(&fusd_file->file_wait);
|
init_waitqueue_head(&fusd_file->file_wait);
|
||||||
init_waitqueue_head(&fusd_file->poll_wait);
|
init_waitqueue_head(&fusd_file->poll_wait);
|
||||||
INIT_LIST_HEAD(&fusd_file->transactions);
|
INIT_LIST_HEAD(&fusd_file->transactions);
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
|
||||||
init_MUTEX(&fusd_file->file_sem);
|
init_MUTEX(&fusd_file->file_sem);
|
||||||
init_MUTEX(&fusd_file->transactions_sem);
|
init_MUTEX(&fusd_file->transactions_sem);
|
||||||
|
#else
|
||||||
|
sema_init(&fusd_file->file_sem, 1);
|
||||||
|
sema_init(&fusd_file->transactions_sem, 1);
|
||||||
|
#endif
|
||||||
fusd_file->last_poll_sent = -1;
|
fusd_file->last_poll_sent = -1;
|
||||||
fusd_file->magic = FUSD_FILE_MAGIC;
|
fusd_file->magic = FUSD_FILE_MAGIC;
|
||||||
fusd_file->fusd_dev = fusd_dev;
|
fusd_file->fusd_dev = fusd_dev;
|
||||||
@ -1589,8 +1591,13 @@ invalid_file:
|
|||||||
return -EPIPE;
|
return -EPIPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_UNLOCKED_IOCTL
|
||||||
STATIC int fusd_client_ioctl (struct inode *inode, struct file *file,
|
STATIC int fusd_client_ioctl (struct inode *inode, struct file *file,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
|
#else
|
||||||
|
STATIC long fusd_client_unlocked_ioctl (struct file *file,
|
||||||
|
unsigned int cmd, unsigned long arg)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fusd_dev_t *fusd_dev;
|
fusd_dev_t *fusd_dev;
|
||||||
fusd_file_t *fusd_file;
|
fusd_file_t *fusd_file;
|
||||||
@ -1937,8 +1944,7 @@ invalid_dev:
|
|||||||
return POLLPRI;
|
return POLLPRI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_UNLOCKED_IOCTL
|
||||||
|
|
||||||
STATIC struct file_operations fusd_client_fops = {
|
STATIC struct file_operations fusd_client_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.open = fusd_client_open,
|
.open = fusd_client_open,
|
||||||
@ -1949,7 +1955,18 @@ STATIC struct file_operations fusd_client_fops = {
|
|||||||
.poll = fusd_client_poll,
|
.poll = fusd_client_poll,
|
||||||
.mmap = fusd_client_mmap
|
.mmap = fusd_client_mmap
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
STATIC struct file_operations fusd_client_fops = {
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
.open = fusd_client_open,
|
||||||
|
.release = fusd_client_release,
|
||||||
|
.read = fusd_client_read,
|
||||||
|
.write = fusd_client_write,
|
||||||
|
.unlocked_ioctl = fusd_client_unlocked_ioctl,
|
||||||
|
.poll = fusd_client_poll,
|
||||||
|
.mmap = fusd_client_mmap
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
@ -2351,7 +2368,11 @@ STATIC int fusd_open (struct inode *inode, struct file *file)
|
|||||||
goto file_malloc_failed;
|
goto file_malloc_failed;
|
||||||
|
|
||||||
init_waitqueue_head(&fusd_dev->dev_wait);
|
init_waitqueue_head(&fusd_dev->dev_wait);
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
|
||||||
init_MUTEX(&fusd_dev->dev_sem);
|
init_MUTEX(&fusd_dev->dev_sem);
|
||||||
|
#else
|
||||||
|
sema_init(&fusd_dev->dev_sem, 1);
|
||||||
|
#endif
|
||||||
fusd_dev->magic = FUSD_DEV_MAGIC;
|
fusd_dev->magic = FUSD_DEV_MAGIC;
|
||||||
fusd_dev->pid = current->pid;
|
fusd_dev->pid = current->pid;
|
||||||
fusd_dev->task = current;
|
fusd_dev->task = current;
|
||||||
@ -2626,8 +2647,13 @@ STATIC ssize_t fusd_writev (struct file *file,
|
|||||||
iov[1].iov_base, iov[1].iov_len);
|
iov[1].iov_base, iov[1].iov_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_UNLOCKED_IOCTL
|
||||||
STATIC int fusd_ioctl (struct inode *inode, struct file *file,
|
STATIC int fusd_ioctl (struct inode *inode, struct file *file,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
|
#else
|
||||||
|
STATIC long fusd_unlocked_ioctl (struct file *file,
|
||||||
|
unsigned int cmd, unsigned long arg)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
void __user *argp = (void __user *) arg;
|
void __user *argp = (void __user *) arg;
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
@ -2839,7 +2865,7 @@ invalid_dev:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_UNLOCKED_IOCTL
|
||||||
STATIC struct file_operations fusd_fops = {
|
STATIC struct file_operations fusd_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.open = fusd_open,
|
.open = fusd_open,
|
||||||
@ -2850,6 +2876,19 @@ STATIC struct file_operations fusd_fops = {
|
|||||||
.release = fusd_release,
|
.release = fusd_release,
|
||||||
.poll = fusd_poll,
|
.poll = fusd_poll,
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
STATIC struct file_operations fusd_fops = {
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
.open = fusd_open,
|
||||||
|
.read = fusd_read,
|
||||||
|
.write = fusd_write,
|
||||||
|
//writev: fusd_writev,
|
||||||
|
.unlocked_ioctl = fusd_unlocked_ioctl,
|
||||||
|
.release = fusd_release,
|
||||||
|
.poll = fusd_poll,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
@ -2904,8 +2943,13 @@ STATIC int fusd_status_release (struct inode *inode, struct file *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ioctl() on /dev/fusd/status */
|
/* ioctl() on /dev/fusd/status */
|
||||||
|
#ifndef HAVE_UNLOCKED_IOCTL
|
||||||
STATIC int fusd_status_ioctl (struct inode *inode, struct file *file,
|
STATIC int fusd_status_ioctl (struct inode *inode, struct file *file,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
|
#else
|
||||||
|
STATIC long fusd_status_unlocked_ioctl (struct file *file,
|
||||||
|
unsigned int cmd, unsigned long arg)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fusd_statcontext_t *fs = (fusd_statcontext_t *) file->private_data;
|
fusd_statcontext_t *fs = (fusd_statcontext_t *) file->private_data;
|
||||||
|
|
||||||
@ -3123,7 +3167,7 @@ STATIC unsigned int fusd_status_poll (struct file *file, poll_table *wait)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_UNLOCKED_IOCTL
|
||||||
STATIC struct file_operations fusd_status_fops = {
|
STATIC struct file_operations fusd_status_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.open = fusd_status_open,
|
.open = fusd_status_open,
|
||||||
@ -3132,6 +3176,16 @@ STATIC struct file_operations fusd_status_fops = {
|
|||||||
.release = fusd_status_release,
|
.release = fusd_status_release,
|
||||||
.poll = fusd_status_poll,
|
.poll = fusd_status_poll,
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
STATIC struct file_operations fusd_status_fops = {
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
.open = fusd_status_open,
|
||||||
|
.unlocked_ioctl = fusd_status_unlocked_ioctl,
|
||||||
|
.read = fusd_status_read,
|
||||||
|
.release = fusd_status_release,
|
||||||
|
.poll = fusd_status_poll,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user