scsi: ata: libata-scsi: Remove unnecessary !cmd checks
authorNiklas Cassel <niklas.cassel@wdc.com>
Thu, 11 May 2023 01:13:45 +0000 (03:13 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 22 May 2023 21:05:19 +0000 (17:05 -0400)
commit91a8967ca7f4b8eabe021b1ba974a992cfca2a07
tree6491eaf20de82d216ab6cea6ac777a6c7cb66e82
parent390e2d1a587405a522dc6b433d45648f895a352c
scsi: ata: libata-scsi: Remove unnecessary !cmd checks

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>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Link: https://lore.kernel.org/r/20230511011356.227789-13-nks@flawful.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ata/libata-scsi.c