]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: dsa: ksz: implement .support_eee() method
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tue, 10 Dec 2024 14:18:47 +0000 (14:18 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 12 Dec 2024 04:29:39 +0000 (20:29 -0800)
Implement the .support_eee() method by reusing the ksz_validate_eee()
method as a template, renaming the function, changing the return type
and values, and removing it from the ksz_set_mac_eee() and
ksz_get_mac_eee() methods.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://patch.msgid.link/E1tL14Z-006cZs-6o@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/microchip/ksz_common.c

index f5822c57be32e77dd75464216877a05635750daa..94f9aa983ff67f5a4829ed68a31ace6be7093480 100644 (file)
@@ -3454,12 +3454,12 @@ static int ksz_max_mtu(struct dsa_switch *ds, int port)
        return -EOPNOTSUPP;
 }
 
-static int ksz_validate_eee(struct dsa_switch *ds, int port)
+static bool ksz_support_eee(struct dsa_switch *ds, int port)
 {
        struct ksz_device *dev = ds->priv;
 
        if (!dev->info->internal_phy[port])
-               return -EOPNOTSUPP;
+               return false;
 
        switch (dev->chip_id) {
        case KSZ8563_CHIP_ID:
@@ -3471,21 +3471,15 @@ static int ksz_validate_eee(struct dsa_switch *ds, int port)
        case KSZ9896_CHIP_ID:
        case KSZ9897_CHIP_ID:
        case LAN9646_CHIP_ID:
-               return 0;
+               return true;
        }
 
-       return -EOPNOTSUPP;
+       return false;
 }
 
 static int ksz_get_mac_eee(struct dsa_switch *ds, int port,
                           struct ethtool_keee *e)
 {
-       int ret;
-
-       ret = ksz_validate_eee(ds, port);
-       if (ret)
-               return ret;
-
        /* There is no documented control of Tx LPI configuration. */
        e->tx_lpi_enabled = true;
 
@@ -3501,11 +3495,6 @@ static int ksz_set_mac_eee(struct dsa_switch *ds, int port,
                           struct ethtool_keee *e)
 {
        struct ksz_device *dev = ds->priv;
-       int ret;
-
-       ret = ksz_validate_eee(ds, port);
-       if (ret)
-               return ret;
 
        if (!e->tx_lpi_enabled) {
                dev_err(dev->dev, "Disabling EEE Tx LPI is not supported\n");
@@ -4651,6 +4640,7 @@ static const struct dsa_switch_ops ksz_switch_ops = {
        .cls_flower_add         = ksz_cls_flower_add,
        .cls_flower_del         = ksz_cls_flower_del,
        .port_setup_tc          = ksz_setup_tc,
+       .support_eee            = ksz_support_eee,
        .get_mac_eee            = ksz_get_mac_eee,
        .set_mac_eee            = ksz_set_mac_eee,
        .port_get_default_prio  = ksz_port_get_default_prio,