From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: bzolnier@gmail.com, jgarzik@pobox.com, linux-ide@vger.kernel.org,
gdu@mns.spb.ru
Subject: Re: [PATCH] ide/libata: fix ata_id_is_cfa()
Date: Tue, 27 Jan 2009 14:29:51 +0300 [thread overview]
Message-ID: <497EF02F.4060109@ru.mvista.com> (raw)
In-Reply-To: <20090126190801.7d198246@lxorguk.ukuu.org.uk>
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@lxorguk.ukuu.org.uk>
>
[...]
> 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
prev parent reply other threads:[~2009-01-27 11:29 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-23 13:15 [PATCH] ide/libata: fix ata_id_is_cfa() Sergei Shtylyov
2009-01-23 13:33 ` Alan Cox
2009-01-23 13:53 ` Sergei Shtylyov
2009-01-23 15:43 ` Alan Cox
2009-01-23 16:30 ` Sergei Shtylyov
2009-01-23 16:41 ` Alan Cox
2009-01-23 17:01 ` Sergei Shtylyov
2009-01-23 17:12 ` Mark Lord
2009-01-23 17:18 ` Sergei Shtylyov
2009-01-23 17:27 ` Sergei Shtylyov
2009-01-23 17:53 ` Alan Cox
2009-01-23 19:13 ` Sergei Shtylyov
2009-01-24 23:06 ` Sergei Shtylyov
2009-01-25 10:50 ` Alan Cox
2009-01-26 11:49 ` Sergei Shtylyov
2009-01-26 12:01 ` Alan Cox
2009-01-26 18:11 ` Sergei Shtylyov
2009-01-26 19:01 ` Alan Cox
2009-01-26 19:25 ` Sergei Shtylyov
2009-01-25 10:52 ` Alan Cox
2009-01-25 19:04 ` Bartlomiej Zolnierkiewicz
2009-01-26 19:32 ` Sergei Shtylyov
2009-01-26 18:47 ` Sergei Shtylyov
2009-01-26 19:08 ` Alan Cox
2009-01-26 19:28 ` Sergei Shtylyov
2009-01-26 19:33 ` Sergei Shtylyov
2009-01-26 19:41 ` Alan Cox
2009-01-26 19:42 ` Alan Cox
2009-01-26 19:56 ` Sergei Shtylyov
2009-01-26 20:01 ` Alan Cox
2009-01-26 20:31 ` Sergei Shtylyov
2009-01-26 20:59 ` Sergei Shtylyov
2009-01-26 21:22 ` Alan Cox
2009-01-26 21:38 ` Sergei Shtylyov
2009-01-26 21:43 ` Sergei Shtylyov
2009-01-26 23:28 ` Sergei Shtylyov
2009-01-26 20:47 ` Sergei Shtylyov
2009-01-26 19:39 ` Alan Cox
2009-01-26 19:31 ` Sergei Shtylyov
2009-01-26 19:35 ` Alan Cox
2009-01-26 19:45 ` Sergei Shtylyov
2009-01-26 19:54 ` Alan Cox
2009-01-26 20:03 ` Sergei Shtylyov
2009-01-26 20:12 ` Jeff Garzik
2009-01-26 20:23 ` Sergei Shtylyov
2009-01-26 20:33 ` Alan Cox
2009-01-26 20:41 ` Sergei Shtylyov
2009-01-26 23:53 ` Sergei Shtylyov
2009-01-26 20:16 ` Sergei Shtylyov
2009-01-27 11:29 ` Sergei Shtylyov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=497EF02F.4060109@ru.mvista.com \
--to=sshtylyov@ru.mvista.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=bzolnier@gmail.com \
--cc=gdu@mns.spb.ru \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).