Skip to contentSkip to conversation

EDAC/amd64: Use DEVICE_ATTR helper macros

PATCH In review Dwaipayan Ray 3 participants 3 messages Jul 13, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 EDAC/amd64: Use DEVICE_ATTR helper macros

Instead of "open coding" DEVICE_ATTR, use the corresponding helper macros DEVICE_ATTR_{RW,RO,WO} in amd64_edac.c

Some function names needed to be changed to match the device conventions <foo>_show and <foo>_store, but the functionality itself is unchanged.

The devices using EDAC_DCT_ATTR_SHOW() are left unchanged.

---

Changes in v3:
- Reword patch subject as suggested by Yazen and fix a typo.
https://lore.kernel.org/lkml/20210712194433.GA1002(a)aus-x-yghannam.amd.com/

Changes in v2:
- Revert back the device name changes which broke the kernel. These were using the macro EDAC_DCT_ATTR_SHOW() to construct the show methods based on device name. Reported by Kernel test bot.

 drivers/edac/amd64_edac.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/edac/amd64_edac.c +8 -13
index f0d8f60acee1..99b06a3e8fb1 100644
@@ -571,8 +571,8 @@ EDAC_DCT_ATTR_SHOW(dbam0);
 EDAC_DCT_ATTR_SHOW(top_mem);
 EDAC_DCT_ATTR_SHOW(top_mem2);
 
-static ssize_t hole_show(struct device *dev, struct device_attribute *mattr,
-			 char *data)
+static ssize_t dram_hole_show(struct device *dev, struct device_attribute *mattr,
+			      char *data)
 {
 	struct mem_ctl_info *mci = to_mci(dev);
 
@@ -593,7 +593,7 @@ static DEVICE_ATTR(dhar, S_IRUGO, dhar_show, NULL);
 static DEVICE_ATTR(dbam, S_IRUGO, dbam0_show, NULL);
 static DEVICE_ATTR(topmem, S_IRUGO, top_mem_show, NULL);
 static DEVICE_ATTR(topmem2, S_IRUGO, top_mem2_show, NULL);
-static DEVICE_ATTR(dram_hole, S_IRUGO, hole_show, NULL);
+static DEVICE_ATTR_RO(dram_hole);
 
 static struct attribute *dbg_attrs[] = {
 	&dev_attr_dhar.attr,
@@ -802,16 +802,11 @@ static ssize_t inject_write_store(struct device *dev,
  * update NUM_INJ_ATTRS in case you add new members
  */
 
-static DEVICE_ATTR(inject_section, S_IRUGO | S_IWUSR,
-		   inject_section_show, inject_section_store);
-static DEVICE_ATTR(inject_word, S_IRUGO | S_IWUSR,
-		   inject_word_show, inject_word_store);
-static DEVICE_ATTR(inject_ecc_vector, S_IRUGO | S_IWUSR,
-		   inject_ecc_vector_show, inject_ecc_vector_store);
-static DEVICE_ATTR(inject_write, S_IWUSR,
-		   NULL, inject_write_store);
-static DEVICE_ATTR(inject_read,  S_IWUSR,
-		   NULL, inject_read_store);
+static DEVICE_ATTR_RW(inject_section);
+static DEVICE_ATTR_RW(inject_word);
+static DEVICE_ATTR_RW(inject_ecc_vector);
+static DEVICE_ATTR_WO(inject_write);
+static DEVICE_ATTR_WO(inject_read);
 
 static struct attribute *inj_attrs[] = {
 	&dev_attr_inject_section.attr,
Signature · 1 line
2.28.0
maintainer
#1 lore raw
Quoted 11 lines

Instead of "open coding" DEVICE_ATTR, use the corresponding helper macros DEVICE_ATTR_{RW,RO,WO} in amd64_edac.c

Some function names needed to be changed to match the device conventions <foo>_show and <foo>_store, but the functionality itself is unchanged.

The devices using EDAC_DCT_ATTR_SHOW() are left unchanged.

Yazen,

Boris is on vacation. Should I queue this change?

-Tony

maintainer
#2 lore raw
Quoted 7 lines · Tony
Quoted 7 lines

Instead of "open coding" DEVICE_ATTR, use the corresponding helper macros DEVICE_ATTR_{RW,RO,WO} in amd64_edac.c

Some function names needed to be changed to match the device conventions <foo>_show and <foo>_store, but the functionality itself is unchanged.

Quoted 9 lines
Quoted 4 lines

The devices using EDAC_DCT_ATTR_SHOW() are left unchanged.

Yazen,

Boris is on vacation. Should I queue this change?

Hi Tony,

Yes, please.

Thanks,
Yazen