From: Shiju Jose <shiju.jose@xxxxxxxxxx> Add function to show scrub control attributes to the user in decimal. Signed-off-by: Shiju Jose <shiju.jose@xxxxxxxxxx> --- drivers/memory/scrub/memory-scrub.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/memory/scrub/memory-scrub.c b/drivers/memory/scrub/memory-scrub.c index b3011e7cd062..ff5b4a52d2da 100755 --- a/drivers/memory/scrub/memory-scrub.c +++ b/drivers/memory/scrub/memory-scrub.c @@ -130,6 +130,20 @@ static ssize_t scrub_attr_show(struct device *dev, u64 val; struct scrub_device_attribute *hattr = to_scrub_attr(devattr); + ret = hattr->ops->read(dev, hattr->attr, hattr->region_id, &val); + if (ret < 0) + return ret; + + return sprintf(buf, "%lld\n", val); +} + +static ssize_t scrub_attr_show_hex(struct device *dev, + struct device_attribute *devattr, char *buf) +{ + int ret; + u64 val; + struct scrub_device_attribute *hattr = to_scrub_attr(devattr); + ret = hattr->ops->read(dev, hattr->attr, hattr->region_id, &val); if (ret < 0) return ret; @@ -236,8 +250,12 @@ static struct attribute *scrub_genattr(const void *drvdata, hattr->region_id = region_id; dattr = &hattr->dev_attr; - dattr->show = is_string ? scrub_attr_show_string : scrub_attr_show; - dattr->store = is_hex ? scrub_attr_store_hex : scrub_attr_store; + if (is_string) { + dattr->show = scrub_attr_show_string; + } else { + dattr->show = is_hex ? scrub_attr_show_hex : scrub_attr_show; + dattr->store = is_hex ? scrub_attr_store_hex : scrub_attr_store; + } a = &dattr->attr; sysfs_attr_init(a); -- 2.34.1