Replace the macro PFN with ELEM_NO for common use. Signed-off-by: Shiju Jose <shiju.jose@xxxxxxxxxx> --- drivers/ras/cec.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c index 569d9ad2c594..22d11c66c266 100644 --- a/drivers/ras/cec.c +++ b/drivers/ras/cec.c @@ -86,7 +86,7 @@ * u64: [ 63 ... 12 | DECAY_BITS | COUNT_BITS ] */ -#define PFN(e) ((e) >> PAGE_SHIFT) +#define ELEM_NO(e, shift) ((e) >> (shift)) #define DECAY(e) (((e) >> COUNT_BITS) & DECAY_MASK) #define COUNT(e) ((unsigned int)(e) & COUNT_MASK) #define FULL_COUNT(e) ((e) & (PAGE_SIZE - 1)) @@ -113,6 +113,10 @@ static struct ce_array { * Times we did spring cleaning. */ + u8 id_shift; /* + * shift for element id. + */ + union { struct { __u32 disabled : 1, /* cmdline disabled */ @@ -191,7 +195,7 @@ static int __find_elem(struct ce_array *ca, u64 pfn, unsigned int *to) while (min <= max) { int i = (min + max) >> 1; - this_pfn = PFN(ca->array[i]); + this_pfn = ELEM_NO(ca->array[i], ca->id_shift); if (this_pfn < pfn) min = i + 1; @@ -258,7 +262,7 @@ static u64 del_lru_elem_unlocked(struct ce_array *ca) del_elem(ca, min_idx); - return PFN(ca->array[min_idx]); + return ELEM_NO(ca->array[min_idx], ca->id_shift); } /* @@ -287,7 +291,7 @@ static bool sanity_check(struct ce_array *ca) int i; for (i = 0; i < ca->n; i++) { - u64 this = PFN(ca->array[i]); + u64 this = ELEM_NO(ca->array[i], ca->id_shift); if (WARN(prev > this, "prev: 0x%016llx <-> this: 0x%016llx\n", prev, this)) ret = true; @@ -300,7 +304,7 @@ static bool sanity_check(struct ce_array *ca) pr_info("Sanity check dump:\n{ n: %d\n", ca->n); for (i = 0; i < ca->n; i++) { - u64 this = PFN(ca->array[i]); + u64 this = ELEM_NO(ca->array[i], ca->id_shift); pr_info(" %03d: [%016llx|%03llx]\n", i, this, FULL_COUNT(ca->array[i])); } @@ -444,7 +448,7 @@ static int array_dump(struct seq_file *m, void *v) seq_printf(m, "{ n: %d\n", ca->n); for (i = 0; i < ca->n; i++) { - u64 this = PFN(ca->array[i]); + u64 this = ELEM_NO(ca->array[i], ca->id_shift); seq_printf(m, " %3d: [%016llx|%s|%03llx]\n", i, this, bins[DECAY(ca->array[i])], COUNT(ca->array[i])); @@ -569,6 +573,7 @@ static void __init cec_init(void) return; } + ce_arr.id_shift = PAGE_SHIFT; INIT_DELAYED_WORK(&cec_work, cec_work_fn); schedule_delayed_work(&cec_work, CEC_DECAY_DEFAULT_INTERVAL); -- 2.17.1