mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 19:26:25 +00:00
[SCSI] aha1542: convert to accessors and !use_sg cleanup
- convert to accessors and !use_sg cleanup Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
This commit is contained in:
parent
cc0455fac0
commit
fc3fdfcc8b
1 changed files with 10 additions and 35 deletions
|
@ -51,15 +51,6 @@
|
|||
#define SCSI_BUF_PA(address) isa_virt_to_bus(address)
|
||||
#define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset)
|
||||
|
||||
static void BAD_DMA(void *address, unsigned int length)
|
||||
{
|
||||
printk(KERN_CRIT "buf vaddress %p paddress 0x%lx length %d\n",
|
||||
address,
|
||||
SCSI_BUF_PA(address),
|
||||
length);
|
||||
panic("Buffer at physical address > 16Mb used for aha1542");
|
||||
}
|
||||
|
||||
static void BAD_SG_DMA(Scsi_Cmnd * SCpnt,
|
||||
struct scatterlist *sgp,
|
||||
int nseg,
|
||||
|
@ -597,8 +588,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
|
|||
unchar target = SCpnt->device->id;
|
||||
unchar lun = SCpnt->device->lun;
|
||||
unsigned long flags;
|
||||
void *buff = SCpnt->request_buffer;
|
||||
int bufflen = SCpnt->request_bufflen;
|
||||
int bufflen = scsi_bufflen(SCpnt);
|
||||
int mbo;
|
||||
struct mailbox *mb;
|
||||
struct ccb *ccb;
|
||||
|
@ -689,42 +679,29 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
|
|||
|
||||
memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen);
|
||||
|
||||
if (SCpnt->use_sg) {
|
||||
if (bufflen) {
|
||||
struct scatterlist *sg;
|
||||
struct chain *cptr;
|
||||
#ifdef DEBUG
|
||||
unsigned char *ptr;
|
||||
#endif
|
||||
int i;
|
||||
int i, sg_count = scsi_sg_count(SCpnt);
|
||||
ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */
|
||||
SCpnt->host_scribble = kmalloc(512, GFP_KERNEL | GFP_DMA);
|
||||
SCpnt->host_scribble = kmalloc(sizeof(*cptr)*sg_count,
|
||||
GFP_KERNEL | GFP_DMA);
|
||||
cptr = (struct chain *) SCpnt->host_scribble;
|
||||
if (cptr == NULL) {
|
||||
/* free the claimed mailbox slot */
|
||||
HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL;
|
||||
return SCSI_MLQUEUE_HOST_BUSY;
|
||||
}
|
||||
scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) {
|
||||
if (sg->length == 0 || SCpnt->use_sg > 16 ||
|
||||
(((int) sg->offset) & 1) || (sg->length & 1)) {
|
||||
unsigned char *ptr;
|
||||
printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i);
|
||||
scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) {
|
||||
printk(KERN_CRIT "%d: %p %d\n", i,
|
||||
sg_virt(sg), sg->length);
|
||||
};
|
||||
printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr);
|
||||
ptr = (unsigned char *) &cptr[i];
|
||||
for (i = 0; i < 18; i++)
|
||||
printk("%02x ", ptr[i]);
|
||||
panic("Foooooooood fight!");
|
||||
};
|
||||
scsi_for_each_sg(SCpnt, sg, sg_count, i) {
|
||||
any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg));
|
||||
if (SCSI_SG_PA(sg) + sg->length - 1 > ISA_DMA_THRESHOLD)
|
||||
BAD_SG_DMA(SCpnt, sg, SCpnt->use_sg, i);
|
||||
BAD_SG_DMA(SCpnt, scsi_sglist(SCpnt), sg_count, i);
|
||||
any2scsi(cptr[i].datalen, sg->length);
|
||||
};
|
||||
any2scsi(ccb[mbo].datalen, SCpnt->use_sg * sizeof(struct chain));
|
||||
any2scsi(ccb[mbo].datalen, sg_count * sizeof(struct chain));
|
||||
any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr));
|
||||
#ifdef DEBUG
|
||||
printk("cptr %x: ", cptr);
|
||||
|
@ -735,10 +712,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
|
|||
} else {
|
||||
ccb[mbo].op = 0; /* SCSI Initiator Command */
|
||||
SCpnt->host_scribble = NULL;
|
||||
any2scsi(ccb[mbo].datalen, bufflen);
|
||||
if (buff && SCSI_BUF_PA(buff + bufflen - 1) > ISA_DMA_THRESHOLD)
|
||||
BAD_DMA(buff, bufflen);
|
||||
any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(buff));
|
||||
any2scsi(ccb[mbo].datalen, 0);
|
||||
any2scsi(ccb[mbo].dataptr, 0);
|
||||
};
|
||||
ccb[mbo].idlun = (target & 7) << 5 | direction | (lun & 7); /*SCSI Target Id */
|
||||
ccb[mbo].rsalen = 16;
|
||||
|
|
Loading…
Reference in a new issue