]> git.baikalelectronics.ru Git - kernel.git/commitdiff
phy: make phy_set_max_speed() *void*
authorSergey Shtylyov <s.shtylyov@omp.ru>
Fri, 28 Jan 2022 18:32:40 +0000 (21:32 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 31 Jan 2022 11:30:56 +0000 (11:30 +0000)
After following the call tree of phy_set_max_speed(), it became clear
that this function never returns anything but 0, so we can change its
result type to *void* and drop the result checks from the three drivers
that actually bothered to do it...

Found by Linux Verification Center (linuxtesting.org) with the SVACE static
analysis tool.

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/renesas/ravb_main.c
drivers/net/ethernet/renesas/sh_eth.c
drivers/net/phy/aquantia_main.c
drivers/net/phy/phy-core.c
include/linux/phy.h

index b215cde68e10b5a0097dcf55e83e00b2a9d72bcb..80366661a361eb38802895d5da145a07524710ac 100644 (file)
@@ -1432,11 +1432,7 @@ static int ravb_phy_init(struct net_device *ndev)
         * at this time.
         */
        if (soc_device_match(r8a7795es10)) {
-               err = phy_set_max_speed(phydev, SPEED_100);
-               if (err) {
-                       netdev_err(ndev, "failed to limit PHY to 100Mbit/s\n");
-                       goto err_phy_disconnect;
-               }
+               phy_set_max_speed(phydev, SPEED_100);
 
                netdev_info(ndev, "limited PHY to 100Mbit/s\n");
        }
@@ -1457,8 +1453,6 @@ static int ravb_phy_init(struct net_device *ndev)
 
        return 0;
 
-err_phy_disconnect:
-       phy_disconnect(phydev);
 err_deregister_fixed_link:
        if (of_phy_is_fixed_link(np))
                of_phy_deregister_fixed_link(np);
index d947a628e16630097c520e5a6965d3747b589cff..8aa91e99227dd55cfac63541d02555dd2d89432e 100644 (file)
@@ -2026,14 +2026,8 @@ static int sh_eth_phy_init(struct net_device *ndev)
        }
 
        /* mask with MAC supported features */
-       if (mdp->cd->register_type != SH_ETH_REG_GIGABIT) {
-               int err = phy_set_max_speed(phydev, SPEED_100);
-               if (err) {
-                       netdev_err(ndev, "failed to limit PHY to 100 Mbit/s\n");
-                       phy_disconnect(phydev);
-                       return err;
-               }
-       }
+       if (mdp->cd->register_type != SH_ETH_REG_GIGABIT)
+               phy_set_max_speed(phydev, SPEED_100);
 
        phy_attached_info(phydev);
 
index 968dd43a2b1e00268dd48427511d5e574f33a9d1..a8db1a19011bde69fe9435c63ddc39c83258d413 100644 (file)
@@ -533,9 +533,7 @@ static int aqcs109_config_init(struct phy_device *phydev)
         * PMA speed ability bits are the same for all members of the family,
         * AQCS109 however supports speeds up to 2.5G only.
         */
-       ret = phy_set_max_speed(phydev, SPEED_2500);
-       if (ret)
-               return ret;
+       phy_set_max_speed(phydev, SPEED_2500);
 
        return aqr107_set_downshift(phydev, MDIO_AN_VEND_PROV_DOWNSHIFT_DFLT);
 }
index 271fc01f7f7fd8938826cf573743897229e4affe..2001f3329133361f2ba2fc895a13c6ee45a1f7fc 100644 (file)
@@ -243,7 +243,7 @@ size_t phy_speeds(unsigned int *speeds, size_t size,
        return count;
 }
 
-static int __set_linkmode_max_speed(u32 max_speed, unsigned long *addr)
+static void __set_linkmode_max_speed(u32 max_speed, unsigned long *addr)
 {
        const struct phy_setting *p;
        int i;
@@ -254,13 +254,11 @@ static int __set_linkmode_max_speed(u32 max_speed, unsigned long *addr)
                else
                        break;
        }
-
-       return 0;
 }
 
-static int __set_phy_supported(struct phy_device *phydev, u32 max_speed)
+static void __set_phy_supported(struct phy_device *phydev, u32 max_speed)
 {
-       return __set_linkmode_max_speed(max_speed, phydev->supported);
+       __set_linkmode_max_speed(max_speed, phydev->supported);
 }
 
 /**
@@ -273,17 +271,11 @@ static int __set_phy_supported(struct phy_device *phydev, u32 max_speed)
  * is connected to a 1G PHY. This function allows the MAC to indicate its
  * maximum speed, and so limit what the PHY will advertise.
  */
-int phy_set_max_speed(struct phy_device *phydev, u32 max_speed)
+void phy_set_max_speed(struct phy_device *phydev, u32 max_speed)
 {
-       int err;
-
-       err = __set_phy_supported(phydev, max_speed);
-       if (err)
-               return err;
+       __set_phy_supported(phydev, max_speed);
 
        phy_advertise_supported(phydev);
-
-       return 0;
 }
 EXPORT_SYMBOL(phy_set_max_speed);
 
@@ -440,7 +432,9 @@ int phy_speed_down_core(struct phy_device *phydev)
        if (min_common_speed == SPEED_UNKNOWN)
                return -EINVAL;
 
-       return __set_linkmode_max_speed(min_common_speed, phydev->advertising);
+       __set_linkmode_max_speed(min_common_speed, phydev->advertising);
+
+       return 0;
 }
 
 static void mmd_phy_indirect(struct mii_bus *bus, int phy_addr, int devad,
index 6de8d7a90d78e6cc2d7699ac491c110748b33b63..cd08cf1a8b0de41755a6a813decb6d2f28670498 100644 (file)
@@ -1661,7 +1661,7 @@ int phy_disable_interrupts(struct phy_device *phydev);
 void phy_request_interrupt(struct phy_device *phydev);
 void phy_free_interrupt(struct phy_device *phydev);
 void phy_print_status(struct phy_device *phydev);
-int phy_set_max_speed(struct phy_device *phydev, u32 max_speed);
+void phy_set_max_speed(struct phy_device *phydev, u32 max_speed);
 void phy_remove_link_mode(struct phy_device *phydev, u32 link_mode);
 void phy_advertise_supported(struct phy_device *phydev);
 void phy_support_sym_pause(struct phy_device *phydev);