aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorPascal Ernster <git@hardfalcon.net>2023-01-05 06:35:35 +0100
committerSander Vanheule <sander@svanheule.net>2023-01-05 23:08:13 +0100
commita188536ef6507e30cba218182e673349ea48cbe7 (patch)
treee270e44f8ecc8718fa95ae3ce695f5cbf0f00b40 /target
parentde2dc3feaea7deefcc816fb09167211965fdde9b (diff)
downloadupstream-a188536ef6507e30cba218182e673349ea48cbe7.tar.gz
upstream-a188536ef6507e30cba218182e673349ea48cbe7.tar.bz2
upstream-a188536ef6507e30cba218182e673349ea48cbe7.zip
realtek: 5.15: Improve rtl838x dsa driver error handling
Make sure functions calling rtl838x_smi_wait_op() return its return value in target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c. This brings the code style in line with the rtl839x implementation. Suggested-by: Sander Vanheule <sander@svanheule.net> Signed-off-by: Pascal Ernster <git@hardfalcon.net>
Diffstat (limited to 'target')
-rw-r--r--target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c56
1 files changed, 32 insertions, 24 deletions
diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c
index cbd4543db4..8a162df9a4 100644
--- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c
+++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c
@@ -1798,7 +1798,7 @@ int rtl838x_smi_wait_op(int timeout)
/* Reads a register in a page from the PHY */
int rtl838x_read_phy(u32 port, u32 page, u32 reg, u32 *val)
{
- int err = -ETIMEDOUT;
+ int err;
u32 v;
u32 park_page;
@@ -1812,8 +1812,9 @@ int rtl838x_read_phy(u32 port, u32 page, u32 reg, u32 *val)
mutex_lock(&smi_lock);
- if (rtl838x_smi_wait_op(100000))
- goto timeout;
+ err = rtl838x_smi_wait_op(100000);
+ if (err)
+ goto errout;
sw_w32_mask(0xffff0000, port << 16, RTL838X_SMI_ACCESS_PHY_CTRL_2);
@@ -1822,14 +1823,15 @@ int rtl838x_read_phy(u32 port, u32 page, u32 reg, u32 *val)
sw_w32(v | park_page, RTL838X_SMI_ACCESS_PHY_CTRL_1);
sw_w32_mask(0, 1, RTL838X_SMI_ACCESS_PHY_CTRL_1);
- if (rtl838x_smi_wait_op(100000))
- goto timeout;
+ err = rtl838x_smi_wait_op(100000);
+ if (err)
+ goto errout;
*val = sw_r32(RTL838X_SMI_ACCESS_PHY_CTRL_2) & 0xffff;
err = 0;
-timeout:
+errout:
mutex_unlock(&smi_lock);
return err;
@@ -1838,7 +1840,7 @@ timeout:
/* Write to a register in a page of the PHY */
int rtl838x_write_phy(u32 port, u32 page, u32 reg, u32 val)
{
- int err = -ETIMEDOUT;
+ int err;
u32 v;
u32 park_page;
@@ -1847,8 +1849,9 @@ int rtl838x_write_phy(u32 port, u32 page, u32 reg, u32 val)
return -ENOTSUPP;
mutex_lock(&smi_lock);
- if (rtl838x_smi_wait_op(100000))
- goto timeout;
+ err = rtl838x_smi_wait_op(100000);
+ if (err)
+ goto errout;
sw_w32(BIT(port), RTL838X_SMI_ACCESS_PHY_CTRL_0);
mdelay(10);
@@ -1860,12 +1863,13 @@ int rtl838x_write_phy(u32 port, u32 page, u32 reg, u32 val)
sw_w32(v | park_page, RTL838X_SMI_ACCESS_PHY_CTRL_1);
sw_w32_mask(0, 1, RTL838X_SMI_ACCESS_PHY_CTRL_1);
- if (rtl838x_smi_wait_op(100000))
- goto timeout;
+ err = rtl838x_smi_wait_op(100000);
+ if (err)
+ goto errout;
err = 0;
-timeout:
+errout:
mutex_unlock(&smi_lock);
return err;
@@ -1874,13 +1878,14 @@ timeout:
/* Read an mmd register of a PHY */
int rtl838x_read_mmd_phy(u32 port, u32 addr, u32 reg, u32 *val)
{
- int err = -ETIMEDOUT;
+ int err;
u32 v;
mutex_lock(&smi_lock);
- if (rtl838x_smi_wait_op(100000))
- goto timeout;
+ err = rtl838x_smi_wait_op(100000);
+ if (err)
+ goto errout;
sw_w32(1 << port, RTL838X_SMI_ACCESS_PHY_CTRL_0);
mdelay(10);
@@ -1894,14 +1899,15 @@ int rtl838x_read_mmd_phy(u32 port, u32 addr, u32 reg, u32 *val)
v = 1 << 1 | 0 << 2 | 1;
sw_w32(v, RTL838X_SMI_ACCESS_PHY_CTRL_1);
- if (rtl838x_smi_wait_op(100000))
- goto timeout;
+ err = rtl838x_smi_wait_op(100000);
+ if (err)
+ goto errout;
*val = sw_r32(RTL838X_SMI_ACCESS_PHY_CTRL_2) & 0xffff;
err = 0;
-timeout:
+errout:
mutex_unlock(&smi_lock);
return err;
@@ -1910,15 +1916,16 @@ timeout:
/* Write to an mmd register of a PHY */
int rtl838x_write_mmd_phy(u32 port, u32 addr, u32 reg, u32 val)
{
- int err = -ETIMEDOUT;
+ int err;
u32 v;
pr_debug("MMD write: port %d, dev %d, reg %d, val %x\n", port, addr, reg, val);
val &= 0xffff;
mutex_lock(&smi_lock);
- if (rtl838x_smi_wait_op(100000))
- goto timeout;
+ err = rtl838x_smi_wait_op(100000);
+ if (err)
+ goto errout;
sw_w32(1 << port, RTL838X_SMI_ACCESS_PHY_CTRL_0);
mdelay(10);
@@ -1931,12 +1938,13 @@ int rtl838x_write_mmd_phy(u32 port, u32 addr, u32 reg, u32 val)
v = 1 << 1 | 1 << 2 | 1;
sw_w32(v, RTL838X_SMI_ACCESS_PHY_CTRL_1);
- if (rtl838x_smi_wait_op(100000))
- goto timeout;
+ err = rtl838x_smi_wait_op(100000);
+ if (err)
+ goto errout;
err = 0;
-timeout:
+errout:
mutex_unlock(&smi_lock);
return err;
}