aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2008-07-04 03:29:16 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-07-04 03:52:13 -0400
commit5b6155ee70e9c4d2ad7e6f514c8eee06e2711c3a (patch)
treed764e0d474c2d6cf44eaba1d28fce3f50bc63e73 /drivers/block
parentbe1fd70fea1100c57f3aa1934ebb93abc474e50c (diff)
pktcdvd: push BKL down into driver
Push the lock_kernel down into the driver and switch to unlocked_ioctl [akpm@linux-foundation.org: build fix] Signed-off-by: Alan Cox <alan@redhat.com> Acked-by: Peter Osterlund <petero2@telia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/pktcdvd.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 589850cff359..85e44d07eab8 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -49,6 +49,7 @@
49#include <linux/types.h> 49#include <linux/types.h>
50#include <linux/kernel.h> 50#include <linux/kernel.h>
51#include <linux/kthread.h> 51#include <linux/kthread.h>
52#include <linux/smp_lock.h>
52#include <linux/errno.h> 53#include <linux/errno.h>
53#include <linux/spinlock.h> 54#include <linux/spinlock.h>
54#include <linux/file.h> 55#include <linux/file.h>
@@ -2797,9 +2798,14 @@ out_mem:
2797 return ret; 2798 return ret;
2798} 2799}
2799 2800
2800static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 2801static long pkt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2801{ 2802{
2802 struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; 2803 struct inode *inode = file->f_path.dentry->d_inode;
2804 struct pktcdvd_device *pd;
2805 long ret;
2806
2807 lock_kernel();
2808 pd = inode->i_bdev->bd_disk->private_data;
2803 2809
2804 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode)); 2810 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode));
2805 2811
@@ -2812,7 +2818,8 @@ static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
2812 case CDROM_LAST_WRITTEN: 2818 case CDROM_LAST_WRITTEN:
2813 case CDROM_SEND_PACKET: 2819 case CDROM_SEND_PACKET:
2814 case SCSI_IOCTL_SEND_COMMAND: 2820 case SCSI_IOCTL_SEND_COMMAND:
2815 return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); 2821 ret = blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg);
2822 break;
2816 2823
2817 case CDROMEJECT: 2824 case CDROMEJECT:
2818 /* 2825 /*
@@ -2821,14 +2828,15 @@ static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
2821 */ 2828 */
2822 if (pd->refcnt == 1) 2829 if (pd->refcnt == 1)
2823 pkt_lock_door(pd, 0); 2830 pkt_lock_door(pd, 0);
2824 return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); 2831 ret = blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg);
2832 break;
2825 2833
2826 default: 2834 default:
2827 VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); 2835 VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd);
2828 return -ENOTTY; 2836 ret = -ENOTTY;
2829 } 2837 }
2830 2838 unlock_kernel();
2831 return 0; 2839 return ret;
2832} 2840}
2833 2841
2834static int pkt_media_changed(struct gendisk *disk) 2842static int pkt_media_changed(struct gendisk *disk)
@@ -2850,7 +2858,7 @@ static struct block_device_operations pktcdvd_ops = {
2850 .owner = THIS_MODULE, 2858 .owner = THIS_MODULE,
2851 .open = pkt_open, 2859 .open = pkt_open,
2852 .release = pkt_close, 2860 .release = pkt_close,
2853 .ioctl = pkt_ioctl, 2861 .unlocked_ioctl = pkt_ioctl,
2854 .media_changed = pkt_media_changed, 2862 .media_changed = pkt_media_changed,
2855}; 2863};
2856 2864
@@ -3015,7 +3023,8 @@ static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd)
3015 mutex_unlock(&ctl_mutex); 3023 mutex_unlock(&ctl_mutex);
3016} 3024}
3017 3025
3018static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 3026static long pkt_ctl_ioctl(struct file *file, unsigned int cmd,
3027 unsigned long arg)
3019{ 3028{
3020 void __user *argp = (void __user *)arg; 3029 void __user *argp = (void __user *)arg;
3021 struct pkt_ctrl_command ctrl_cmd; 3030 struct pkt_ctrl_command ctrl_cmd;
@@ -3032,16 +3041,22 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
3032 case PKT_CTRL_CMD_SETUP: 3041 case PKT_CTRL_CMD_SETUP:
3033 if (!capable(CAP_SYS_ADMIN)) 3042 if (!capable(CAP_SYS_ADMIN))
3034 return -EPERM; 3043 return -EPERM;
3044 lock_kernel();
3035 ret = pkt_setup_dev(new_decode_dev(ctrl_cmd.dev), &pkt_dev); 3045 ret = pkt_setup_dev(new_decode_dev(ctrl_cmd.dev), &pkt_dev);
3036 ctrl_cmd.pkt_dev = new_encode_dev(pkt_dev); 3046 ctrl_cmd.pkt_dev = new_encode_dev(pkt_dev);
3047 unlock_kernel();
3037 break; 3048 break;
3038 case PKT_CTRL_CMD_TEARDOWN: 3049 case PKT_CTRL_CMD_TEARDOWN:
3039 if (!capable(CAP_SYS_ADMIN)) 3050 if (!capable(CAP_SYS_ADMIN))
3040 return -EPERM; 3051 return -EPERM;
3052 lock_kernel();
3041 ret = pkt_remove_dev(new_decode_dev(ctrl_cmd.pkt_dev)); 3053 ret = pkt_remove_dev(new_decode_dev(ctrl_cmd.pkt_dev));
3054 unlock_kernel();
3042 break; 3055 break;
3043 case PKT_CTRL_CMD_STATUS: 3056 case PKT_CTRL_CMD_STATUS:
3057 lock_kernel();
3044 pkt_get_status(&ctrl_cmd); 3058 pkt_get_status(&ctrl_cmd);
3059 unlock_kernel();
3045 break; 3060 break;
3046 default: 3061 default:
3047 return -ENOTTY; 3062 return -ENOTTY;
@@ -3054,7 +3069,7 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
3054 3069
3055 3070
3056static const struct file_operations pkt_ctl_fops = { 3071static const struct file_operations pkt_ctl_fops = {
3057 .ioctl = pkt_ctl_ioctl, 3072 .unlocked_ioctl = pkt_ctl_ioctl,
3058 .owner = THIS_MODULE, 3073 .owner = THIS_MODULE,
3059}; 3074};
3060 3075