[SCSI] aacraid: use sg buffer copy helper functions
This replaces aac_internal_transfer with scsi_sg_copy_to/from_buffer. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: Mark Salyzyn <Mark_Salyzyn@adaptec.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
This commit is contained in:
committed by
James Bottomley
parent
6690bae7e0
commit
d4345028d4
@@ -379,24 +379,6 @@ int aac_get_containers(struct aac_dev *dev)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void aac_internal_transfer(struct scsi_cmnd *scsicmd, void *data, unsigned int offset, unsigned int len)
|
|
||||||
{
|
|
||||||
void *buf;
|
|
||||||
int transfer_len;
|
|
||||||
struct scatterlist *sg = scsi_sglist(scsicmd);
|
|
||||||
|
|
||||||
buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
|
|
||||||
transfer_len = min(sg->length, len + offset);
|
|
||||||
|
|
||||||
transfer_len -= offset;
|
|
||||||
if (buf && transfer_len > 0)
|
|
||||||
memcpy(buf + offset, data, transfer_len);
|
|
||||||
|
|
||||||
flush_kernel_dcache_page(kmap_atomic_to_page(buf - sg->offset));
|
|
||||||
kunmap_atomic(buf - sg->offset, KM_IRQ0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void get_container_name_callback(void *context, struct fib * fibptr)
|
static void get_container_name_callback(void *context, struct fib * fibptr)
|
||||||
{
|
{
|
||||||
struct aac_get_name_resp * get_name_reply;
|
struct aac_get_name_resp * get_name_reply;
|
||||||
@@ -419,14 +401,17 @@ static void get_container_name_callback(void *context, struct fib * fibptr)
|
|||||||
while (*sp == ' ')
|
while (*sp == ' ')
|
||||||
++sp;
|
++sp;
|
||||||
if (*sp) {
|
if (*sp) {
|
||||||
|
struct inquiry_data inq;
|
||||||
char d[sizeof(((struct inquiry_data *)NULL)->inqd_pid)];
|
char d[sizeof(((struct inquiry_data *)NULL)->inqd_pid)];
|
||||||
int count = sizeof(d);
|
int count = sizeof(d);
|
||||||
char *dp = d;
|
char *dp = d;
|
||||||
do {
|
do {
|
||||||
*dp++ = (*sp) ? *sp++ : ' ';
|
*dp++ = (*sp) ? *sp++ : ' ';
|
||||||
} while (--count > 0);
|
} while (--count > 0);
|
||||||
aac_internal_transfer(scsicmd, d,
|
|
||||||
offsetof(struct inquiry_data, inqd_pid), sizeof(d));
|
scsi_sg_copy_to_buffer(scsicmd, &inq, sizeof(inq));
|
||||||
|
memcpy(inq.inqd_pid, d, sizeof(d));
|
||||||
|
scsi_sg_copy_from_buffer(scsicmd, &inq, sizeof(inq));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -811,7 +796,7 @@ static void get_container_serial_callback(void *context, struct fib * fibptr)
|
|||||||
sp[2] = 0;
|
sp[2] = 0;
|
||||||
sp[3] = snprintf(sp+4, sizeof(sp)-4, "%08X",
|
sp[3] = snprintf(sp+4, sizeof(sp)-4, "%08X",
|
||||||
le32_to_cpu(get_serial_reply->uid));
|
le32_to_cpu(get_serial_reply->uid));
|
||||||
aac_internal_transfer(scsicmd, sp, 0, sizeof(sp));
|
scsi_sg_copy_from_buffer(scsicmd, sp, sizeof(sp));
|
||||||
}
|
}
|
||||||
|
|
||||||
scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
|
scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
|
||||||
@@ -1986,8 +1971,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
|
|||||||
arr[4] = 0x0;
|
arr[4] = 0x0;
|
||||||
arr[5] = 0x80;
|
arr[5] = 0x80;
|
||||||
arr[1] = scsicmd->cmnd[2];
|
arr[1] = scsicmd->cmnd[2];
|
||||||
aac_internal_transfer(scsicmd, &inq_data, 0,
|
scsi_sg_copy_from_buffer(scsicmd, &inq_data,
|
||||||
sizeof(inq_data));
|
sizeof(inq_data));
|
||||||
scsicmd->result = DID_OK << 16 |
|
scsicmd->result = DID_OK << 16 |
|
||||||
COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
|
COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
|
||||||
} else if (scsicmd->cmnd[2] == 0x80) {
|
} else if (scsicmd->cmnd[2] == 0x80) {
|
||||||
@@ -1995,8 +1980,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
|
|||||||
arr[3] = setinqserial(dev, &arr[4],
|
arr[3] = setinqserial(dev, &arr[4],
|
||||||
scmd_id(scsicmd));
|
scmd_id(scsicmd));
|
||||||
arr[1] = scsicmd->cmnd[2];
|
arr[1] = scsicmd->cmnd[2];
|
||||||
aac_internal_transfer(scsicmd, &inq_data, 0,
|
scsi_sg_copy_from_buffer(scsicmd, &inq_data,
|
||||||
sizeof(inq_data));
|
sizeof(inq_data));
|
||||||
return aac_get_container_serial(scsicmd);
|
return aac_get_container_serial(scsicmd);
|
||||||
} else {
|
} else {
|
||||||
/* vpd page not implemented */
|
/* vpd page not implemented */
|
||||||
@@ -2027,7 +2012,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
|
|||||||
if (cid == host->this_id) {
|
if (cid == host->this_id) {
|
||||||
setinqstr(dev, (void *) (inq_data.inqd_vid), ARRAY_SIZE(container_types));
|
setinqstr(dev, (void *) (inq_data.inqd_vid), ARRAY_SIZE(container_types));
|
||||||
inq_data.inqd_pdt = INQD_PDT_PROC; /* Processor device */
|
inq_data.inqd_pdt = INQD_PDT_PROC; /* Processor device */
|
||||||
aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));
|
scsi_sg_copy_from_buffer(scsicmd, &inq_data,
|
||||||
|
sizeof(inq_data));
|
||||||
scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
|
scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
|
||||||
scsicmd->scsi_done(scsicmd);
|
scsicmd->scsi_done(scsicmd);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -2036,7 +2022,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
|
|||||||
return -1;
|
return -1;
|
||||||
setinqstr(dev, (void *) (inq_data.inqd_vid), fsa_dev_ptr[cid].type);
|
setinqstr(dev, (void *) (inq_data.inqd_vid), fsa_dev_ptr[cid].type);
|
||||||
inq_data.inqd_pdt = INQD_PDT_DA; /* Direct/random access device */
|
inq_data.inqd_pdt = INQD_PDT_DA; /* Direct/random access device */
|
||||||
aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));
|
scsi_sg_copy_from_buffer(scsicmd, &inq_data, sizeof(inq_data));
|
||||||
return aac_get_container_name(scsicmd);
|
return aac_get_container_name(scsicmd);
|
||||||
}
|
}
|
||||||
case SERVICE_ACTION_IN:
|
case SERVICE_ACTION_IN:
|
||||||
@@ -2070,8 +2056,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
|
|||||||
+ (scsicmd->cmnd[12] << 8) + scsicmd->cmnd[13]);
|
+ (scsicmd->cmnd[12] << 8) + scsicmd->cmnd[13]);
|
||||||
|
|
||||||
alloc_len = min_t(size_t, alloc_len, sizeof(cp));
|
alloc_len = min_t(size_t, alloc_len, sizeof(cp));
|
||||||
aac_internal_transfer(scsicmd, cp, 0, alloc_len);
|
scsi_sg_copy_from_buffer(scsicmd, cp, alloc_len);
|
||||||
|
|
||||||
if (alloc_len < scsi_bufflen(scsicmd))
|
if (alloc_len < scsi_bufflen(scsicmd))
|
||||||
scsi_set_resid(scsicmd,
|
scsi_set_resid(scsicmd,
|
||||||
scsi_bufflen(scsicmd) - alloc_len);
|
scsi_bufflen(scsicmd) - alloc_len);
|
||||||
@@ -2104,7 +2089,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
|
|||||||
cp[5] = 0;
|
cp[5] = 0;
|
||||||
cp[6] = 2;
|
cp[6] = 2;
|
||||||
cp[7] = 0;
|
cp[7] = 0;
|
||||||
aac_internal_transfer(scsicmd, cp, 0, sizeof(cp));
|
scsi_sg_copy_from_buffer(scsicmd, cp, sizeof(cp));
|
||||||
/* Do not cache partition table for arrays */
|
/* Do not cache partition table for arrays */
|
||||||
scsicmd->device->removable = 1;
|
scsicmd->device->removable = 1;
|
||||||
|
|
||||||
@@ -2139,7 +2124,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
|
|||||||
if (mode_buf_length > scsicmd->cmnd[4])
|
if (mode_buf_length > scsicmd->cmnd[4])
|
||||||
mode_buf_length = scsicmd->cmnd[4];
|
mode_buf_length = scsicmd->cmnd[4];
|
||||||
}
|
}
|
||||||
aac_internal_transfer(scsicmd, mode_buf, 0, mode_buf_length);
|
scsi_sg_copy_from_buffer(scsicmd, mode_buf, mode_buf_length);
|
||||||
scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
|
scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
|
||||||
scsicmd->scsi_done(scsicmd);
|
scsicmd->scsi_done(scsicmd);
|
||||||
|
|
||||||
@@ -2174,7 +2159,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
|
|||||||
if (mode_buf_length > scsicmd->cmnd[8])
|
if (mode_buf_length > scsicmd->cmnd[8])
|
||||||
mode_buf_length = scsicmd->cmnd[8];
|
mode_buf_length = scsicmd->cmnd[8];
|
||||||
}
|
}
|
||||||
aac_internal_transfer(scsicmd, mode_buf, 0, mode_buf_length);
|
scsi_sg_copy_from_buffer(scsicmd, mode_buf, mode_buf_length);
|
||||||
|
|
||||||
scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
|
scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
|
||||||
scsicmd->scsi_done(scsicmd);
|
scsicmd->scsi_done(scsicmd);
|
||||||
|
Reference in New Issue
Block a user