if (copy_from_user(scmd->cmnd, uptr64(hdr->request), scmd->cmd_len))
                goto out_put_request;
        ret = -EPERM;
-       if (!scsi_cmd_allowed(scmd->cmnd, mode))
+       if (!scsi_cmd_allowed(scmd->cmnd, mode & FMODE_WRITE))
                goto out_put_request;
 
        ret = 0;
 
  * Only a subset of commands are allowed for unprivileged users. Commands used
  * to format the media, update the firmware, etc. are not permitted.
  */
-bool scsi_cmd_allowed(unsigned char *cmd, fmode_t mode)
+bool scsi_cmd_allowed(unsigned char *cmd, bool open_for_write)
 {
        /* root can do any command. */
        if (capable(CAP_SYS_RAWIO))
        case GPCMD_SET_READ_AHEAD:
        /* ZBC */
        case ZBC_OUT:
-               return (mode & FMODE_WRITE);
+               return open_for_write;
        default:
                return false;
        }
                return -EMSGSIZE;
        if (copy_from_user(scmd->cmnd, hdr->cmdp, hdr->cmd_len))
                return -EFAULT;
-       if (!scsi_cmd_allowed(scmd->cmnd, mode))
+       if (!scsi_cmd_allowed(scmd->cmnd, mode & FMODE_WRITE))
                return -EPERM;
        scmd->cmd_len = hdr->cmd_len;
 
                goto error;
 
        err = -EPERM;
-       if (!scsi_cmd_allowed(scmd->cmnd, mode))
+       if (!scsi_cmd_allowed(scmd->cmnd, mode & FMODE_WRITE))
                goto error;
 
        /* default.  possible overridden later */
 
 
        if (sfp->parentdp->device->type == TYPE_SCANNER)
                return 0;
-       if (!scsi_cmd_allowed(cmd, filp->f_mode))
+       if (!scsi_cmd_allowed(cmd, filp->f_mode & FMODE_WRITE))
                return -EPERM;
        return 0;
 }
 
                void __user *arg);
 int get_sg_io_hdr(struct sg_io_hdr *hdr, const void __user *argp);
 int put_sg_io_hdr(const struct sg_io_hdr *hdr, void __user *argp);
-bool scsi_cmd_allowed(unsigned char *cmd, fmode_t mode);
+bool scsi_cmd_allowed(unsigned char *cmd, bool open_for_write);
 
 #endif /* __KERNEL__ */
 #endif /* _SCSI_IOCTL_H */