]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/scsi/sd.c
[PATCH] beginning of methods conversion
[mirror_ubuntu-zesty-kernel.git] / drivers / scsi / sd.c
index a7b53be633676399e3a08b6a6113a2b95da7cc6e..c8b95e8d2859163aeea032663235d70236f61ed2 100644 (file)
@@ -384,7 +384,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
        sector_t block = rq->sector;
        sector_t threshold;
        unsigned int this_count = rq->nr_sectors;
-       int ret;
+       int ret, host_dif;
 
        if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
                ret = scsi_setup_blk_pc_cmnd(sdp, rq);
@@ -515,7 +515,8 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
                                        rq->nr_sectors));
 
        /* Set RDPROTECT/WRPROTECT if disk is formatted with DIF */
-       if (scsi_host_dif_capable(sdp->host, sdkp->protection_type))
+       host_dif = scsi_host_dif_capable(sdp->host, sdkp->protection_type);
+       if (host_dif)
                SCpnt->cmnd[1] = 1 << 5;
        else
                SCpnt->cmnd[1] = 0;
@@ -573,8 +574,9 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
        SCpnt->sdb.length = this_count * sdp->sector_size;
 
        /* If DIF or DIX is enabled, tell HBA how to handle request */
-       if (sdkp->protection_type || scsi_prot_sg_count(SCpnt))
-               sd_dif_op(SCpnt, sdkp->protection_type, scsi_prot_sg_count(SCpnt));
+       if (host_dif || scsi_prot_sg_count(SCpnt))
+               sd_dif_op(SCpnt, host_dif, scsi_prot_sg_count(SCpnt),
+                         sdkp->protection_type);
 
        /*
         * We shouldn't disconnect in the middle of a sector, so with a dumb
@@ -638,7 +640,7 @@ static int sd_open(struct inode *inode, struct file *filp)
         */
        retval = -ENOMEDIUM;
        if (sdev->removable && !sdkp->media_present &&
-           !(filp->f_flags & O_NDELAY))
+           !(filp->f_mode & FMODE_NDELAY))
                goto error_out;
 
        /*
@@ -759,7 +761,8 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
         * may try and take the device offline, in which case all further
         * access to the device is prohibited.
         */
-       error = scsi_nonblockable_ioctl(sdp, cmd, p, filp);
+       error = scsi_nonblockable_ioctl(sdp, cmd, p,
+                                       filp ? filp->f_flags & O_NDELAY : 0);
        if (!scsi_block_when_processing_errors(sdp) || !error)
                return error;
 
@@ -773,7 +776,8 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
                case SCSI_IOCTL_GET_BUS_NUMBER:
                        return scsi_ioctl(sdp, cmd, p);
                default:
-                       error = scsi_cmd_ioctl(filp, disk->queue, disk, cmd, p);
+                       error = scsi_cmd_ioctl(disk->queue, disk,
+                                       filp ? filp->f_mode : 0, cmd, p);
                        if (error != -ENOTTY)
                                return error;
        }
@@ -958,12 +962,12 @@ static long sd_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a
 
 static struct block_device_operations sd_fops = {
        .owner                  = THIS_MODULE,
-       .open                   = sd_open,
-       .release                = sd_release,
-       .ioctl                  = sd_ioctl,
+       .__open                 = sd_open,
+       .__release              = sd_release,
+       .__ioctl                        = sd_ioctl,
        .getgeo                 = sd_getgeo,
 #ifdef CONFIG_COMPAT
-       .compat_ioctl           = sd_compat_ioctl,
+       .__compat_ioctl         = sd_compat_ioctl,
 #endif
        .media_changed          = sd_media_changed,
        .revalidate_disk        = sd_revalidate_disk,
@@ -1252,14 +1256,12 @@ void sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer)
        else
                type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */
 
+       sdkp->protection_type = type;
+
        switch (type) {
        case SD_DIF_TYPE0_PROTECTION:
-               sdkp->protection_type = 0;
-               break;
-
        case SD_DIF_TYPE1_PROTECTION:
        case SD_DIF_TYPE3_PROTECTION:
-               sdkp->protection_type = type;
                break;
 
        case SD_DIF_TYPE2_PROTECTION:
@@ -1277,7 +1279,6 @@ void sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer)
        return;
 
 disable:
-       sdkp->protection_type = 0;
        sdkp->capacity = 0;
 }