[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200902161328.GE3050651@lunn.ch>
Date: Wed, 2 Sep 2020 18:13:28 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Pali Rohár <pali@...nel.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Rob Herring <robh@...nel.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Kishon Vijay Abraham I <kishon@...com>,
Vinod Koul <vkoul@...nel.org>,
Marek Behún <marek.behun@....cz>,
Tomasz Maciej Nowak <tmn505@...il.com>,
linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH 1/2] phy: marvell: comphy: Convert internal SMCC firmware
return codes to errno
On Wed, Sep 02, 2020 at 04:43:43PM +0200, Pali Rohár wrote:
> Driver ->power_on and ->power_off callbacks leaks internal SMCC firmware
> return codes to phy caller. This patch converts SMCC error codes to
> standard linux errno codes. Include file linux/arm-smccc.h already provides
> defines for SMCC error codes, so use them instead of custom driver defines.
> Note that return value is signed 32bit, but stored in unsigned long type
> with zero padding.
>
> Signed-off-by: Pali Rohár <pali@...nel.org>
> ---
> drivers/phy/marvell/phy-mvebu-a3700-comphy.c | 14 +++++++++++---
> drivers/phy/marvell/phy-mvebu-cp110-comphy.c | 14 +++++++++++---
> 2 files changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
> index 1a138be8bd6a..810f25a47632 100644
> --- a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
> +++ b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
> @@ -26,7 +26,6 @@
> #define COMPHY_SIP_POWER_ON 0x82000001
> #define COMPHY_SIP_POWER_OFF 0x82000002
> #define COMPHY_SIP_PLL_LOCK 0x82000003
> -#define COMPHY_FW_NOT_SUPPORTED (-1)
>
> #define COMPHY_FW_MODE_SATA 0x1
> #define COMPHY_FW_MODE_SGMII 0x2
> @@ -112,10 +111,19 @@ static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane,
> unsigned long mode)
> {
> struct arm_smccc_res res;
> + s32 ret;
>
> arm_smccc_smc(function, lane, mode, 0, 0, 0, 0, 0, &res);
> + ret = res.a0;
>
> - return res.a0;
> + switch (ret) {
> + case SMCCC_RET_SUCCESS:
> + return 0;
> + case SMCCC_RET_NOT_SUPPORTED:
> + return -EOPNOTSUPP;
> + default:
> + return -EINVAL;
> + }
> }
Hi Pali
Maybe this should be a global helper translating SMCCC_RET_* into a
standard errno value?
Andrew
Powered by blists - more mailing lists