From patchwork Tue Nov 14 12:56:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13455285 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A621A3FB34; Tue, 14 Nov 2023 12:57:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2730F131; Tue, 14 Nov 2023 04:57:07 -0800 (PST) Received: from lhrpeml500006.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4SV5mX4rsVz6JB1b; Tue, 14 Nov 2023 20:52:28 +0800 (CST) Received: from SecurePC30232.china.huawei.com (10.122.247.234) by lhrpeml500006.china.huawei.com (7.191.161.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 14 Nov 2023 12:57:04 +0000 From: To: CC: , , , , , , , , , , , , , , , , , , , , <"pgonda@pgonda"@google.com>, , , , , , , , , Subject: [RFC PATCH 3/6] memory: scrub: Add function to show scrub attributes in decimal Date: Tue, 14 Nov 2023 20:56:44 +0800 Message-ID: <20231114125648.1146-4-shiju.jose@huawei.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20231114125648.1146-1-shiju.jose@huawei.com> References: <20231114125648.1146-1-shiju.jose@huawei.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.122.247.234] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500006.china.huawei.com (7.191.161.198) X-CFilter-Loop: Reflected From: Shiju Jose Add function to show scrub control attributes to the user in decimal. Signed-off-by: Shiju Jose --- 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);