mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
scsi: replace the fmode_t argument to ->sg_io_fn with a simple bool
Instead of passing a fmode_t and only checking it for FMODE_WRITE, pass a bool open_for_write to prepare for callers that won't have the fmode_t. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Acked-by: Christian Brauner <brauner@kernel.org> Link: https://lore.kernel.org/r/20230608110258.189493-21-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
2e80089c18
commit
1991299e49
@ -26,7 +26,7 @@ struct bsg_set {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int bsg_transport_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
|
static int bsg_transport_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
|
||||||
fmode_t mode, unsigned int timeout)
|
bool open_for_write, unsigned int timeout)
|
||||||
{
|
{
|
||||||
struct bsg_job *job;
|
struct bsg_job *job;
|
||||||
struct request *rq;
|
struct request *rq;
|
||||||
|
@ -54,7 +54,8 @@ static unsigned int bsg_timeout(struct bsg_device *bd, struct sg_io_v4 *hdr)
|
|||||||
return max_t(unsigned int, timeout, BLK_MIN_SG_TIMEOUT);
|
return max_t(unsigned int, timeout, BLK_MIN_SG_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bsg_sg_io(struct bsg_device *bd, fmode_t mode, void __user *uarg)
|
static int bsg_sg_io(struct bsg_device *bd, bool open_for_write,
|
||||||
|
void __user *uarg)
|
||||||
{
|
{
|
||||||
struct sg_io_v4 hdr;
|
struct sg_io_v4 hdr;
|
||||||
int ret;
|
int ret;
|
||||||
@ -63,7 +64,8 @@ static int bsg_sg_io(struct bsg_device *bd, fmode_t mode, void __user *uarg)
|
|||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
if (hdr.guard != 'Q')
|
if (hdr.guard != 'Q')
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
ret = bd->sg_io_fn(bd->queue, &hdr, mode, bsg_timeout(bd, &hdr));
|
ret = bd->sg_io_fn(bd->queue, &hdr, open_for_write,
|
||||||
|
bsg_timeout(bd, &hdr));
|
||||||
if (!ret && copy_to_user(uarg, &hdr, sizeof(hdr)))
|
if (!ret && copy_to_user(uarg, &hdr, sizeof(hdr)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return ret;
|
return ret;
|
||||||
@ -146,7 +148,7 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|||||||
case SG_EMULATED_HOST:
|
case SG_EMULATED_HOST:
|
||||||
return put_user(1, intp);
|
return put_user(1, intp);
|
||||||
case SG_IO:
|
case SG_IO:
|
||||||
return bsg_sg_io(bd, file->f_mode, uarg);
|
return bsg_sg_io(bd, file->f_mode & FMODE_WRITE, uarg);
|
||||||
case SCSI_IOCTL_SEND_COMMAND:
|
case SCSI_IOCTL_SEND_COMMAND:
|
||||||
pr_warn_ratelimited("%s: calling unsupported SCSI_IOCTL_SEND_COMMAND\n",
|
pr_warn_ratelimited("%s: calling unsupported SCSI_IOCTL_SEND_COMMAND\n",
|
||||||
current->comm);
|
current->comm);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#define uptr64(val) ((void __user *)(uintptr_t)(val))
|
#define uptr64(val) ((void __user *)(uintptr_t)(val))
|
||||||
|
|
||||||
static int scsi_bsg_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
|
static int scsi_bsg_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
|
||||||
fmode_t mode, unsigned int timeout)
|
bool open_for_write, unsigned int timeout)
|
||||||
{
|
{
|
||||||
struct scsi_cmnd *scmd;
|
struct scsi_cmnd *scmd;
|
||||||
struct request *rq;
|
struct request *rq;
|
||||||
@ -42,7 +42,7 @@ static int scsi_bsg_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
|
|||||||
if (copy_from_user(scmd->cmnd, uptr64(hdr->request), scmd->cmd_len))
|
if (copy_from_user(scmd->cmnd, uptr64(hdr->request), scmd->cmd_len))
|
||||||
goto out_put_request;
|
goto out_put_request;
|
||||||
ret = -EPERM;
|
ret = -EPERM;
|
||||||
if (!scsi_cmd_allowed(scmd->cmnd, mode & FMODE_WRITE))
|
if (!scsi_cmd_allowed(scmd->cmnd, open_for_write))
|
||||||
goto out_put_request;
|
goto out_put_request;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -9,7 +9,7 @@ struct device;
|
|||||||
struct request_queue;
|
struct request_queue;
|
||||||
|
|
||||||
typedef int (bsg_sg_io_fn)(struct request_queue *, struct sg_io_v4 *hdr,
|
typedef int (bsg_sg_io_fn)(struct request_queue *, struct sg_io_v4 *hdr,
|
||||||
fmode_t mode, unsigned int timeout);
|
bool open_for_write, unsigned int timeout);
|
||||||
|
|
||||||
struct bsg_device *bsg_register_queue(struct request_queue *q,
|
struct bsg_device *bsg_register_queue(struct request_queue *q,
|
||||||
struct device *parent, const char *name,
|
struct device *parent, const char *name,
|
||||||
|
Loading…
Reference in New Issue
Block a user