aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-01-10 03:41:46 -0500
committerTejun Heo <tj@kernel.org>2017-01-10 10:55:40 -0500
commit8fc6c0657bf852766f08d389c5c3378a032b3de7 (patch)
treeae8905020f8e592679701e0db0ed12da0f9f8bbb
parent506db3609cdf30b0ff661e8e38e95e91c54fbb82 (diff)
libata: call ->scsi_done from ata_scsi_simulate
We always need to call ->scsi_done after we've finished emulating a command, so do it in a single place at the end of ata_scsi_simulate. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--drivers/ata/libata-scsi.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 28e2530b9cd3..6078bc28b325 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -484,13 +484,6 @@ struct device_attribute *ata_common_sdev_attrs[] = {
484}; 484};
485EXPORT_SYMBOL_GPL(ata_common_sdev_attrs); 485EXPORT_SYMBOL_GPL(ata_common_sdev_attrs);
486 486
487static void ata_scsi_invalid_field(struct ata_device *dev,
488 struct scsi_cmnd *cmd, u16 field)
489{
490 ata_scsi_set_invalid_field(dev, cmd, field, 0xff);
491 cmd->scsi_done(cmd);
492}
493
494/** 487/**
495 * ata_std_bios_param - generic bios head/sector/cylinder calculator used by sd. 488 * ata_std_bios_param - generic bios head/sector/cylinder calculator used by sd.
496 * @sdev: SCSI device for which BIOS geometry is to be determined 489 * @sdev: SCSI device for which BIOS geometry is to be determined
@@ -2139,7 +2132,6 @@ static void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
2139 2132
2140 if (rc == 0) 2133 if (rc == 0)
2141 cmd->result = SAM_STAT_GOOD; 2134 cmd->result = SAM_STAT_GOOD;
2142 cmd->scsi_done(cmd);
2143} 2135}
2144 2136
2145/** 2137/**
@@ -4360,7 +4352,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
4360 switch(scsicmd[0]) { 4352 switch(scsicmd[0]) {
4361 case INQUIRY: 4353 case INQUIRY:
4362 if (scsicmd[1] & 2) /* is CmdDt set? */ 4354 if (scsicmd[1] & 2) /* is CmdDt set? */
4363 ata_scsi_invalid_field(dev, cmd, 1); 4355 ata_scsi_set_invalid_field(dev, cmd, 1, 0xff);
4364 else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */ 4356 else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */
4365 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std); 4357 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std);
4366 else switch (scsicmd[2]) { 4358 else switch (scsicmd[2]) {
@@ -4392,7 +4384,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
4392 } 4384 }
4393 /* Fallthrough */ 4385 /* Fallthrough */
4394 default: 4386 default:
4395 ata_scsi_invalid_field(dev, cmd, 2); 4387 ata_scsi_set_invalid_field(dev, cmd, 2, 0xff);
4396 break; 4388 break;
4397 } 4389 }
4398 break; 4390 break;
@@ -4410,7 +4402,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
4410 if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16) 4402 if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16)
4411 ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); 4403 ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap);
4412 else 4404 else
4413 ata_scsi_invalid_field(dev, cmd, 1); 4405 ata_scsi_set_invalid_field(dev, cmd, 1, 0xff);
4414 break; 4406 break;
4415 4407
4416 case REPORT_LUNS: 4408 case REPORT_LUNS:
@@ -4420,7 +4412,6 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
4420 case REQUEST_SENSE: 4412 case REQUEST_SENSE:
4421 ata_scsi_set_sense(dev, cmd, 0, 0, 0); 4413 ata_scsi_set_sense(dev, cmd, 0, 0, 0);
4422 cmd->result = (DRIVER_SENSE << 24); 4414 cmd->result = (DRIVER_SENSE << 24);
4423 cmd->scsi_done(cmd);
4424 break; 4415 break;
4425 4416
4426 /* if we reach this, then writeback caching is disabled, 4417 /* if we reach this, then writeback caching is disabled,
@@ -4442,23 +4433,24 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
4442 if ((tmp8 == 0x4) && (!scsicmd[3]) && (!scsicmd[4])) 4433 if ((tmp8 == 0x4) && (!scsicmd[3]) && (!scsicmd[4]))
4443 ata_scsi_rbuf_fill(&args, ata_scsiop_noop); 4434 ata_scsi_rbuf_fill(&args, ata_scsiop_noop);
4444 else 4435 else
4445 ata_scsi_invalid_field(dev, cmd, 1); 4436 ata_scsi_set_invalid_field(dev, cmd, 1, 0xff);
4446 break; 4437 break;
4447 4438
4448 case MAINTENANCE_IN: 4439 case MAINTENANCE_IN:
4449 if (scsicmd[1] == MI_REPORT_SUPPORTED_OPERATION_CODES) 4440 if (scsicmd[1] == MI_REPORT_SUPPORTED_OPERATION_CODES)
4450 ata_scsi_rbuf_fill(&args, ata_scsiop_maint_in); 4441 ata_scsi_rbuf_fill(&args, ata_scsiop_maint_in);
4451 else 4442 else
4452 ata_scsi_invalid_field(dev, cmd, 1); 4443 ata_scsi_set_invalid_field(dev, cmd, 1, 0xff);
4453 break; 4444 break;
4454 4445
4455 /* all other commands */ 4446 /* all other commands */
4456 default: 4447 default:
4457 ata_scsi_set_sense(dev, cmd, ILLEGAL_REQUEST, 0x20, 0x0); 4448 ata_scsi_set_sense(dev, cmd, ILLEGAL_REQUEST, 0x20, 0x0);
4458 /* "Invalid command operation code" */ 4449 /* "Invalid command operation code" */
4459 cmd->scsi_done(cmd);
4460 break; 4450 break;
4461 } 4451 }
4452
4453 cmd->scsi_done(cmd);
4462} 4454}
4463 4455
4464int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht) 4456int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht)