From patchwork Wed Mar 30 15:05:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 12796002 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49A64C433F5 for ; Wed, 30 Mar 2022 15:13:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PNM9zozfLASkgiSMMS5kEXrj3c22U3cAeEEAom0WgX8=; b=dWbTAquhJ98Qr5 a6gPBNOkI+E90rLleXqnYzGr996vxPZ4/VRjqTHvElUyBPH0nf3YjSZ5LBMu0a7yHG2pqk0RklJU0 QMa8t+mU3mPKCCVJ8PLeheI3M9K45MeGXQtVad6Il3cEMlI/3Y1DJOMuVw5in/L7IPXHXnA15yGbQ PGN3kZ/ZND+R0HhRepwKSDQVyPhu/5wizpIz5fUdpXEx74X2rN8RQW5O3yYvH3qr+Iqa9G0rvYMwr xD1l0EFuhFGgS5sgLG3/j2EcVcUXNMBlldNkrv1FSKGqx9WFOcSrmyrRUOmV/T1Ii0w4ANR/53rFN 54Lhjl1AFeSD2gs7D7gg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZZz5-00GS1e-Tk; Wed, 30 Mar 2022 15:11:44 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZZuK-00GPgB-8H for linux-arm-kernel@lists.infradead.org; Wed, 30 Mar 2022 15:06:49 +0000 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 F1A2D1477; Wed, 30 Mar 2022 08:06:47 -0700 (PDT) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A22343F73B; Wed, 30 Mar 2022 08:06:46 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, james.quinlan@broadcom.com, Jonathan.Cameron@Huawei.com, f.fainelli@gmail.com, etienne.carriere@linaro.org, vincent.guittot@linaro.org, souvik.chakravarty@arm.com, cristian.marussi@arm.com Subject: [PATCH 12/22] firmware: arm_scmi: Parse clock_enable_latency conditionally Date: Wed, 30 Mar 2022 16:05:41 +0100 Message-Id: <20220330150551.2573938-13-cristian.marussi@arm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220330150551.2573938-1-cristian.marussi@arm.com> References: <20220330150551.2573938-1-cristian.marussi@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220330_080648_395979_0BFE2CC0 X-CRM114-Status: GOOD ( 11.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The clock_enable_latency field in CLOCK_ATTRIBUTES response message has been added only since SCMI v3.1: use the advertised SCMI Clock protocol version as a proper condition check for parsing it, instead of the bare message length lookup. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index 6dd4150b761b..b46b43a99871 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -130,8 +130,8 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph, if (!ret) { attributes = le32_to_cpu(attr->attributes); strlcpy(clk->name, attr->name, SCMI_MAX_STR_SIZE); - /* Is optional field clock_enable_latency provided ? */ - if (t->rx.len == sizeof(*attr)) + /* clock_enable_latency field is present only since SCMI v3.1 */ + if (PROTOCOL_REV_MAJOR(version) >= 0x2) clk->enable_latency = le32_to_cpu(attr->clock_enable_latency); }