From: Vishal Verma <vishal.l.verma@intel.com>
To: linux-nvdimm@lists.01.org
Cc: linux-acpi@vger.kernel.org,
Dan Williams <dan.j.williams@intel.com>,
Jeff Moyer <jmoyer@redhat.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Toshi Kani <toshi.kani@hpe.com>,
Vishal Verma <vishal.l.verma@intel.com>
Subject: [PATCH 2/6] btt: refactor map entry operations with macros
Date: Fri, 14 Jul 2017 16:11:44 -0600 [thread overview]
Message-ID: <20170714221148.11232-3-vishal.l.verma@intel.com> (raw)
In-Reply-To: <20170714221148.11232-1-vishal.l.verma@intel.com>
Add helpers for converting a raw map entry to just the block number, or
either of the 'e' or 'z' flags in preparation for actually using the
error flag to mark blocks with media errors.
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
drivers/nvdimm/btt.c | 8 ++++----
drivers/nvdimm/btt.h | 4 ++++
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 52aa96f..3aa6bc0 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -106,7 +106,7 @@ static int btt_map_write(struct arena_info *arena, u32 lba, u32 mapping,
* This 'mapping' is supposed to be just the LBA mapping, without
* any flags set, so strip the flag bits.
*/
- mapping &= MAP_LBA_MASK;
+ mapping = ent_lba(mapping);
ze = (z_flag << 1) + e_flag;
switch (ze) {
@@ -155,10 +155,10 @@ static int btt_map_read(struct arena_info *arena, u32 lba, u32 *mapping,
raw_mapping = le32_to_cpu(in);
- z_flag = (raw_mapping & MAP_TRIM_MASK) >> MAP_TRIM_SHIFT;
- e_flag = (raw_mapping & MAP_ERR_MASK) >> MAP_ERR_SHIFT;
+ z_flag = ent_z_flag(raw_mapping);
+ e_flag = ent_e_flag(raw_mapping);
ze = (z_flag << 1) + e_flag;
- postmap = raw_mapping & MAP_LBA_MASK;
+ postmap = ent_lba(raw_mapping);
/* Reuse the {z,e}_flag variables for *trim and *error */
z_flag = 0;
diff --git a/drivers/nvdimm/btt.h b/drivers/nvdimm/btt.h
index 888e862..09fabf5 100644
--- a/drivers/nvdimm/btt.h
+++ b/drivers/nvdimm/btt.h
@@ -38,6 +38,10 @@
#define IB_FLAG_ERROR 0x00000001
#define IB_FLAG_ERROR_MASK 0x00000001
+#define ent_lba(ent) (ent & MAP_LBA_MASK)
+#define ent_e_flag(ent) (!!(ent & MAP_ERR_MASK))
+#define ent_z_flag(ent) (!!(ent & MAP_TRIM_MASK))
+
enum btt_init_state {
INIT_UNCHECKED = 0,
INIT_NOTFOUND,
--
2.9.3
next prev parent reply other threads:[~2017-07-14 22:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-14 22:11 [PATCH 0/6] BTT error clearing rework Vishal Verma
2017-07-14 22:11 ` [PATCH 1/6] btt: fix a missed NVDIMM_IO_ATOMIC case in the write path Vishal Verma
2017-07-14 22:11 ` Vishal Verma [this message]
[not found] ` <20170714221148.11232-1-vishal.l.verma-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-07-14 22:11 ` [PATCH 3/6] btt: ensure that flags were also unchanged during a map_read Vishal Verma
2017-07-14 22:11 ` [PATCH 6/6] libnvdimm, btt: rework error clearing Vishal Verma
2017-07-14 22:11 ` [PATCH 4/6] btt: cache sector_size in arena_info Vishal Verma
2017-07-14 22:11 ` [PATCH 5/6] acpi: change memory allocations to GFP_NOIO Vishal Verma
2017-07-15 5:26 ` Dan Williams
2017-07-15 12:45 ` Rafael J. Wysocki
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=20170714221148.11232-3-vishal.l.verma@intel.com \
--to=vishal.l.verma@intel.com \
--cc=dan.j.williams@intel.com \
--cc=jmoyer@redhat.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=rafael.j.wysocki@intel.com \
--cc=toshi.kani@hpe.com \
/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).