aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2018-05-12 08:32:43 -0400
committerBorislav Petkov <bp@suse.de>2018-05-12 08:35:30 -0400
commita0671c39ddf4ebe464dc49da7e48860ff4135920 (patch)
treef82e4b8e7d5c3e14bd1ad4af9d73a1e8286328ce
parentad0d73b324dbc9e5b987fbda08ceb523fbeb0a9f (diff)
EDAC, ghes: Use BIT() macro
... for improved readability. Also, add a local mask variable for the same reason. No functional changes. Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Toshi Kani <toshi.kani@hpe.com> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
-rw-r--r--drivers/edac/ghes_edac.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
index cb8f2704ffb0..863fbf3db29f 100644
--- a/drivers/edac/ghes_edac.c
+++ b/drivers/edac/ghes_edac.c
@@ -91,6 +91,7 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg)
91 struct dimm_info *dimm = EDAC_DIMM_PTR(mci->layers, mci->dimms, 91 struct dimm_info *dimm = EDAC_DIMM_PTR(mci->layers, mci->dimms,
92 mci->n_layers, 92 mci->n_layers,
93 dimm_fill->count, 0, 0); 93 dimm_fill->count, 0, 0);
94 u16 rdr_mask = BIT(7) | BIT(13);
94 95
95 if (entry->size == 0xffff) { 96 if (entry->size == 0xffff) {
96 pr_info("Can't get DIMM%i size\n", 97 pr_info("Can't get DIMM%i size\n",
@@ -99,22 +100,21 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg)
99 } else if (entry->size == 0x7fff) { 100 } else if (entry->size == 0x7fff) {
100 dimm->nr_pages = MiB_TO_PAGES(entry->extended_size); 101 dimm->nr_pages = MiB_TO_PAGES(entry->extended_size);
101 } else { 102 } else {
102 if (entry->size & 1 << 15) 103 if (entry->size & BIT(15))
103 dimm->nr_pages = MiB_TO_PAGES((entry->size & 104 dimm->nr_pages = MiB_TO_PAGES((entry->size & 0x7fff) << 10);
104 0x7fff) << 10);
105 else 105 else
106 dimm->nr_pages = MiB_TO_PAGES(entry->size); 106 dimm->nr_pages = MiB_TO_PAGES(entry->size);
107 } 107 }
108 108
109 switch (entry->memory_type) { 109 switch (entry->memory_type) {
110 case 0x12: 110 case 0x12:
111 if (entry->type_detail & 1 << 13) 111 if (entry->type_detail & BIT(13))
112 dimm->mtype = MEM_RDDR; 112 dimm->mtype = MEM_RDDR;
113 else 113 else
114 dimm->mtype = MEM_DDR; 114 dimm->mtype = MEM_DDR;
115 break; 115 break;
116 case 0x13: 116 case 0x13:
117 if (entry->type_detail & 1 << 13) 117 if (entry->type_detail & BIT(13))
118 dimm->mtype = MEM_RDDR2; 118 dimm->mtype = MEM_RDDR2;
119 else 119 else
120 dimm->mtype = MEM_DDR2; 120 dimm->mtype = MEM_DDR2;
@@ -123,30 +123,29 @@ static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg)
123 dimm->mtype = MEM_FB_DDR2; 123 dimm->mtype = MEM_FB_DDR2;
124 break; 124 break;
125 case 0x18: 125 case 0x18:
126 if (entry->type_detail & 1 << 12) 126 if (entry->type_detail & BIT(12))
127 dimm->mtype = MEM_NVDIMM; 127 dimm->mtype = MEM_NVDIMM;
128 else if (entry->type_detail & 1 << 13) 128 else if (entry->type_detail & BIT(13))
129 dimm->mtype = MEM_RDDR3; 129 dimm->mtype = MEM_RDDR3;
130 else 130 else
131 dimm->mtype = MEM_DDR3; 131 dimm->mtype = MEM_DDR3;
132 break; 132 break;
133 case 0x1a: 133 case 0x1a:
134 if (entry->type_detail & 1 << 12) 134 if (entry->type_detail & BIT(12))
135 dimm->mtype = MEM_NVDIMM; 135 dimm->mtype = MEM_NVDIMM;
136 else if (entry->type_detail & 1 << 13) 136 else if (entry->type_detail & BIT(13))
137 dimm->mtype = MEM_RDDR4; 137 dimm->mtype = MEM_RDDR4;
138 else 138 else
139 dimm->mtype = MEM_DDR4; 139 dimm->mtype = MEM_DDR4;
140 break; 140 break;
141 default: 141 default:
142 if (entry->type_detail & 1 << 6) 142 if (entry->type_detail & BIT(6))
143 dimm->mtype = MEM_RMBS; 143 dimm->mtype = MEM_RMBS;
144 else if ((entry->type_detail & ((1 << 7) | (1 << 13))) 144 else if ((entry->type_detail & rdr_mask) == rdr_mask)
145 == ((1 << 7) | (1 << 13)))
146 dimm->mtype = MEM_RDR; 145 dimm->mtype = MEM_RDR;
147 else if (entry->type_detail & 1 << 7) 146 else if (entry->type_detail & BIT(7))
148 dimm->mtype = MEM_SDR; 147 dimm->mtype = MEM_SDR;
149 else if (entry->type_detail & 1 << 9) 148 else if (entry->type_detail & BIT(9))
150 dimm->mtype = MEM_EDO; 149 dimm->mtype = MEM_EDO;
151 else 150 else
152 dimm->mtype = MEM_UNKNOWN; 151 dimm->mtype = MEM_UNKNOWN;