From nobody Sun Sep 14 22:15:28 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 6707FC32793 for ; Wed, 18 Jan 2023 12:53:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231269AbjARMx3 (ORCPT ); Wed, 18 Jan 2023 07:53:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230492AbjARMvz (ORCPT ); Wed, 18 Jan 2023 07:51:55 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9C8DD46728 for ; Wed, 18 Jan 2023 04:15:15 -0800 (PST) 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 9E068169C; Wed, 18 Jan 2023 04:15:57 -0800 (PST) Received: from e120937-lin.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 70BFC3F71A; Wed, 18 Jan 2023 04:15:13 -0800 (PST) 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, wleavitt@marvell.com, peter.hilber@opensynergy.com, nicola.mazzucato@arm.com, tarek.el-sherbiny@arm.com, quic_kshivnan@quicinc.com, cristian.marussi@arm.com Subject: [PATCH v8 06/17] firmware: arm_scmi: Move errors defs and code to common.h Date: Wed, 18 Jan 2023 12:14:15 +0000 Message-Id: <20230118121426.492864-7-cristian.marussi@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118121426.492864-1-cristian.marussi@arm.com> References: <20230118121426.492864-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Move SCMI error codes definitions and helper to the common.h header together with the delayed response timeout define. No functional change. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/common.h | 40 ++++++++++++++++++++++++++++++ drivers/firmware/arm_scmi/driver.c | 40 ------------------------------ 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi= /common.h index e9aa1cfef90d..049607280ea5 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -27,6 +27,46 @@ #include "protocols.h" #include "notify.h" =20 +#define SCMI_MAX_RESPONSE_TIMEOUT (2 * MSEC_PER_SEC) + +enum scmi_error_codes { + SCMI_SUCCESS =3D 0, /* Success */ + SCMI_ERR_SUPPORT =3D -1, /* Not supported */ + SCMI_ERR_PARAMS =3D -2, /* Invalid Parameters */ + SCMI_ERR_ACCESS =3D -3, /* Invalid access/permission denied */ + SCMI_ERR_ENTRY =3D -4, /* Not found */ + SCMI_ERR_RANGE =3D -5, /* Value out of range */ + SCMI_ERR_BUSY =3D -6, /* Device busy */ + SCMI_ERR_COMMS =3D -7, /* Communication Error */ + SCMI_ERR_GENERIC =3D -8, /* Generic Error */ + SCMI_ERR_HARDWARE =3D -9, /* Hardware Error */ + SCMI_ERR_PROTOCOL =3D -10,/* Protocol Error */ +}; + +static const int scmi_linux_errmap[] =3D { + /* better than switch case as long as return value is continuous */ + 0, /* SCMI_SUCCESS */ + -EOPNOTSUPP, /* SCMI_ERR_SUPPORT */ + -EINVAL, /* SCMI_ERR_PARAM */ + -EACCES, /* SCMI_ERR_ACCESS */ + -ENOENT, /* SCMI_ERR_ENTRY */ + -ERANGE, /* SCMI_ERR_RANGE */ + -EBUSY, /* SCMI_ERR_BUSY */ + -ECOMM, /* SCMI_ERR_COMMS */ + -EIO, /* SCMI_ERR_GENERIC */ + -EREMOTEIO, /* SCMI_ERR_HARDWARE */ + -EPROTO, /* SCMI_ERR_PROTOCOL */ +}; + +static inline int scmi_to_linux_errno(int errno) +{ + int err_idx =3D -errno; + + if (err_idx >=3D SCMI_SUCCESS && err_idx < ARRAY_SIZE(scmi_linux_errmap)) + return scmi_linux_errmap[err_idx]; + return -EIO; +} + #define MSG_ID_MASK GENMASK(7, 0) #define MSG_XTRACT_ID(hdr) FIELD_GET(MSG_ID_MASK, (hdr)) #define MSG_TYPE_MASK GENMASK(9, 8) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi= /driver.c index 67072699b029..fefa01dbf9ee 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -39,20 +39,6 @@ #define CREATE_TRACE_POINTS #include =20 -enum scmi_error_codes { - SCMI_SUCCESS =3D 0, /* Success */ - SCMI_ERR_SUPPORT =3D -1, /* Not supported */ - SCMI_ERR_PARAMS =3D -2, /* Invalid Parameters */ - SCMI_ERR_ACCESS =3D -3, /* Invalid access/permission denied */ - SCMI_ERR_ENTRY =3D -4, /* Not found */ - SCMI_ERR_RANGE =3D -5, /* Value out of range */ - SCMI_ERR_BUSY =3D -6, /* Device busy */ - SCMI_ERR_COMMS =3D -7, /* Communication Error */ - SCMI_ERR_GENERIC =3D -8, /* Generic Error */ - SCMI_ERR_HARDWARE =3D -9, /* Hardware Error */ - SCMI_ERR_PROTOCOL =3D -10,/* Protocol Error */ -}; - static DEFINE_IDR(scmi_protocols); static DEFINE_SPINLOCK(protocol_lock); =20 @@ -172,30 +158,6 @@ struct scmi_info { #define bus_nb_to_scmi_info(nb) container_of(nb, struct scmi_info, bus_nb) #define req_nb_to_scmi_info(nb) container_of(nb, struct scmi_info, dev_req= _nb) =20 -static const int scmi_linux_errmap[] =3D { - /* better than switch case as long as return value is continuous */ - 0, /* SCMI_SUCCESS */ - -EOPNOTSUPP, /* SCMI_ERR_SUPPORT */ - -EINVAL, /* SCMI_ERR_PARAM */ - -EACCES, /* SCMI_ERR_ACCESS */ - -ENOENT, /* SCMI_ERR_ENTRY */ - -ERANGE, /* SCMI_ERR_RANGE */ - -EBUSY, /* SCMI_ERR_BUSY */ - -ECOMM, /* SCMI_ERR_COMMS */ - -EIO, /* SCMI_ERR_GENERIC */ - -EREMOTEIO, /* SCMI_ERR_HARDWARE */ - -EPROTO, /* SCMI_ERR_PROTOCOL */ -}; - -static inline int scmi_to_linux_errno(int errno) -{ - int err_idx =3D -errno; - - if (err_idx >=3D SCMI_SUCCESS && err_idx < ARRAY_SIZE(scmi_linux_errmap)) - return scmi_linux_errmap[err_idx]; - return -EIO; -} - static const struct scmi_protocol *scmi_protocol_get(int protocol_id) { const struct scmi_protocol *proto; @@ -1217,8 +1179,6 @@ static void reset_rx_to_maxsz(const struct scmi_proto= col_handle *ph, xfer->rx.len =3D info->desc->max_msg_size; } =20 -#define SCMI_MAX_RESPONSE_TIMEOUT (2 * MSEC_PER_SEC) - /** * do_xfer_with_response() - Do one transfer and wait until the delayed * response is received --=20 2.34.1