From: Patrick Mansfield <patmans@us.ibm.com>
To: Jens Axboe <axboe@suse.de>, linux-scsi@vger.kernel.org
Subject: [PATCH] add scsi_cmd_ioctl (SG_IO) support for st
Date: Sun, 1 Feb 2004 12:50:31 -0800 [thread overview]
Message-ID: <20040201125031.A18128@beaverton.ibm.com> (raw)
In-Reply-To: <20040201124803.A18050@beaverton.ibm.com>; from patmans@us.ibm.com on Sun, Feb 01, 2004 at 12:48:03PM -0800
Add SG_IO support for st, so we can send scsi commands directly to an st
device.
Though st (still?) needs to move to move away from cdev for udev to
function with it.
diff -uprN -X /home/patman/dontdiff bk-2.6.2-rc3/drivers/scsi/st.c char_sg_io-bk-2.6.2-rc3/drivers/scsi/st.c
--- bk-2.6.2-rc3/drivers/scsi/st.c Mon Jan 5 08:46:42 2004
+++ char_sg_io-bk-2.6.2-rc3/drivers/scsi/st.c Sun Feb 1 11:53:03 2004
@@ -179,6 +179,7 @@ static int sgl_unmap_user_pages(struct s
static int st_probe(struct device *);
static int st_remove(struct device *);
+static int st_init_command(struct scsi_cmnd *);
static void do_create_driverfs_files(void);
static void do_remove_driverfs_files(void);
@@ -191,6 +192,7 @@ static struct scsi_driver st_template =
.probe = st_probe,
.remove = st_remove,
},
+ .init_command = st_init_command,
};
static int st_compression(Scsi_Tape *, int);
@@ -3389,7 +3391,11 @@ static int st_ioctl(struct inode *inode,
goto out;
}
up(&STp->lock);
- return scsi_ioctl(STp->device, cmd_in, (void *) arg);
+ i = scsi_cmd_ioctl(STp->disk, cmd_in, arg);
+ if (i != -ENOTTY)
+ return i;
+ else
+ return scsi_ioctl(STp->device, cmd_in, (void *) arg);
out:
up(&STp->lock);
@@ -3796,6 +3802,7 @@ static int st_probe(struct device *dev)
tpnt->disk = disk;
sprintf(disk->disk_name, "st%d", i);
disk->private_data = &tpnt->driver;
+ disk->queue = SDp->request_queue;
tpnt->driver = &st_template;
scsi_tapes[i] = tpnt;
dev_num = i;
@@ -3983,6 +3990,41 @@ static int st_remove(struct device *dev)
write_unlock(&st_dev_arr_lock);
return 0;
+}
+
+static void st_intr(struct scsi_cmnd *SCpnt)
+{
+ scsi_io_completion(SCpnt, (SCpnt->result ? 0: SCpnt->bufflen >> 9), 1);
+}
+
+/*
+ * st_init_command: only called via the scsi_cmd_ioctl (block SG_IO)
+ * interface for REQ_BLOCK_PC commands.
+ */
+static int st_init_command(struct scsi_cmnd *SCpnt)
+{
+ struct request *rq;
+
+ if (!(SCpnt->request->flags & REQ_BLOCK_PC))
+ return 0;
+
+ rq = SCpnt->request;
+ if (sizeof(rq->cmd) > sizeof(SCpnt->cmnd))
+ return 0;
+
+ memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
+
+ if (rq_data_dir(rq) == WRITE)
+ SCpnt->sc_data_direction = DMA_TO_DEVICE;
+ else if (rq->data_len)
+ SCpnt->sc_data_direction = DMA_FROM_DEVICE;
+ else
+ SCpnt->sc_data_direction = DMA_NONE;
+
+ SCpnt->timeout_per_command = rq->timeout;
+ SCpnt->transfersize = rq->data_len;
+ SCpnt->done = st_intr;
+ return 1;
}
static int __init init_st(void)
next prev parent reply other threads:[~2004-02-01 20:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-01 20:48 [PATCH] change scsi_cmd_ioctl to take a gendisk instead of a queue Patrick Mansfield
2004-02-01 20:50 ` Patrick Mansfield [this message]
2004-02-01 21:35 ` [PATCH] add scsi_cmd_ioctl (SG_IO) support for st Christoph Hellwig
2004-02-01 21:51 ` Patrick Mansfield
2004-02-01 22:28 ` Willem Riede
2004-02-01 22:36 ` Christoph Hellwig
2004-02-01 21:33 ` [PATCH] change scsi_cmd_ioctl to take a gendisk instead of a queue Christoph Hellwig
2004-02-01 21:49 ` Patrick Mansfield
2004-02-01 22:13 ` Christoph Hellwig
2004-02-02 13:27 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040201125031.A18128@beaverton.ibm.com \
--to=patmans@us.ibm.com \
--cc=axboe@suse.de \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox