From nobody Tue Dec 30 16:41:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CAF3C4332F for ; Tue, 14 Nov 2023 12:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233127AbjKNM5S (ORCPT ); Tue, 14 Nov 2023 07:57:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232889AbjKNM5K (ORCPT ); Tue, 14 Nov 2023 07:57:10 -0500 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/mem= ory-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 =3D to_scrub_attr(devattr); =20 + ret =3D 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 =3D to_scrub_attr(devattr); + ret =3D 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 *drv= data, hattr->region_id =3D region_id; =20 dattr =3D &hattr->dev_attr; - dattr->show =3D is_string ? scrub_attr_show_string : scrub_attr_show; - dattr->store =3D is_hex ? scrub_attr_store_hex : scrub_attr_store; + if (is_string) { + dattr->show =3D scrub_attr_show_string; + } else { + dattr->show =3D is_hex ? scrub_attr_show_hex : scrub_attr_show; + dattr->store =3D is_hex ? scrub_attr_store_hex : scrub_attr_store; + } =20 a =3D &dattr->attr; sysfs_attr_init(a); --=20 2.34.1