diff mbox series

[v3,10/18] ata: libata-scsi: remove unnecessary !cmd checks

Message ID 20230124190308.127318-11-niklas.cassel@wdc.com (mailing list archive)
State New, archived
Headers show
Series Add Command Duration Limits support | expand

Commit Message

Niklas Cassel Jan. 24, 2023, 7:02 p.m. UTC
There is no need to check if !cmd as this can only happen for
ATA internal commands which uses the ATA internal tag (32).

Most users of ata_scsi_set_sense() are from _xlat functions that
translate a scsicmd to an ATA command. These obviously have a qc->scsicmd.

ata_scsi_qc_complete() can also call ata_scsi_set_sense() via
ata_gen_passthru_sense() / ata_gen_ata_sense(), called via
ata_scsi_qc_complete(). This callback is only called for translated
commands, so it also has a qc->scsicmd.

ata_eh_analyze_ncq_error(): the NCQ error log can only contain a 0-31
value, so it will never be able to get the ATA internal tag (32).

ata_eh_request_sense(): only called by ata_eh_analyze_tf(), which
is only called when iteratating the QCs using ata_qc_for_each_raw(),
which does not include the internal tag.

Since there is no existing call site where cmd can be NULL, remove the
!cmd check from ata_scsi_set_sense() and ata_scsi_set_sense_information().

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
---
 drivers/ata/libata-scsi.c | 6 ------
 1 file changed, 6 deletions(-)

Comments

Hannes Reinecke Jan. 27, 2023, 3:35 p.m. UTC | #1
On 1/24/23 20:02, Niklas Cassel wrote:
> There is no need to check if !cmd as this can only happen for
> ATA internal commands which uses the ATA internal tag (32).
> 
> Most users of ata_scsi_set_sense() are from _xlat functions that
> translate a scsicmd to an ATA command. These obviously have a qc->scsicmd.
> 
> ata_scsi_qc_complete() can also call ata_scsi_set_sense() via
> ata_gen_passthru_sense() / ata_gen_ata_sense(), called via
> ata_scsi_qc_complete(). This callback is only called for translated
> commands, so it also has a qc->scsicmd.
> 
> ata_eh_analyze_ncq_error(): the NCQ error log can only contain a 0-31
> value, so it will never be able to get the ATA internal tag (32).
> 
> ata_eh_request_sense(): only called by ata_eh_analyze_tf(), which
> is only called when iteratating the QCs using ata_qc_for_each_raw(),
> which does not include the internal tag.
> 
> Since there is no existing call site where cmd can be NULL, remove the
> !cmd check from ata_scsi_set_sense() and ata_scsi_set_sense_information().
> 
> Suggested-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
> ---
>   drivers/ata/libata-scsi.c | 6 ------
>   1 file changed, 6 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
diff mbox series

Patch

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index e093c7a7deeb..26746609bf76 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -209,9 +209,6 @@  void ata_scsi_set_sense(struct ata_device *dev, struct scsi_cmnd *cmd,
 {
 	bool d_sense = (dev->flags & ATA_DFLAG_D_SENSE);
 
-	if (!cmd)
-		return;
-
 	scsi_build_sense(cmd, d_sense, sk, asc, ascq);
 }
 
@@ -221,9 +218,6 @@  void ata_scsi_set_sense_information(struct ata_device *dev,
 {
 	u64 information;
 
-	if (!cmd)
-		return;
-
 	information = ata_tf_read_block(tf, dev);
 	if (information == U64_MAX)
 		return;