Commit 68ec3b81 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

scsi: add a scsi_alloc_request helper



Add a new helper that calls blk_get_request and initializes the
scsi_request to avoid the indirect call through ->.initialize_rq_fn.

Note that this makes the pktcdvd driver depend on the SCSI core, but
given that only SCSI devices support SCSI passthrough requests that
is not a functional change.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20211021060607.264371-6-hch@lst.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 237ea160
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -304,8 +304,8 @@ config BLK_DEV_RAM_SIZE
config CDROM_PKTCDVD
	tristate "Packet writing on CD/DVD media (DEPRECATED)"
	depends on !UML
	depends on SCSI
	select CDROM
	select SCSI_COMMON
	help
	  Note: This driver is deprecated and will be removed from the
	  kernel in the near future!
+1 −1
Original line number Diff line number Diff line
@@ -703,7 +703,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
	struct request *rq;
	int ret = 0;

	rq = blk_get_request(q, (cgc->data_direction == CGC_DATA_WRITE) ?
	rq = scsi_alloc_request(q, (cgc->data_direction == CGC_DATA_WRITE) ?
			     REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0);
	if (IS_ERR(rq))
		return PTR_ERR(rq);
+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ static int scsi_bsg_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
		return -EOPNOTSUPP;
	}

	rq = blk_get_request(q, hdr->dout_xfer_len ?
	rq = scsi_alloc_request(q, hdr->dout_xfer_len ?
				REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0);
	if (IS_ERR(rq))
		return PTR_ERR(rq);
+1 −1
Original line number Diff line number Diff line
@@ -1998,7 +1998,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev)
	struct request *req;
	struct scsi_request *rq;

	req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN, 0);
	req = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN, 0);
	if (IS_ERR(req))
		return;
	rq = scsi_req(req);
+2 −2
Original line number Diff line number Diff line
@@ -438,7 +438,7 @@ static int sg_io(struct scsi_device *sdev, struct gendisk *disk,
		at_head = 1;

	ret = -ENOMEM;
	rq = blk_get_request(sdev->request_queue, writing ?
	rq = scsi_alloc_request(sdev->request_queue, writing ?
			     REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0);
	if (IS_ERR(rq))
		return PTR_ERR(rq);
@@ -561,7 +561,7 @@ static int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk,

	}

	rq = blk_get_request(q, in_len ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0);
	rq = scsi_alloc_request(q, in_len ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0);
	if (IS_ERR(rq)) {
		err = PTR_ERR(rq);
		goto error_free_buffer;
Loading