Skip to content

Commit a1f8609

Browse files
Justin LaiPaolo Abeni
authored andcommitted
rtase: Refactor the rtase_check_mac_version_valid() function
Different hardware requires different configurations, but this distinction was not made previously. Additionally, the error message was not clear enough. Therefore, this patch will address the issues mentioned above. Fixes: a36e9f5 ("rtase: Add support for a pci table in this module") Signed-off-by: Justin Lai <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent ebaf813 commit a1f8609

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

drivers/net/ethernet/realtek/rtase/rtase.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
#ifndef RTASE_H
1010
#define RTASE_H
1111

12-
#define RTASE_HW_VER_MASK 0x7C800000
12+
#define RTASE_HW_VER_MASK 0x7C800000
13+
#define RTASE_HW_VER_906X_7XA 0x00800000
14+
#define RTASE_HW_VER_906X_7XC 0x04000000
15+
#define RTASE_HW_VER_907XD_V1 0x04800000
1316

1417
#define RTASE_RX_DMA_BURST_256 4
1518
#define RTASE_TX_DMA_BURST_UNLIMITED 7
@@ -327,6 +330,8 @@ struct rtase_private {
327330
u16 int_nums;
328331
u16 tx_int_mit;
329332
u16 rx_int_mit;
333+
334+
u32 hw_ver;
330335
};
331336

332337
#define RTASE_LSO_64K 64000

drivers/net/ethernet/realtek/rtase/rtase_main.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,20 +1972,21 @@ static void rtase_init_software_variable(struct pci_dev *pdev,
19721972
tp->dev->max_mtu = RTASE_MAX_JUMBO_SIZE;
19731973
}
19741974

1975-
static bool rtase_check_mac_version_valid(struct rtase_private *tp)
1975+
static int rtase_check_mac_version_valid(struct rtase_private *tp)
19761976
{
1977-
u32 hw_ver = rtase_r32(tp, RTASE_TX_CONFIG_0) & RTASE_HW_VER_MASK;
1978-
bool known_ver = false;
1977+
int ret = -ENODEV;
19791978

1980-
switch (hw_ver) {
1981-
case 0x00800000:
1982-
case 0x04000000:
1983-
case 0x04800000:
1984-
known_ver = true;
1979+
tp->hw_ver = rtase_r32(tp, RTASE_TX_CONFIG_0) & RTASE_HW_VER_MASK;
1980+
1981+
switch (tp->hw_ver) {
1982+
case RTASE_HW_VER_906X_7XA:
1983+
case RTASE_HW_VER_906X_7XC:
1984+
case RTASE_HW_VER_907XD_V1:
1985+
ret = 0;
19851986
break;
19861987
}
19871988

1988-
return known_ver;
1989+
return ret;
19891990
}
19901991

19911992
static int rtase_init_board(struct pci_dev *pdev, struct net_device **dev_out,
@@ -2105,9 +2106,12 @@ static int rtase_init_one(struct pci_dev *pdev,
21052106
tp->pdev = pdev;
21062107

21072108
/* identify chip attached to board */
2108-
if (!rtase_check_mac_version_valid(tp))
2109-
return dev_err_probe(&pdev->dev, -ENODEV,
2110-
"unknown chip version, contact rtase maintainers (see MAINTAINERS file)\n");
2109+
ret = rtase_check_mac_version_valid(tp);
2110+
if (ret != 0) {
2111+
dev_err(&pdev->dev,
2112+
"unknown chip version: 0x%08x, contact rtase maintainers (see MAINTAINERS file)\n",
2113+
tp->hw_ver);
2114+
}
21112115

21122116
rtase_init_software_variable(pdev, tp);
21132117
rtase_init_hardware(tp);

0 commit comments

Comments
 (0)