From patchwork Mon Jan 6 12:10:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13927260 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 45F09E77188 for ; Mon, 6 Jan 2025 12:12:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3600C6B00B0; Mon, 6 Jan 2025 07:11:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E49F6B00B1; Mon, 6 Jan 2025 07:11:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 137A56B00B2; Mon, 6 Jan 2025 07:11:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E1F096B00B0 for ; Mon, 6 Jan 2025 07:11:56 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A44D61C85C5 for ; Mon, 6 Jan 2025 12:11:56 +0000 (UTC) X-FDA: 82976913432.16.F3CA8A7 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf22.hostedemail.com (Postfix) with ESMTP id C4C0CC0011 for ; Mon, 6 Jan 2025 12:11:54 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736165514; 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=LrK5A8kZIZhWum4I/7Silnup7YzVuKKdihsziphTRhA=; b=EuLERi+qXAWLGccWT7Z95YZMaHNcSKtcebsfVvJCR7Bd6fY4rPV6ry2lMnSlHiZXX9nb5P uF+WlVLqTtFo9IM/KVMK29iHI2MG6tPQfsOoD/w4a4l+lws1aXybsw7OdH2k1Q0tk+X7Mi sxbYgQefTflaAyHh5CelHrUIi7fJ7V0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736165515; a=rsa-sha256; cv=none; b=8k4w9SC+hcMet21Uk+wYppc0cTudcvF1Gcya00PVfZI/vBay+eURlOPBJRgiFSd12FkWKo FXHoyAW5U/6IkfeAEl6O6Nk/O9WFEHTd/+EfUVXoeKowAVdbnLIng/h6HaJVceBC9NNDYp oj49v6Me/LypK5jm2Ci6u/rKvVjfBog= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4YRY176FsMz6FGp1; Mon, 6 Jan 2025 20:10:51 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 4BEBB14022E; Mon, 6 Jan 2025 20:11:53 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.126.170.95) by frapeml500007.china.huawei.com (7.182.85.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 6 Jan 2025 13:11:51 +0100 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v18 11/19] cxl: Add features driver attribute to emit number of features supported Date: Mon, 6 Jan 2025 12:10:07 +0000 Message-ID: <20250106121017.1620-12-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20250106121017.1620-1-shiju.jose@huawei.com> References: <20250106121017.1620-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.126.170.95] X-ClientProxiedBy: lhrpeml100011.china.huawei.com (7.191.174.247) To frapeml500007.china.huawei.com (7.182.85.172) X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C4C0CC0011 X-Stat-Signature: tubnhwpbkudg5ajs8y4kcw95s7xe8ny3 X-Rspam-User: X-HE-Tag: 1736165514-441363 X-HE-Meta: U2FsdGVkX1/OiFi959SkMqopVrf387lPNZtIkKELYpyMaW50BvEZ9CkmKWFRJLWGDs8brijchoPveRNnagqJk9H9FAZZQpbmu8FKs6syz6SWwzuLe/FqFxEfCvDOeX2r8IpQD8T20EB2EJbo+9wLi7cnPCT8I8GunDRHaaDtGLlPmyieWR9872tXVjjlHaRQ2KXNyHjAuSa8D/dge3iAfDgIeKWlA7afWTdAon/VUJL8IHvbeDYeb/zMlVlMm9Loes80Fs2/PeiKCkFeZmfmmOw0oTPt3msqXg2uI4fL7jIpcCQTsKbnSU7DsuD+qbWKKYxU6ij1oNyfukDFbEIOb2wa1++C7cdodHhIRTYj8Z8G02ru9aIP/eP78Gp/Tx1SB5VMTzCEszruaKwV7VyWtH1k2PKLy4isfD8hgGR96xDJUBolbNrBkqs4pz4lBezR1x9WVyfqqpF2Jcr5l8TCf3CjosfE3HTn7youj9hycjfqSb/8H4qO6N7oT046Gnu3V+wVs9NnI1JXlCgKgVBr5WLVVcTEanoJO09XQGCZHck0XFUofzls7wh0+fE6uJ/kIF58hicWV7Amw/bDV56IrEdt57Ts9T1I2B2m5MhlIhXU7DBhC+VJ7HrY1Cu+kADt77vUWbnmJxKIXGQj2uSjEA8YdcZa+V+ogeD5qRN7c3P5rJ1CYhuta5LjctfdFBf2q9hYcm3OyM5Co58awYvX6OLHcF7/nrpmgHxpmXBx+IJ53AV20t/57OEP4x8ziRORdcSk+DZtmJeP4H9fk1vAXioFHsCpmHOD/gUs9RdE7cpELCk+VhCyfifp3Z8Ss81N3FAYFKGWU4SvsIUULo9MzwScG57pd1V5HX7MgbH+Hqq2ik8wnqlO3YtdTcUuIZj5gESCC+vHLS4zEJM04fYGqDOnL0hXvIiPL1OundKOUT5v6muBJaAiMjebZ6D4hMJo91+/qiXBWyEdk3iLRJ3 7KqELbtp KCpHGHqqyt0TR/rkxy0EGcUTeGGqffruICSe3WXBj3RpyKxF8YAHb4vCcU24DCT7Ph+fNkoMAJ8NXDotf/iBpMsp/hW9EIF7BbqUbQ4I1QJ+A0tgNHCb6Gs6MwQ3kDTKfPKPgiOAZgqC3UN+2xqGMDT0va7LTJaF8vj9gpLDC/bUIFOIV8GJcUaU6FjTwy/3b7peKAJ+aombcddVr88+dFNH12SnCFnjCq0dquNOrRWSBampvcCqOm+TFxi66Vbnl40ZL 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: Dave Jiang Enable sysfs attribute emission of the number of features supported by the driver/device. This is useful for userspace to determine the number of features to query for. Signed-off-by: Dave Jiang --- drivers/cxl/features.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/cxl/features.c b/drivers/cxl/features.c index 2cdf5ed0a771..2f0fb072921e 100644 --- a/drivers/cxl/features.c +++ b/drivers/cxl/features.c @@ -173,11 +173,38 @@ static void cxl_features_remove(struct device *dev) kfree(cfs); } +static ssize_t features_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct cxl_features_state *cfs = dev_get_drvdata(dev); + + if (!cfs) + return -ENOENT; + + return sysfs_emit(buf, "%d\n", cfs->num_features); +} + +static DEVICE_ATTR_RO(features); + +static struct attribute *cxl_features_attrs[] = { + &dev_attr_features.attr, + NULL +}; + +static struct attribute_group cxl_features_group = { + .attrs = cxl_features_attrs, +}; + +__ATTRIBUTE_GROUPS(cxl_features); + static struct cxl_driver cxl_features_driver = { .name = "cxl_features", .probe = cxl_features_probe, .remove = cxl_features_remove, .id = CXL_DEVICE_FEATURES, + .drv = { + .dev_groups = cxl_features_groups, + }, }; module_cxl_driver(cxl_features_driver);