diff mbox series

[1/2] mtd: core: add MTD_DEVICE_ATTR_RO/RW() helper macros

Message ID 20210603125323.12142-2-thunder.leizhen@huawei.com
State New
Headers show
Series mtd: core: add and use MTD_DEVICE_ATTR_RO/RW() helper macros to simplify code | expand

Commit Message

Leizhen (ThunderTown) June 3, 2021, 12:53 p.m. UTC
Compared with the definition of DEVICE_ATTR_RO/RW(), the read and write
function names of the sysfs attribute have an additional "mtd_" prefix.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

---
 drivers/mtd/mtdcore.c | 6 ++++++
 1 file changed, 6 insertions(+)

-- 
2.26.0.106.g9fadedd



______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

Comments

Miquel Raynal June 11, 2021, 7 p.m. UTC | #1
On Thu, 2021-06-03 at 12:53:22 UTC, Zhen Lei wrote:
> Compared with the definition of DEVICE_ATTR_RO/RW(), the read and write

> function names of the sysfs attribute have an additional "mtd_" prefix.

> 

> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>


Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
diff mbox series

Patch

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index ce514305f8f756e..770f64d6701567a 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -96,6 +96,12 @@  static void mtd_release(struct device *dev)
 	device_destroy(&mtd_class, index + 1);
 }
 
+#define MTD_DEVICE_ATTR_RO(name) \
+static DEVICE_ATTR(name, 0444, mtd_##name##_show, NULL)
+
+#define MTD_DEVICE_ATTR_RW(name) \
+static DEVICE_ATTR(name, 0644, mtd_##name##_show, mtd_##name##_store)
+
 static ssize_t mtd_type_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {