]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: stmmac: use correct type for tx_lpi_timer
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 8 Jan 2025 16:47:44 +0000 (16:47 +0000)
committerJakub Kicinski <kuba@kernel.org>
Sat, 11 Jan 2025 01:51:00 +0000 (17:51 -0800)
The ethtool interface uses u32 for tx_lpi_timer, and so does phylib.
Use u32 to store this internally within stmmac rather than "int"
which could misinterpret large values.

Correct "value" in dwmac4_set_eee_lpi_entry_timer() to use u32
rather than int, which is derived from tx_lpi_timer. Even though this
path won't be used with values larger than STMMAC_ET_MAX, this brings
consistency of type usage to the stmmac code for this variable.

We leave eee_timer unchanged for now, with the assumption that values
up to INT_MAX will safely fit in a u32.

Tested-by: Choong Yong Liang <yong.liang.choong@linux.intel.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1tVZDc-0002Jx-3b@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
drivers/net/ethernet/stmicro/stmmac/hwif.h
drivers/net/ethernet/stmicro/stmmac/stmmac.h
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index c36f90a782c505d5f258ab3b4574b4c328281b00..9ed8620580a868099af984149344d9c588f0fdda 100644 (file)
@@ -420,10 +420,10 @@ static void dwmac4_set_eee_pls(struct mac_device_info *hw, int link)
        writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS);
 }
 
-static void dwmac4_set_eee_lpi_entry_timer(struct mac_device_info *hw, int et)
+static void dwmac4_set_eee_lpi_entry_timer(struct mac_device_info *hw, u32 et)
 {
        void __iomem *ioaddr = hw->pcsr;
-       int value = et & STMMAC_ET_MAX;
+       u32 value = et & STMMAC_ET_MAX;
        int regval;
 
        /* Program LPI entry timer value into register */
index 2f7295b6c1c54544945bcd8ac56c77bba065579a..0f200b72c2250156bc945490b086cf4b2afe64b7 100644 (file)
@@ -363,7 +363,7 @@ struct stmmac_ops {
        void (*set_eee_mode)(struct mac_device_info *hw,
                             bool en_tx_lpi_clockgating);
        void (*reset_eee_mode)(struct mac_device_info *hw);
-       void (*set_eee_lpi_entry_timer)(struct mac_device_info *hw, int et);
+       void (*set_eee_lpi_entry_timer)(struct mac_device_info *hw, u32 et);
        void (*set_eee_timer)(struct mac_device_info *hw, int ls, int tw);
        void (*set_eee_pls)(struct mac_device_info *hw, int link);
        void (*debug)(struct stmmac_priv *priv, void __iomem *ioaddr,
index 681741294e4ab5b79b1658ec7e832ff0374df168..e2584fc9ce4ee0a94ab7b71e4d1c1993bc948560 100644 (file)
@@ -307,7 +307,7 @@ struct stmmac_priv {
        int lpi_irq;
        int eee_enabled;
        int eee_active;
-       int tx_lpi_timer;
+       u32 tx_lpi_timer;
        int tx_lpi_enabled;
        int eee_tw_timer;
        bool eee_sw_timer_en;
index 0e74cd4000a3f94abc934be178ca4bb5ec6a768c..df6b0b5feec6c5172c1704fbb363ea8f3cc330bf 100644 (file)
@@ -394,11 +394,11 @@ static inline u32 stmmac_rx_dirty(struct stmmac_priv *priv, u32 queue)
 
 static void stmmac_lpi_entry_timer_config(struct stmmac_priv *priv, bool en)
 {
-       int tx_lpi_timer;
+       u32 tx_lpi_timer;
 
        /* Clear/set the SW EEE timer flag based on LPI ET enablement */
        priv->eee_sw_timer_en = en ? 0 : 1;
-       tx_lpi_timer  = en ? priv->tx_lpi_timer : 0;
+       tx_lpi_timer = en ? priv->tx_lpi_timer : 0;
        stmmac_set_eee_lpi_timer(priv, priv->hw, tx_lpi_timer);
 }