From: tom.ty89@gmail.com
To: tj@kernel.org, sergei.shtylyov@cogentembedded.com
Cc: linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org,
Tom Yan <tom.ty89@gmail.com>
Subject: [PATCH v4] libata-scsi: better style in ata_msense_*()
Date: Wed, 20 Jul 2016 04:39:28 +0800 [thread overview]
Message-ID: <578e9008.4500420a.2d828.d131@mx.google.com> (raw)
In-Reply-To: <5784f28c.c4d0620a.69372.3df2@mx.google.com>
From: Tom Yan <tom.ty89@gmail.com>
`changeable` is the "version" of mode page requested by the user.
It will be less confusing/misleading if we do not check it
"together" with the setting bits of the drive.
Not to mention that we currently have ata_mselect_*() implemented
in a way that each of them will serve exclusively a particular bit
on each page. The old style will hence make the condition look even
more unnecessarily arcane if the ata_msense_*() is reflecting more
than one bit.
Signed-off-by: Tom Yan <tom.ty89@gmail.com>
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bf4cb21..b00521b 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2424,10 +2424,12 @@ static void modecpy(u8 *dest, const u8 *src, int n, bool changeable)
static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
{
modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable);
- if (changeable || ata_id_wcache_enabled(id))
- buf[2] |= (1 << 2); /* write cache enable */
- if (!changeable && !ata_id_rahead_enabled(id))
- buf[12] |= (1 << 5); /* disable read ahead */
+ if (changeable) {
+ buf[2] |= (1 << 2); /* ata_mselect_caching() */
+ } else {
+ buf[2] |= (ata_id_wcache_enabled(id) << 2); /* write cache enable */
+ buf[12] |= (!ata_id_rahead_enabled(id) << 5); /* disable read ahead */
+ }
return sizeof(def_cache_mpage);
}
@@ -2446,8 +2448,13 @@ static unsigned int ata_msense_control(struct ata_device *dev, u8 *buf,
bool changeable)
{
modecpy(buf, def_control_mpage, sizeof(def_control_mpage), changeable);
- if (changeable || (dev->flags & ATA_DFLAG_D_SENSE))
- buf[2] |= (1 << 2); /* Descriptor sense requested */
+ if (changeable) {
+ buf[2] |= (1 << 2); /* ata_mselect_control() */
+ } else {
+ bool d_sense = (dev->flags & ATA_DFLAG_D_SENSE);
+
+ buf[2] |= (d_sense << 2); /* descriptor format sense data */
+ }
return sizeof(def_control_mpage);
}
--
2.9.0
next prev parent reply other threads:[~2016-07-19 20:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20160712133703.2076-1-me>
2016-07-12 13:37 ` [PATCH v3 2/2] libata-scsi: better style in ata_msense_caching() tom.ty89
2016-07-12 14:48 ` Tejun Heo
2016-07-12 16:20 ` Tom Yan
2016-07-12 17:20 ` Tejun Heo
2016-07-12 17:54 ` Tom Yan
2016-07-19 20:39 ` tom.ty89 [this message]
2016-07-19 20:44 ` [PATCH v4] libata-scsi: better style in ata_msense_*() Tom Yan
2016-07-19 21:11 ` [PATCH v4] libata-scsi: minor cleanup in ata_mselect_*() tom.ty89
2016-07-19 22:50 ` [PATCH] libata-scsi: fix read-only bits checking " tom.ty89
2016-07-19 22:59 ` Tom Yan
2016-07-19 22:59 ` [PATCH v2] " tom.ty89
2016-07-20 15:25 ` Tejun Heo
2016-07-20 17:20 ` Tejun Heo
2016-07-19 23:03 ` [PATCH v4] libata-scsi: minor cleanup " Tom Yan
2016-07-20 15:22 ` Tejun Heo
2016-07-20 15:22 ` [PATCH v4] libata-scsi: better style in ata_msense_*() Tejun Heo
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=578e9008.4500420a.2d828.d131@mx.google.com \
--to=tom.ty89@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.