From patchwork Tue Dec 10 14:53:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 181127 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp5606041och; Tue, 10 Dec 2019 06:54:22 -0800 (PST) X-Google-Smtp-Source: APXvYqzuSZOTt5uSR1EInNoCeSJa+ETWjfkCcBZJICnegnHxWnhEmL5+1hb53pqv4/valO4iLj5M X-Received: by 2002:a9d:eee:: with SMTP id 101mr16490562otj.5.1575989662710; Tue, 10 Dec 2019 06:54:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575989662; cv=none; d=google.com; s=arc-20160816; b=Hc0zgv9twiqJgwfRyqrU6mgrL9Rg2uBIevNrilfWzp5nf8vw+3y7QMp1URTuu9gpnJ sjNToD5clv/3hj3W2VAsvKXEGZU0rSB4Jl3kXcYUW/WwjjmD+Hn3I+7tC4e87pEsJ6U+ S6yTjgyUzrcew5FDEhAf6gon5WKqfyVbnCi7b0vqIfaWktt6eQW3V6jGZB1luXiyLMs5 3luiGHJabniJGbcOA9I2Y7rmoWHXL2d1tCRJbTiUlKaZMr7efrOpc4Bhd0kqkNmjxS4Z NNPJ/v8kvOneZhxa2X9BN44/NFvBV0H/QCwbk+Ksgvc0aujxAZe8mmsbvBD52LSpBiIZ BUUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=ZMq72ZBzaRT1xU9DwEGwYdDPoh4TMxVapr5gN0Jwh9U=; b=ghMWP0dLnDLf8MpmP+I/dkZkz1BKA2i4lnzFTyYwTVoftcIEGKBQnLHu6scw2e/YD5 izf0kzda6vOnFoSb2SXQSPpkbnmwSfzbgz1zaOEuF2jIQCyiinOE4cIMpivLgpUsHdXZ A2SDGd+cc+BjU0JMceNbqG27cozY6E4eQruqBwpEyv9upaSaLeGUs1X4QWj4FylfjgyS LYHeooYYTUHYPWPaNiRud7bxScJzDJUApfZPJlHAU8UCX+FKzBgD5fyYX1f9NMamUQff ePWUWxXb0z4fzlnDKQfgPGv6LECgLPbiRTL6XU74wRx3DEkGn02yolT/vQGDNKI+YXav r5Kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j6si721501oij.197.2019.12.10.06.54.22; Tue, 10 Dec 2019 06:54:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727768AbfLJOyV (ORCPT + 27 others); Tue, 10 Dec 2019 09:54:21 -0500 Received: from foss.arm.com ([217.140.110.172]:47158 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727681AbfLJOyN (ORCPT ); Tue, 10 Dec 2019 09:54:13 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C15AA328; Tue, 10 Dec 2019 06:54:12 -0800 (PST) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1E95E3F67D; Tue, 10 Dec 2019 06:54:12 -0800 (PST) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi Subject: [PATCH 09/15] firmware: arm_scmi: Add scmi protocol version and id device attributes Date: Tue, 10 Dec 2019 14:53:39 +0000 Message-Id: <20191210145345.11616-10-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191210145345.11616-1-sudeep.holla@arm.com> References: <20191210145345.11616-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Linux kernel bus driver management layer provides way to add set of default attributes of the devices on the bus. Using the same, let's add the scmi per protocol version and id attributes to the sysfs. It helps to identify the individual protocol details from the sysfs entries similar to the SCMI protocol and firmware version. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/bus.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index f619da2634a6..ed0ed02f7158 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -92,11 +92,38 @@ static int scmi_dev_remove(struct device *dev) return 0; } +static ssize_t protocol_version_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct scmi_device *scmi_dev = to_scmi_dev(dev); + + return sprintf(buf, "%u.%u\n", PROTOCOL_REV_MAJOR(scmi_dev->version), + PROTOCOL_REV_MINOR(scmi_dev->version)); +} +static DEVICE_ATTR_RO(protocol_version); + +static ssize_t protocol_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct scmi_device *scmi_dev = to_scmi_dev(dev); + + return sprintf(buf, "%u\n", scmi_dev->protocol_id); +} +static DEVICE_ATTR_RO(protocol_id); + +static struct attribute *versions_attrs[] = { + &dev_attr_protocol_version.attr, + &dev_attr_protocol_id.attr, + NULL, +}; +ATTRIBUTE_GROUPS(versions); + static struct bus_type scmi_bus_type = { .name = "scmi_protocol", .match = scmi_dev_match, .probe = scmi_dev_probe, .remove = scmi_dev_remove, + .dev_groups = versions_groups, }; int scmi_driver_register(struct scmi_driver *driver, struct module *owner,