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: 13455270 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8231C4332F for ; Tue, 14 Nov 2023 12:57:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 839408D0048; Tue, 14 Nov 2023 07:57:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 602B38000E; Tue, 14 Nov 2023 07:57:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 267708D004A; Tue, 14 Nov 2023 07:57:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EF8C08000D for ; Tue, 14 Nov 2023 07:57:09 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D0DF7A0996 for ; Tue, 14 Nov 2023 12:57:09 +0000 (UTC) X-FDA: 81456560178.11.495E954 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf24.hostedemail.com (Postfix) with ESMTP id 04E9C180003 for ; Tue, 14 Nov 2023 12:57:07 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699966628; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d9Z1p7Z4/MY+X41SwPF5C0hM0Rz2uuemHQ8ngvAqiy4=; b=5exeoDAB9gyug9XnWh/nON2NnCQtza70SFU8t2hQxTsQMIsZIoaFVkeIBrtk8h335nRXWT 7HXvf76Y1+7BsW2sMTW6ifZUXBjp0L+abJbeK626W0UjhLP/dZ926aAbIAPjv0CNOilKYP jclYW8/vj1dWqVs+oTsniKQxV9YGc5Q= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699966628; a=rsa-sha256; cv=none; b=dXkJYA0ChmpLhThlinuSTNzYexudPz7LJfL2Jihah31Utd/38AjUvIjuF2E4pVeMjqUI7i jU4tCXFbuXBJHGMYs/6Eeh8AX6GnDpxcXB2MtyfKKapGGxPJU82+sTZ/UscQO2cJvUc4x/ 5QtLfvSqlv9d+jBJyhiI8jTSVz9YFhs= 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 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 X-Rspamd-Queue-Id: 04E9C180003 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ycbdtepsknjoj4m3y18tie19asr8afti X-HE-Tag: 1699966627-814337 X-HE-Meta: U2FsdGVkX19SN1Yob17fN8bJVoNaPflRXPVrrmqWH7s4Z5O43Q3tz81JM2c+U9eaSi2m3nuOzagROLJnxkhMQVSjtCJjUM9a/L2lxceLYdaAX73lS10hpRwVemtUzS2uT9FLQHxriqIPh1VpPU7Pv0nwMRItSQ4MF1YM9fstQg0jop/T54i9ZJgl2cIKjtb74eLZ6iQ3yiPtaAdJAP9lSbvS1w69pMuGMWlIrQVEB/N4vl+6I+3EjtvyzLSUGaImU1E6EcotE3A5TQMhvm3FV959EICkWQyoOdc9CSaI91dd4LhFFub9dAbS6A05vsKYqad0HpgHHrhOtRIV5kCPnHKgsr89L4ArWClloEdGw0qmUAYeNoa60T/CYhA7gh2zY3xe0LW/zSnPx/e+txDza9ypxxYUjZSc4dvo12vq56X3CTIiiBR+v0LObUFxX3+S9NktQTkWzV/EnKsTCwSg11P28R62BbJPZsmZRf1Rwm2sagvR43PiaPXqGbuHPyCv+lZ/2KUq4zTzW/ZLjUIMlJkqWsH85bGPX5aFBd5rujw2VpKoaH2B7iC92AyLhDpjtFMo1zttSCMrHXYwbp9ke+VLkAK6FMSQL8HPOe9zmwT6u4ZiDggGgLg8EScuQ/8Fid5dTrjdxKVnBmJwfqpmwGSevgpxl5Cpx12xENBEhCI3qssinpj4iCVvphwauTHZCfwsfPyHxqxdleHFF37awwJtF61ta16oNfqh9LJ58fCowVSfVTRUHgi0PYappd8I0UIV6mtcObWBgx5b7wiuTd8WcfgipxYPoWup2uROMWJ1bHnZ/EZeBFLQgoShBpsBxEiXfhowW9lVPSkLZ2hHh5H0S4JNzckJjz03n8GBvtIH7aDjs9qoG21SBsENWZz6Ns8FaHU+HtlrLrRNnVBQ3QcznEAVy59LSLf/DEZvkQ3y3OwIErf/cxsV1XstRzS4hRO3a5RedERpK1hWWZc 5haIMjj1 lOqLf/fvmIs8iREt38bux+oYuzGsMfsMw52O3MrYu7xWi+97cNiyfp6KzSWhEUCCeDs5vtXupJ+7bXseTgw59gkP8WvfB/c89t1rZBlMzZZ7hzArNFfjvnWWZk7ui2gsGz9lOqzIBQoDRDQY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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);