diff mbox series

[v2,2/3] ata: libata-sata: Simplify sense_valid fetching

Message ID 20250415073013.414987-7-cassel@kernel.org
State New
Headers show
Series Successful NCQ commands sense_valid cleanups/fixes | expand

Commit Message

Niklas Cassel April 15, 2025, 7:30 a.m. UTC
While the SENSE DATA VALID field in the ACS-6 specification is 47 bits,
we are currently only fetching 32 bits, because these are the only bits
that we care about (these bits represent the tags (which can be 0-31)).

Thus, replace the existing logic with a simple get_unaligned_le32().

While at it, change the type of sense_valid to u32.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
---
 drivers/ata/libata-sata.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Igor Pylypiv April 15, 2025, 6:03 p.m. UTC | #1
On Tue, Apr 15, 2025 at 09:30:16AM +0200, Niklas Cassel wrote:
> While the SENSE DATA VALID field in the ACS-6 specification is 47 bits,
> we are currently only fetching 32 bits, because these are the only bits
> that we care about (these bits represent the tags (which can be 0-31)).
> 
> Thus, replace the existing logic with a simple get_unaligned_le32().
> 
> While at it, change the type of sense_valid to u32.
> 
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> Reviewed-by: Hannes Reinecke <hare@suse.de>

Reviewed-by: Igor Pylypiv <ipylypiv@google.com>
diff mbox series

Patch

diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
index 2e4463d3a356..076953d18db9 100644
--- a/drivers/ata/libata-sata.c
+++ b/drivers/ata/libata-sata.c
@@ -1509,9 +1509,10 @@  int ata_eh_get_ncq_success_sense(struct ata_link *link)
 	struct ata_queued_cmd *qc;
 	unsigned int err_mask, tag;
 	u8 *sense, sk = 0, asc = 0, ascq = 0;
-	u64 sense_valid, val;
 	u16 extended_sense;
 	bool aux_icc_valid;
+	u32 sense_valid;
+	u64 val;
 	int ret = 0;
 
 	err_mask = ata_read_log_page(dev, ATA_LOG_SENSE_NCQ, 0, buf, 2);
@@ -1529,8 +1530,7 @@  int ata_eh_get_ncq_success_sense(struct ata_link *link)
 		return -EIO;
 	}
 
-	sense_valid = (u64)buf[8] | ((u64)buf[9] << 8) |
-		((u64)buf[10] << 16) | ((u64)buf[11] << 24);
+	sense_valid = get_unaligned_le32(&buf[8]);
 	extended_sense = get_unaligned_le16(&buf[14]);
 	aux_icc_valid = extended_sense & BIT(15);