Re: [PATCH] ide/libata: fix ata_id_is_cfa()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

Alan Cox wrote:

This patch keeps the version checks but incorporates the other suggestions
Sergei made including a better ata version check for the usual case where
we want to know "is version >= x" rather than "what version do you
support".

Signed-off-by: Alan Cox <alan@xxxxxxxxxxxxxxxxxxx>
[...]
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 88c2428..c17b62a 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2212,7 +2212,7 @@ retry:
 		 * Note that ATA4 says lba is mandatory so the second check
 		 * shoud never trigger.
 		 */
-		if (ata_id_major_version(id) < 4 || !ata_id_has_lba(id)) {
+		if (!ata_id_has_version(id, 4) || !ata_id_has_lba(id)) {
 			err_mask = ata_dev_init_params(dev, id[3], id[6]);
 			if (err_mask) {
 				rc = -EIO;
diff --git a/include/linux/ata.h b/include/linux/ata.h
index a53318b..e35d8de 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -675,6 +675,13 @@ static inline unsigned int ata_id_major_version(const u16 *id)
 	return mver;
 }
+static inline int ata_id_has_version(const u16 *id, int v)
+{
+	if (id[ATA_ID_MAJOR_VER] == 0xFFFF)
+		return 0;
+	return (id[ATA_ID_MAJOR_VER] & (1 << v)) ? 1 : 0;
+}
+ @@ -691,7 +698,7 @@ static inline int ata_id_is_sata(const u16 *id)
 static inline int ata_id_has_tpm(const u16 *id)
 {
 	/* The TPM bits are only valid on ATA8 */
-	if (ata_id_major_version(id) < 8)
+	if (!ata_id_has_version(id, 8))
 		return 0;

Note that this is not equivalent to the old code which didn't require the bit v to be set, just some bits above it.

MBR, Sergei


--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux