Skip to content

Commit 3304cdc

Browse files
Howard Wangshemminger
authored andcommitted
net/r8169: fix issues reported by Coverity
Signed-off-by: Howard Wang <[email protected]>
1 parent 7a516d3 commit 3304cdc

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

drivers/net/r8169/r8169_hw.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,16 @@ rtl_oob_mutex_lock(struct rtl_hw *hw)
346346
}
347347

348348
rtl_ocp_write(hw, ocp_reg_mutex_ib, 1, BIT_0);
349-
reg_16 = rtl_ocp_read(hw, ocp_reg_mutex_oob, 1);
349+
reg_16 = (u8)rtl_ocp_read(hw, ocp_reg_mutex_oob, 1);
350350
wait_cnt_0 = 0;
351351
while (reg_16) {
352-
reg_a0 = rtl_ocp_read(hw, ocp_reg_mutex_prio, 1);
352+
reg_a0 = (u8)rtl_ocp_read(hw, ocp_reg_mutex_prio, 1);
353353
if (reg_a0) {
354354
rtl_ocp_write(hw, ocp_reg_mutex_ib, 1, 0x00);
355-
reg_a0 = rtl_ocp_read(hw, ocp_reg_mutex_prio, 1);
355+
reg_a0 = (u8)rtl_ocp_read(hw, ocp_reg_mutex_prio, 1);
356356
wait_cnt_1 = 0;
357357
while (reg_a0) {
358-
reg_a0 = rtl_ocp_read(hw, ocp_reg_mutex_prio, 1);
358+
reg_a0 = (u8)rtl_ocp_read(hw, ocp_reg_mutex_prio, 1);
359359

360360
wait_cnt_1++;
361361

@@ -364,7 +364,7 @@ rtl_oob_mutex_lock(struct rtl_hw *hw)
364364
};
365365
rtl_ocp_write(hw, ocp_reg_mutex_ib, 1, BIT_0);
366366
}
367-
reg_16 = rtl_ocp_read(hw, ocp_reg_mutex_oob, 1);
367+
reg_16 = (u8)rtl_ocp_read(hw, ocp_reg_mutex_oob, 1);
368368

369369
wait_cnt_0++;
370370

drivers/net/r8169/r8169_phy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ rtl8168_phy_ram_code_check(struct rtl_hw *hw)
807807
retval = FALSE;
808808
}
809809

810-
retval = rtl_clear_phy_mcu_patch_request(hw);
810+
rtl_clear_phy_mcu_patch_request(hw);
811811

812812
rte_delay_ms(2);
813813
}

drivers/net/r8169/r8169_rxtx.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,9 +1707,6 @@ rtl8125_tx_clean(struct rtl_hw *hw, struct rtl_tx_queue *txq)
17071707
uint32_t tx_left;
17081708
uint32_t tx_desc_closed;
17091709

1710-
if (!txq)
1711-
return;
1712-
17131710
if (enable_tx_no_close) {
17141711
txq->NextHwDesCloPtr = rtl_get_hw_clo_ptr(txq);
17151712
tx_desc_closed = rtl_fast_mod_mask(txq->NextHwDesCloPtr -
@@ -1755,9 +1752,6 @@ rtl8168_tx_clean(struct rtl_hw *hw __rte_unused, struct rtl_tx_queue *txq)
17551752
int head = txq->tx_head;
17561753
uint16_t desc_freed = 0;
17571754

1758-
if (!txq)
1759-
return;
1760-
17611755
while (1) {
17621756
txd = &txq->hw_ring[head];
17631757

@@ -1794,13 +1788,13 @@ static int
17941788
rtl8125_tx_done_cleanup(void *tx_queue, uint32_t free_cnt)
17951789
{
17961790
struct rtl_tx_queue *txq = tx_queue;
1797-
struct rtl_hw *hw = txq->hw;
1798-
struct rtl_tx_entry *sw_ring = txq->sw_ring;
1791+
struct rtl_hw *hw;
1792+
struct rtl_tx_entry *sw_ring;
17991793
struct rtl_tx_entry *txe;
18001794
struct rtl_tx_desc *txd;
1801-
const uint8_t enable_tx_no_close = hw->EnableTxNoClose;
1802-
const uint16_t nb_tx_desc = txq->nb_tx_desc;
1803-
uint16_t head = txq->tx_head;
1795+
uint8_t enable_tx_no_close;
1796+
uint16_t nb_tx_desc;
1797+
uint16_t head;
18041798
uint16_t desc_freed = 0;
18051799
uint32_t tx_left;
18061800
uint32_t count = 0;
@@ -1810,6 +1804,12 @@ rtl8125_tx_done_cleanup(void *tx_queue, uint32_t free_cnt)
18101804
if (!txq)
18111805
return -ENODEV;
18121806

1807+
hw = txq->hw;
1808+
enable_tx_no_close = hw->EnableTxNoClose;
1809+
sw_ring = txq->sw_ring;
1810+
nb_tx_desc = txq->nb_tx_desc;
1811+
head = txq->tx_head;
1812+
18131813
if (enable_tx_no_close) {
18141814
txq->NextHwDesCloPtr = rtl_get_hw_clo_ptr(txq);
18151815
tx_desc_closed = rtl_fast_mod_mask(txq->NextHwDesCloPtr -
@@ -1860,19 +1860,24 @@ static int
18601860
rtl8168_tx_done_cleanup(void *tx_queue, uint32_t free_cnt)
18611861
{
18621862
struct rtl_tx_queue *txq = tx_queue;
1863-
struct rtl_tx_entry *sw_ring = txq->sw_ring;
1863+
struct rtl_tx_entry *sw_ring;
18641864
struct rtl_tx_entry *txe;
18651865
struct rtl_tx_desc *txd;
1866-
const uint16_t nb_tx_desc = txq->nb_tx_desc;
1867-
const int tx_tail = txq->tx_tail % nb_tx_desc;
1868-
int head = txq->tx_head;
1866+
uint16_t nb_tx_desc;
18691867
uint16_t desc_freed = 0;
1870-
int count = 0;
18711868
uint32_t status;
1869+
int tx_tail;
1870+
int head;
1871+
int count = 0;
18721872

18731873
if (!txq)
18741874
return -ENODEV;
18751875

1876+
sw_ring = txq->sw_ring;
1877+
nb_tx_desc = txq->nb_tx_desc;
1878+
tx_tail = txq->tx_tail % nb_tx_desc;
1879+
head = txq->tx_head;
1880+
18761881
while (1) {
18771882
txd = &txq->hw_ring[head];
18781883

0 commit comments

Comments
 (0)