Skip to content

Commit ea17a0f

Browse files
paliLorenzo Pieralisi
authored andcommitted
phy: marvell: comphy: Convert internal SMCC firmware return codes to errno
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. Tested-by: Tomasz Maciej Nowak <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Pali Rohár <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Reviewed-by: Rob Herring <[email protected]>
1 parent d0c6a34 commit ea17a0f

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

drivers/phy/marvell/phy-mvebu-a3700-comphy.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#define COMPHY_SIP_POWER_ON 0x82000001
2727
#define COMPHY_SIP_POWER_OFF 0x82000002
2828
#define COMPHY_SIP_PLL_LOCK 0x82000003
29-
#define COMPHY_FW_NOT_SUPPORTED (-1)
3029

3130
#define COMPHY_FW_MODE_SATA 0x1
3231
#define COMPHY_FW_MODE_SGMII 0x2
@@ -112,10 +111,19 @@ static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane,
112111
unsigned long mode)
113112
{
114113
struct arm_smccc_res res;
114+
s32 ret;
115115

116116
arm_smccc_smc(function, lane, mode, 0, 0, 0, 0, 0, &res);
117+
ret = res.a0;
117118

118-
return res.a0;
119+
switch (ret) {
120+
case SMCCC_RET_SUCCESS:
121+
return 0;
122+
case SMCCC_RET_NOT_SUPPORTED:
123+
return -EOPNOTSUPP;
124+
default:
125+
return -EINVAL;
126+
}
119127
}
120128

121129
static int mvebu_a3700_comphy_get_fw_mode(int lane, int port,
@@ -220,7 +228,7 @@ static int mvebu_a3700_comphy_power_on(struct phy *phy)
220228
}
221229

222230
ret = mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_ON, lane->id, fw_param);
223-
if (ret == COMPHY_FW_NOT_SUPPORTED)
231+
if (ret == -EOPNOTSUPP)
224232
dev_err(lane->dev,
225233
"unsupported SMC call, try updating your firmware\n");
226234

drivers/phy/marvell/phy-mvebu-cp110-comphy.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@
123123

124124
#define COMPHY_SIP_POWER_ON 0x82000001
125125
#define COMPHY_SIP_POWER_OFF 0x82000002
126-
#define COMPHY_FW_NOT_SUPPORTED (-1)
127126

128127
/*
129128
* A lane is described by the following bitfields:
@@ -273,10 +272,19 @@ static int mvebu_comphy_smc(unsigned long function, unsigned long phys,
273272
unsigned long lane, unsigned long mode)
274273
{
275274
struct arm_smccc_res res;
275+
s32 ret;
276276

277277
arm_smccc_smc(function, phys, lane, mode, 0, 0, 0, 0, &res);
278+
ret = res.a0;
278279

279-
return res.a0;
280+
switch (ret) {
281+
case SMCCC_RET_SUCCESS:
282+
return 0;
283+
case SMCCC_RET_NOT_SUPPORTED:
284+
return -EOPNOTSUPP;
285+
default:
286+
return -EINVAL;
287+
}
280288
}
281289

282290
static int mvebu_comphy_get_mode(bool fw_mode, int lane, int port,
@@ -819,7 +827,7 @@ static int mvebu_comphy_power_on(struct phy *phy)
819827
if (!ret)
820828
return ret;
821829

822-
if (ret == COMPHY_FW_NOT_SUPPORTED)
830+
if (ret == -EOPNOTSUPP)
823831
dev_err(priv->dev,
824832
"unsupported SMC call, try updating your firmware\n");
825833

0 commit comments

Comments
 (0)