aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishal Verma <vishal.l.verma@intel.com>2017-08-30 21:35:59 -0400
committerDan Williams <dan.j.williams@intel.com>2017-08-31 18:05:10 -0400
commit0595d539a5deb4f495618ebbed96db59ae635e32 (patch)
tree0c5930eff3470fc56261075a15da25e56af3688b
parent1db1f3cea1d8886c686832d4618b346ae16c03c8 (diff)
libnvdimm, btt: refactor map entry operations with macros
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> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/nvdimm/btt.c8
-rw-r--r--drivers/nvdimm/btt.h4
2 files changed, 8 insertions, 4 deletions
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index a5e4134e1ed0..bb816bc1a906 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,
106 * This 'mapping' is supposed to be just the LBA mapping, without 106 * This 'mapping' is supposed to be just the LBA mapping, without
107 * any flags set, so strip the flag bits. 107 * any flags set, so strip the flag bits.
108 */ 108 */
109 mapping &= MAP_LBA_MASK; 109 mapping = ent_lba(mapping);
110 110
111 ze = (z_flag << 1) + e_flag; 111 ze = (z_flag << 1) + e_flag;
112 switch (ze) { 112 switch (ze) {
@@ -155,10 +155,10 @@ static int btt_map_read(struct arena_info *arena, u32 lba, u32 *mapping,
155 155
156 raw_mapping = le32_to_cpu(in); 156 raw_mapping = le32_to_cpu(in);
157 157
158 z_flag = (raw_mapping & MAP_TRIM_MASK) >> MAP_TRIM_SHIFT; 158 z_flag = ent_z_flag(raw_mapping);
159 e_flag = (raw_mapping & MAP_ERR_MASK) >> MAP_ERR_SHIFT; 159 e_flag = ent_e_flag(raw_mapping);
160 ze = (z_flag << 1) + e_flag; 160 ze = (z_flag << 1) + e_flag;
161 postmap = raw_mapping & MAP_LBA_MASK; 161 postmap = ent_lba(raw_mapping);
162 162
163 /* Reuse the {z,e}_flag variables for *trim and *error */ 163 /* Reuse the {z,e}_flag variables for *trim and *error */
164 z_flag = 0; 164 z_flag = 0;
diff --git a/drivers/nvdimm/btt.h b/drivers/nvdimm/btt.h
index 888e862907a0..09fabf5a5590 100644
--- a/drivers/nvdimm/btt.h
+++ b/drivers/nvdimm/btt.h
@@ -38,6 +38,10 @@
38#define IB_FLAG_ERROR 0x00000001 38#define IB_FLAG_ERROR 0x00000001
39#define IB_FLAG_ERROR_MASK 0x00000001 39#define IB_FLAG_ERROR_MASK 0x00000001
40 40
41#define ent_lba(ent) (ent & MAP_LBA_MASK)
42#define ent_e_flag(ent) (!!(ent & MAP_ERR_MASK))
43#define ent_z_flag(ent) (!!(ent & MAP_TRIM_MASK))
44
41enum btt_init_state { 45enum btt_init_state {
42 INIT_UNCHECKED = 0, 46 INIT_UNCHECKED = 0,
43 INIT_NOTFOUND, 47 INIT_NOTFOUND,