Skip to content

Commit 0338e29

Browse files
author
Al Viro
committed
[PATCH] switch sd
Signed-off-by: Al Viro <[email protected]>
1 parent 3e3c9c6 commit 0338e29

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

drivers/scsi/sd.c

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -609,17 +609,15 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
609609
* In the latter case @inode and @filp carry an abridged amount
610610
* of information as noted above.
611611
**/
612-
static int sd_open(struct inode *inode, struct file *filp)
612+
static int sd_open(struct block_device *bdev, fmode_t mode)
613613
{
614-
struct gendisk *disk = inode->i_bdev->bd_disk;
615-
struct scsi_disk *sdkp;
614+
struct scsi_disk *sdkp = scsi_disk_get(bdev->bd_disk);
616615
struct scsi_device *sdev;
617616
int retval;
618617

619-
if (!(sdkp = scsi_disk_get(disk)))
618+
if (!sdkp)
620619
return -ENXIO;
621620

622-
623621
SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_open\n"));
624622

625623
sdev = sdkp->device;
@@ -633,22 +631,21 @@ static int sd_open(struct inode *inode, struct file *filp)
633631
goto error_out;
634632

635633
if (sdev->removable || sdkp->write_prot)
636-
check_disk_change(inode->i_bdev);
634+
check_disk_change(bdev);
637635

638636
/*
639637
* If the drive is empty, just let the open fail.
640638
*/
641639
retval = -ENOMEDIUM;
642-
if (sdev->removable && !sdkp->media_present &&
643-
!(filp->f_mode & FMODE_NDELAY))
640+
if (sdev->removable && !sdkp->media_present && !(mode & FMODE_NDELAY))
644641
goto error_out;
645642

646643
/*
647644
* If the device has the write protect tab set, have the open fail
648645
* if the user expects to be able to write to the thing.
649646
*/
650647
retval = -EROFS;
651-
if (sdkp->write_prot && (filp->f_mode & FMODE_WRITE))
648+
if (sdkp->write_prot && (mode & FMODE_WRITE))
652649
goto error_out;
653650

654651
/*
@@ -684,9 +681,8 @@ static int sd_open(struct inode *inode, struct file *filp)
684681
* Note: may block (uninterruptible) if error recovery is underway
685682
* on this disk.
686683
**/
687-
static int sd_release(struct inode *inode, struct file *filp)
684+
static int sd_release(struct gendisk *disk, fmode_t mode)
688685
{
689-
struct gendisk *disk = inode->i_bdev->bd_disk;
690686
struct scsi_disk *sdkp = scsi_disk(disk);
691687
struct scsi_device *sdev = sdkp->device;
692688

@@ -743,10 +739,9 @@ static int sd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
743739
* Note: most ioctls are forward onto the block subsystem or further
744740
* down in the scsi subsystem.
745741
**/
746-
static int sd_ioctl(struct inode * inode, struct file * filp,
742+
static int sd_ioctl(struct block_device *bdev, fmode_t mode,
747743
unsigned int cmd, unsigned long arg)
748744
{
749-
struct block_device *bdev = inode->i_bdev;
750745
struct gendisk *disk = bdev->bd_disk;
751746
struct scsi_device *sdp = scsi_disk(disk)->device;
752747
void __user *p = (void __user *)arg;
@@ -762,7 +757,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
762757
* access to the device is prohibited.
763758
*/
764759
error = scsi_nonblockable_ioctl(sdp, cmd, p,
765-
filp ? filp->f_flags & O_NDELAY : 0);
760+
(mode & FMODE_NDELAY_NOW) != 0);
766761
if (!scsi_block_when_processing_errors(sdp) || !error)
767762
return error;
768763

@@ -776,8 +771,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
776771
case SCSI_IOCTL_GET_BUS_NUMBER:
777772
return scsi_ioctl(sdp, cmd, p);
778773
default:
779-
error = scsi_cmd_ioctl(disk->queue, disk,
780-
filp ? filp->f_mode : 0, cmd, p);
774+
error = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, p);
781775
if (error != -ENOTTY)
782776
return error;
783777
}
@@ -930,11 +924,10 @@ static void sd_rescan(struct device *dev)
930924
* This gets directly called from VFS. When the ioctl
931925
* is not recognized we go back to the other translation paths.
932926
*/
933-
static long sd_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
927+
static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode,
928+
unsigned int cmd, unsigned long arg)
934929
{
935-
struct block_device *bdev = file->f_path.dentry->d_inode->i_bdev;
936-
struct gendisk *disk = bdev->bd_disk;
937-
struct scsi_device *sdev = scsi_disk(disk)->device;
930+
struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device;
938931

939932
/*
940933
* If we are in the middle of error recovery, don't let anyone
@@ -962,12 +955,12 @@ static long sd_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a
962955

963956
static struct block_device_operations sd_fops = {
964957
.owner = THIS_MODULE,
965-
.__open = sd_open,
966-
.__release = sd_release,
967-
.__ioctl = sd_ioctl,
958+
.open = sd_open,
959+
.release = sd_release,
960+
.locked_ioctl = sd_ioctl,
968961
.getgeo = sd_getgeo,
969962
#ifdef CONFIG_COMPAT
970-
.__compat_ioctl = sd_compat_ioctl,
963+
.compat_ioctl = sd_compat_ioctl,
971964
#endif
972965
.media_changed = sd_media_changed,
973966
.revalidate_disk = sd_revalidate_disk,

0 commit comments

Comments
 (0)