Skip to content

Commit caf2c52

Browse files
michaelzhivichdavem330
authored andcommitted
broadcom: tg3: fix use of SPEED_UNKNOWN ethtool constant
tg3 driver uses u16 to store SPEED_UKNOWN ethtool constant, which is defined as -1, resulting in value truncation and thus incorrect test results against SPEED_UNKNOWN. For example, the following test will print "False": u16 speed = SPEED_UNKNOWN; if (speed == SPEED_UNKNOWN) printf("True"); else printf("False"); Change storage of speed to use u32 to avoid this issue. Signed-off-by: Michael Zhivich <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent afe6424 commit caf2c52

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

drivers/net/ethernet/broadcom/tg3.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4283,7 +4283,7 @@ static void tg3_power_down(struct tg3 *tp)
42834283
pci_set_power_state(tp->pdev, PCI_D3hot);
42844284
}
42854285

4286-
static void tg3_aux_stat_to_speed_duplex(struct tg3 *tp, u32 val, u16 *speed, u8 *duplex)
4286+
static void tg3_aux_stat_to_speed_duplex(struct tg3 *tp, u32 val, u32 *speed, u8 *duplex)
42874287
{
42884288
switch (val & MII_TG3_AUX_STAT_SPDMASK) {
42894289
case MII_TG3_AUX_STAT_10HALF:
@@ -4787,7 +4787,7 @@ static int tg3_setup_copper_phy(struct tg3 *tp, bool force_reset)
47874787
bool current_link_up;
47884788
u32 bmsr, val;
47894789
u32 lcl_adv, rmt_adv;
4790-
u16 current_speed;
4790+
u32 current_speed;
47914791
u8 current_duplex;
47924792
int i, err;
47934793

@@ -5719,7 +5719,7 @@ static bool tg3_setup_fiber_by_hand(struct tg3 *tp, u32 mac_status)
57195719
static int tg3_setup_fiber_phy(struct tg3 *tp, bool force_reset)
57205720
{
57215721
u32 orig_pause_cfg;
5722-
u16 orig_active_speed;
5722+
u32 orig_active_speed;
57235723
u8 orig_active_duplex;
57245724
u32 mac_status;
57255725
bool current_link_up;
@@ -5823,7 +5823,7 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, bool force_reset)
58235823
{
58245824
int err = 0;
58255825
u32 bmsr, bmcr;
5826-
u16 current_speed = SPEED_UNKNOWN;
5826+
u32 current_speed = SPEED_UNKNOWN;
58275827
u8 current_duplex = DUPLEX_UNKNOWN;
58285828
bool current_link_up = false;
58295829
u32 local_adv, remote_adv, sgsr;

drivers/net/ethernet/broadcom/tg3.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,7 +2873,7 @@ struct tg3_tx_ring_info {
28732873
struct tg3_link_config {
28742874
/* Describes what we're trying to get. */
28752875
u32 advertising;
2876-
u16 speed;
2876+
u32 speed;
28772877
u8 duplex;
28782878
u8 autoneg;
28792879
u8 flowctrl;
@@ -2882,7 +2882,7 @@ struct tg3_link_config {
28822882
u8 active_flowctrl;
28832883

28842884
u8 active_duplex;
2885-
u16 active_speed;
2885+
u32 active_speed;
28862886
u32 rmt_adv;
28872887
};
28882888

0 commit comments

Comments
 (0)