Skip to content

Commit 738de00

Browse files
committed
Merge branch 'ethtool-fix-use-of-SPEED_UNKNOWN-constant'
Michael Zhivich says: ==================== ethtool: fix use of SPEED_UNKNOWN constant This patch series addresses 2 related issues: 1. ethtool_validate_speed() triggers a "signed-unsigned comparison" warning due to type difference of SPEED_UNKNOWN constant (int) and argument to ethtool_validate_speed (__u32). 2. some drivers use u16 storage for SPEED_UNKNOWN constant, resulting in value truncation and thus failure to test against SPEED_UNKNOWN correctly. This revised series addresses several feedback comments: - split up the patch in to series - do not unnecessarily change drivers that use "int" storage for speed values ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 3c5189a + d63da85 commit 738de00

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

drivers/net/ethernet/broadcom/tg3.c

+4-4
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

+2-2
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

drivers/net/ethernet/qlogic/qlcnic/qlcnic.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ struct qlcnic_hardware_context {
497497
u16 board_type;
498498
u16 supported_type;
499499

500-
u16 link_speed;
500+
u32 link_speed;
501501
u16 link_duplex;
502502
u16 link_autoneg;
503503
u16 module_type;

include/uapi/linux/ethtool.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ enum ethtool_link_mode_bit_indices {
15911591

15921592
static inline int ethtool_validate_speed(__u32 speed)
15931593
{
1594-
return speed <= INT_MAX || speed == SPEED_UNKNOWN;
1594+
return speed <= INT_MAX || speed == (__u32)SPEED_UNKNOWN;
15951595
}
15961596

15971597
/* Duplex, half or full. */

0 commit comments

Comments
 (0)