Commit f4927c45 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Frederic Weisbecker
Browse files

scsi: Push down BKL into ioctl functions



Push down the bkl into ioctl functions on the scsi layer.

[jkacur: Forward declaration missing ';'.
Conflicting declaraction in megaraid.h changed
Fixed missing inodes declarations]

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarJohn Kacur <jkacur@redhat.com>
Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
parent 16ef8def
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_H
static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id);
static char *twa_aen_severity_lookup(unsigned char severity_code);
static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id);
static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
static long twa_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
static int twa_chrdev_open(struct inode *inode, struct file *file);
static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_host);
static void twa_free_request_id(TW_Device_Extension *tw_dev,int request_id);
@@ -218,7 +218,7 @@ static struct device_attribute *twa_host_attrs[] = {
/* File operations struct for character device */
static const struct file_operations twa_fops = {
	.owner		= THIS_MODULE,
	.ioctl		= twa_chrdev_ioctl,
	.unlocked_ioctl	= twa_chrdev_ioctl,
	.open		= twa_chrdev_open,
	.release	= NULL
};
@@ -635,8 +635,9 @@ out:
} /* End twa_check_srl() */

/* This function handles ioctl for the character device */
static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
static long twa_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	struct inode *inode = file->f_path.dentry->d_inode;
	long timeout;
	unsigned long *cpu_addr, data_buffer_length_adjusted = 0, flags = 0;
	dma_addr_t dma_handle;
@@ -655,6 +656,8 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
	int retval = TW_IOCTL_ERROR_OS_EFAULT;
	void __user *argp = (void __user *)arg;

	lock_kernel();

	/* Only let one of these through at a time */
	if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
		retval = TW_IOCTL_ERROR_OS_EINTR;
@@ -874,6 +877,7 @@ out3:
out2:
	mutex_unlock(&tw_dev->ioctl_lock);
out:
	unlock_kernel();
	return retval;
} /* End twa_chrdev_ioctl() */

+6 −2
Original line number Diff line number Diff line
@@ -750,19 +750,22 @@ static void twl_load_sgl(TW_Device_Extension *tw_dev, TW_Command_Full *full_comm

/* This function handles ioctl for the character device
   This interface is used by smartmontools open source software */
static int twl_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
static long twl_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	long timeout;
	unsigned long *cpu_addr, data_buffer_length_adjusted = 0, flags = 0;
	dma_addr_t dma_handle;
	int request_id = 0;
	TW_Ioctl_Driver_Command driver_command;
	struct inode *inode = file->f_dentry->d_inode;
	TW_Ioctl_Buf_Apache *tw_ioctl;
	TW_Command_Full *full_command_packet;
	TW_Device_Extension *tw_dev = twl_device_extension_list[iminor(inode)];
	int retval = -EFAULT;
	void __user *argp = (void __user *)arg;

	lock_kernel();

	/* Only let one of these through at a time */
	if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
		retval = -EINTR;
@@ -858,6 +861,7 @@ out3:
out2:
	mutex_unlock(&tw_dev->ioctl_lock);
out:
	unlock_kernel();
	return retval;
} /* End twl_chrdev_ioctl() */

@@ -884,7 +888,7 @@ out:
/* File operations struct for character device */
static const struct file_operations twl_fops = {
	.owner		= THIS_MODULE,
	.ioctl		= twl_chrdev_ioctl,
	.unlocked_ioctl	= twl_chrdev_ioctl,
	.open		= twl_chrdev_open,
	.release	= NULL
};
+8 −3
Original line number Diff line number Diff line
@@ -880,7 +880,7 @@ static int tw_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
} /* End tw_allocate_memory() */

/* This function handles ioctl for the character device */
static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
static long tw_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	int request_id;
	dma_addr_t dma_handle;
@@ -888,6 +888,7 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
	unsigned long flags;
	unsigned int data_buffer_length = 0;
	unsigned long data_buffer_length_adjusted = 0;
	struct inode *inode = file->f_dentry->d_inode;
	unsigned long *cpu_addr;
	long timeout;
	TW_New_Ioctl *tw_ioctl;
@@ -898,9 +899,12 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int

	dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n");

	lock_kernel();
	/* Only let one of these through at a time */
	if (mutex_lock_interruptible(&tw_dev->ioctl_lock))
	if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
		unlock_kernel();
		return -EINTR;
	}

	/* First copy down the buffer length */
	if (copy_from_user(&data_buffer_length, argp, sizeof(unsigned int)))
@@ -1029,6 +1033,7 @@ out2:
	dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle);
out:
	mutex_unlock(&tw_dev->ioctl_lock);
	unlock_kernel();
	return retval;
} /* End tw_chrdev_ioctl() */

@@ -1051,7 +1056,7 @@ static int tw_chrdev_open(struct inode *inode, struct file *file)
/* File operations struct for character device */
static const struct file_operations tw_fops = {
	.owner		= THIS_MODULE,
	.ioctl		= tw_chrdev_ioctl,
	.unlocked_ioctl	= tw_chrdev_ioctl,
	.open		= tw_chrdev_open,
	.release	= NULL
};
+8 −3
Original line number Diff line number Diff line
@@ -705,12 +705,17 @@ static int aac_cfg_open(struct inode *inode, struct file *file)
 *	Bugs: Needs to handle hot plugging
 */

static int aac_cfg_ioctl(struct inode *inode, struct file *file,
static long aac_cfg_ioctl(struct file *file,
		unsigned int cmd, unsigned long arg)
{
	int ret;
	if (!capable(CAP_SYS_RAWIO))
		return -EPERM;
	return aac_do_ioctl(file->private_data, cmd, (void __user *)arg);
	lock_kernel();
	ret = aac_do_ioctl(file->private_data, cmd, (void __user *)arg);
	unlock_kernel();

	return ret;
}

#ifdef CONFIG_COMPAT
@@ -1029,7 +1034,7 @@ ssize_t aac_get_serial_number(struct device *device, char *buf)

static const struct file_operations aac_cfg_fops = {
	.owner		= THIS_MODULE,
	.ioctl		= aac_cfg_ioctl,
	.unlocked_ioctl	= aac_cfg_ioctl,
#ifdef CONFIG_COMPAT
	.compat_ioctl   = aac_compat_cfg_ioctl,
#endif
+17 −3
Original line number Diff line number Diff line
@@ -114,12 +114,13 @@ static int hba_count = 0;

static struct class *adpt_sysfs_class;

static long adpt_unlocked_ioctl(struct file *, unsigned int, unsigned long);
#ifdef CONFIG_COMPAT
static long compat_adpt_ioctl(struct file *, unsigned int, unsigned long);
#endif

static const struct file_operations adpt_fops = {
	.ioctl		= adpt_ioctl,
	.unlocked_ioctl	= adpt_unlocked_ioctl,
	.open		= adpt_open,
	.release	= adpt_close,
#ifdef CONFIG_COMPAT
@@ -2069,8 +2070,7 @@ static int adpt_system_info(void __user *buffer)
	return 0;
}

static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
	      ulong arg)
static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
{
	int minor;
	int error = 0;
@@ -2153,6 +2153,20 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
	return error;
}

static long adpt_unlocked_ioctl(struct file *file, uint cmd, ulong arg)
{
	struct inode *inode;
	long ret;
 
	inode = file->f_dentry->d_inode;
 
	lock_kernel();
	ret = adpt_ioctl(inode, file, cmd, arg);
	unlock_kernel();

	return ret;
}

#ifdef CONFIG_COMPAT
static long compat_adpt_ioctl(struct file *file,
				unsigned int cmd, unsigned long arg)
Loading