Skip to content

Commit

Permalink
mtd: mtdpart: use DEVICE_ATTR_RO() helper macro
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Zhen Lei authored and Miquel Raynal committed Jun 11, 2021
1 parent 10f3b4d commit 97f4100
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/mtd/mtdpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,14 @@ static struct mtd_info *allocate_partition(struct mtd_info *parent,
return child;
}

static ssize_t mtd_partition_offset_show(struct device *dev,
struct device_attribute *attr, char *buf)
static ssize_t offset_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);

return sysfs_emit(buf, "%lld\n", mtd->part.offset);
}

static DEVICE_ATTR(offset, S_IRUGO, mtd_partition_offset_show, NULL);
static DEVICE_ATTR_RO(offset); /* mtd partition offset */

static const struct attribute *mtd_partition_attrs[] = {
&dev_attr_offset.attr,
Expand Down

0 comments on commit 97f4100

Please sign in to comment.