diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2000-07-15 03:32:22 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2000-07-15 03:32:22 +0000 |
commit | f1da2c3860e301527d56a1ef0b56c649ee7c4b1b (patch) | |
tree | 562b5d2e8b9cb62eb983d78ff6bcf9789e08fcf6 /drivers/char/ftape/zftape | |
parent | 00f11569ac8ca73cbcdef8822de1583e79aee571 (diff) |
Merge with Linux 2.4.0-test5-pre1. This works again on Origin UP.
The IP22 cache bugs which are plaguing some machines are still unfixed.
Diffstat (limited to 'drivers/char/ftape/zftape')
-rw-r--r-- | drivers/char/ftape/zftape/zftape-init.c | 106 |
1 files changed, 8 insertions, 98 deletions
diff --git a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c index fd81f24ca..a57e3abc1 100644 --- a/drivers/char/ftape/zftape/zftape-init.c +++ b/drivers/char/ftape/zftape/zftape-init.c @@ -35,15 +35,11 @@ #endif #include <linux/fcntl.h> #include <linux/wrapper.h> +#include <linux/smp_lock.h> #include <linux/devfs_fs_kernel.h> #include <linux/zftape.h> -#if LINUX_VERSION_CODE >=KERNEL_VER(2,1,16) #include <linux/init.h> -#else -#define __initdata -#define __initfunc(__arg) __arg -#endif #include "../zftape/zftape-init.h" #include "../zftape/zftape-read.h" @@ -56,7 +52,6 @@ char zft_src[] __initdata = "$Source: /homes/cvs/ftape-stacked/ftape/zftape/zfta char zft_rev[] __initdata = "$Revision: 1.8 $"; char zft_dat[] __initdata = "$Date: 1997/11/06 00:48:56 $"; -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,18) MODULE_AUTHOR("(c) 1996, 1997 Claus-Justus Heine " "(claus@momo.math.rwth-aachen.de)"); MODULE_DESCRIPTION(ZFTAPE_VERSION " - " @@ -64,7 +59,6 @@ MODULE_DESCRIPTION(ZFTAPE_VERSION " - " "Support for QIC-113 compatible volume table " "and builtin compression (lzrw3 algorithm)"); MODULE_SUPPORTED_DEVICE("char-major-27"); -#endif /* Global vars. */ @@ -90,38 +84,18 @@ static sigset_t orig_sigmask; */ static int zft_open (struct inode *ino, struct file *filep); -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,31) static int zft_close(struct inode *ino, struct file *filep); -#else -static void zft_close(struct inode *ino, struct file *filep); -#endif static int zft_ioctl(struct inode *ino, struct file *filep, unsigned int command, unsigned long arg); -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,56) static int zft_mmap(struct file *filep, struct vm_area_struct *vma); -#else -static int zft_mmap(struct inode *ino, struct file *filep, - struct vm_area_struct *vma); -#endif -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60) static ssize_t zft_read (struct file *fp, char *buff, size_t req_len, loff_t *ppos); static ssize_t zft_write(struct file *fp, const char *buff, size_t req_len, loff_t *ppos); -#elif LINUX_VERSION_CODE >= KERNEL_VER(2,1,0) -static long zft_read (struct inode *ino, struct file *fp, char *buff, - unsigned long req_len); -static long zft_write(struct inode *ino, struct file *fp, const char *buff, - unsigned long req_len); -#else -static int zft_read (struct inode *ino, struct file *fp, char *buff, - int req_len); -static int zft_write(struct inode *ino, struct file *fp, const char *buff, - int req_len); -#endif static struct file_operations zft_cdev = { + owner: THIS_MODULE, read: zft_read, write: zft_write, ioctl: zft_ioctl, @@ -137,15 +111,6 @@ static int zft_open(struct inode *ino, struct file *filep) int result; TRACE_FUN(ft_t_flow); -#if LINUX_VERSION_CODE < KERNEL_VER(2,1,18) - if (!MOD_IN_USE) { - MOD_INC_USE_COUNT; /* lock module in memory */ - } -#else - MOD_INC_USE_COUNT; /* sets MOD_VISITED and MOD_USED_ONCE, - * locking is done with can_unload() - */ -#endif TRACE(ft_t_flow, "called for minor %d", MINOR(ino->i_rdev)); if (busy_flag) { TRACE_ABORT(-EBUSY, ft_t_warn, "failed: already busy"); @@ -155,11 +120,6 @@ static int zft_open(struct inode *ino, struct file *filep) > FTAPE_SEL_D) { busy_flag = 0; -#if defined(MODULE) && LINUX_VERSION_CODE < KERNEL_VER(2,1,18) - if (!zft_dirty()) { - MOD_DEC_USE_COUNT; /* unlock module in memory */ - } -#endif TRACE_ABORT(-ENXIO, ft_t_err, "failed: illegal unit nr"); } orig_sigmask = current->blocked; @@ -168,11 +128,6 @@ static int zft_open(struct inode *ino, struct file *filep) if (result < 0) { current->blocked = orig_sigmask; /* restore mask */ busy_flag = 0; -#if defined(MODULE) && LINUX_VERSION_CODE < KERNEL_VER(2,1,18) - if (!zft_dirty()) { - MOD_DEC_USE_COUNT; /* unlock module in memory */ - } -#endif TRACE_ABORT(result, ft_t_err, "_ftape_open failed"); } else { /* Mask signals that will disturb proper operation of the @@ -191,13 +146,11 @@ static int zft_close(struct inode *ino, struct file *filep) int result; TRACE_FUN(ft_t_flow); + lock_kernel(); if (!busy_flag || MINOR(ino->i_rdev) != zft_unit) { TRACE(ft_t_err, "failed: not busy or wrong unit"); -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,31) + unlock_kernel(); TRACE_EXIT 0; -#else - TRACE_EXIT; /* keep busy_flag !(?) */ -#endif } sigfillset(¤t->blocked); result = _zft_close(); @@ -206,16 +159,8 @@ static int zft_close(struct inode *ino, struct file *filep) } current->blocked = orig_sigmask; /* restore before open state */ busy_flag = 0; -#if defined(MODULE) && LINUX_VERSION_CODE < KERNEL_VER(2,1,18) - if (!zft_dirty()) { - MOD_DEC_USE_COUNT; /* unlock module in memory */ - } -#endif -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,31) + unlock_kernel(); TRACE_EXIT 0; -#else - TRACE_EXIT; -#endif } /* Ioctl for floppy tape device @@ -241,24 +186,14 @@ static int zft_ioctl(struct inode *ino, struct file *filep, /* Ioctl for floppy tape device */ -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,56) static int zft_mmap(struct file *filep, struct vm_area_struct *vma) -#else -static int zft_mmap(struct inode *ino, - struct file *filep, - struct vm_area_struct *vma) -#endif { int result = -EIO; sigset_t old_sigmask; TRACE_FUN(ft_t_flow); if (!busy_flag || -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,56) MINOR(filep->f_dentry->d_inode->i_rdev) != zft_unit || -#else - MINOR(ino->i_rdev) != zft_unit || -#endif ft_failure) { TRACE_ABORT(-EIO, ft_t_err, @@ -266,34 +201,26 @@ static int zft_mmap(struct inode *ino, } old_sigmask = current->blocked; /* save mask */ sigfillset(¤t->blocked); + lock_kernel(); if ((result = ftape_mmap(vma)) >= 0) { #ifndef MSYNC_BUG_WAS_FIXED static struct vm_operations_struct dummy = { NULL, }; vma->vm_ops = &dummy; #endif } + unlock_kernel(); current->blocked = old_sigmask; /* restore mask */ TRACE_EXIT result; } /* Read from floppy tape device */ -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60) static ssize_t zft_read(struct file *fp, char *buff, size_t req_len, loff_t *ppos) -#elif LINUX_VERSION_CODE >= KERNEL_VER(2,1,0) -static long zft_read(struct inode *ino, struct file *fp, char *buff, - unsigned long req_len) -#else -static int zft_read(struct inode *ino, struct file *fp, char *buff, - int req_len) -#endif { int result = -EIO; sigset_t old_sigmask; -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60) struct inode *ino = fp->f_dentry->d_inode; -#endif TRACE_FUN(ft_t_flow); TRACE(ft_t_data_flow, "called with count: %ld", (unsigned long)req_len); @@ -311,22 +238,12 @@ static int zft_read(struct inode *ino, struct file *fp, char *buff, /* Write to tape device */ -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60) static ssize_t zft_write(struct file *fp, const char *buff, size_t req_len, loff_t *ppos) -#elif LINUX_VERSION_CODE >= KERNEL_VER(2,1,0) -static long zft_write(struct inode *ino, struct file *fp, const char *buff, - unsigned long req_len) -#else -static int zft_write(struct inode *ino, struct file *fp, const char *buff, - int req_len) -#endif { int result = -EIO; sigset_t old_sigmask; -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60) struct inode *ino = fp->f_dentry->d_inode; -#endif TRACE_FUN(ft_t_flow); TRACE(ft_t_flow, "called with count: %ld", (unsigned long)req_len); @@ -470,9 +387,6 @@ KERN_INFO &zft_cdev, NULL); } -#if LINUX_VERSION_CODE < KERNEL_VER(2,1,18) - register_symtab(&zft_symbol_table); /* add global zftape symbols */ -#endif #ifdef CONFIG_ZFT_COMPRESSOR (void)zft_compressor_init(); #endif @@ -484,24 +398,20 @@ KERN_INFO #ifdef MODULE -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,18) /* Called by modules package before trying to unload the module */ static int can_unload(void) { - return (zft_dirty() || busy_flag) ? -EBUSY : 0; + return (GET_USE_COUNT(THIS_MODULE)||zft_dirty()||busy_flag)?-EBUSY:0; } -#endif /* Called by modules package when installing the driver */ int init_module(void) { -#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,18) if (!mod_member_present(&__this_module, can_unload)) { return -EBUSY; } __this_module.can_unload = can_unload; -#endif return zft_init(); } |