ieee1394: sbp2: use correct size of command descriptor block

Boaz Harrosh wrote:
> cmd->cmd_len is now guarantied to be set properly at all cases.
> And some commands you want to support will not be set correctly
> by COMMAND_SIZE().

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
This commit is contained in:
Stefan Richter 2008-05-04 16:54:14 +02:00
parent 424de91dd6
commit 93c596f7d6

View File

@ -1539,15 +1539,13 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
static void sbp2_create_command_orb(struct sbp2_lu *lu, static void sbp2_create_command_orb(struct sbp2_lu *lu,
struct sbp2_command_info *cmd, struct sbp2_command_info *cmd,
unchar *scsi_cmd, struct scsi_cmnd *SCpnt)
unsigned int scsi_use_sg,
unsigned int scsi_request_bufflen,
struct scatterlist *sg,
enum dma_data_direction dma_dir)
{ {
struct sbp2_fwhost_info *hi = lu->hi; struct sbp2_fwhost_info *hi = lu->hi;
struct sbp2_command_orb *orb = &cmd->command_orb; struct sbp2_command_orb *orb = &cmd->command_orb;
u32 orb_direction; u32 orb_direction;
unsigned int scsi_request_bufflen = scsi_bufflen(SCpnt);
enum dma_data_direction dma_dir = SCpnt->sc_data_direction;
/* /*
* Set-up our command ORB. * Set-up our command ORB.
@ -1580,13 +1578,14 @@ static void sbp2_create_command_orb(struct sbp2_lu *lu,
orb->data_descriptor_lo = 0x0; orb->data_descriptor_lo = 0x0;
orb->misc |= ORB_SET_DIRECTION(1); orb->misc |= ORB_SET_DIRECTION(1);
} else } else
sbp2_prep_command_orb_sg(orb, hi, cmd, scsi_use_sg, sg, sbp2_prep_command_orb_sg(orb, hi, cmd, scsi_sg_count(SCpnt),
scsi_sglist(SCpnt),
orb_direction, dma_dir); orb_direction, dma_dir);
sbp2util_cpu_to_be32_buffer(orb, sizeof(*orb)); sbp2util_cpu_to_be32_buffer(orb, sizeof(*orb));
memset(orb->cdb, 0, 12); memset(orb->cdb, 0, sizeof(orb->cdb));
memcpy(orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd)); memcpy(orb->cdb, SCpnt->cmnd, SCpnt->cmd_len);
} }
static void sbp2_link_orb_command(struct sbp2_lu *lu, static void sbp2_link_orb_command(struct sbp2_lu *lu,
@ -1669,16 +1668,13 @@ static void sbp2_link_orb_command(struct sbp2_lu *lu,
static int sbp2_send_command(struct sbp2_lu *lu, struct scsi_cmnd *SCpnt, static int sbp2_send_command(struct sbp2_lu *lu, struct scsi_cmnd *SCpnt,
void (*done)(struct scsi_cmnd *)) void (*done)(struct scsi_cmnd *))
{ {
unchar *scsi_cmd = (unchar *)SCpnt->cmnd;
struct sbp2_command_info *cmd; struct sbp2_command_info *cmd;
cmd = sbp2util_allocate_command_orb(lu, SCpnt, done); cmd = sbp2util_allocate_command_orb(lu, SCpnt, done);
if (!cmd) if (!cmd)
return -EIO; return -EIO;
sbp2_create_command_orb(lu, cmd, scsi_cmd, scsi_sg_count(SCpnt), sbp2_create_command_orb(lu, cmd, SCpnt);
scsi_bufflen(SCpnt), scsi_sglist(SCpnt),
SCpnt->sc_data_direction);
sbp2_link_orb_command(lu, cmd); sbp2_link_orb_command(lu, cmd);
return 0; return 0;