Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: mtdpart: use DEVICE_ATTR_RO() helper macro

Use DEVICE_ATTR_RO() helper macro instead of plain DEVICE_ATTR(), which
makes the code a bit shorter and easier to read.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210603123041.12036-1-thunder.leizhen@huawei.com

authored by

Zhen Lei and committed by
Miquel Raynal
97f41002 10f3b4d7

+3 -4
+3 -4
drivers/mtd/mtdpart.c
··· 212 212 return child; 213 213 } 214 214 215 - static ssize_t mtd_partition_offset_show(struct device *dev, 216 - struct device_attribute *attr, char *buf) 215 + static ssize_t offset_show(struct device *dev, 216 + struct device_attribute *attr, char *buf) 217 217 { 218 218 struct mtd_info *mtd = dev_get_drvdata(dev); 219 219 220 220 return sysfs_emit(buf, "%lld\n", mtd->part.offset); 221 221 } 222 - 223 - static DEVICE_ATTR(offset, S_IRUGO, mtd_partition_offset_show, NULL); 222 + static DEVICE_ATTR_RO(offset); /* mtd partition offset */ 224 223 225 224 static const struct attribute *mtd_partition_attrs[] = { 226 225 &dev_attr_offset.attr,