]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: dsa: microchip: implement .{get/set}_wol only if needed
authorBastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Mon, 8 Jun 2026 14:10:10 +0000 (16:10 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 13 Jun 2026 01:08:07 +0000 (18:08 -0700)
All the KSZ switches use common {get/set}_wol operations while only the
ksz9477 and the ksz87xx families really support it. These operations are
optional so there is no point implementing them to return -EOPNOTSUPP.

Remove the {get/set}_wol callbacks from the switch operations for the
ksz88xx, the ksz8463 and the lan937x families.
Remove the family check from the common {get/set}_wol implementation.

Note that is_ksz9477() is only true for the KSZ9477 so this change will
also add WoL support for the other switches using the
ksz9477_switch_ops. I checked their datasheet, they implement the same
PME_WOL registers, at the same addresses, so this should go fine.
Modify the ksz_wol_pre_shutdown() initial check to ensure consistency in
the WoL handling for these non-KSZ9477 switches using ksz9477_switch_ops.

Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Link: https://patch.msgid.link/20260608-clean-ksz-3rd-v2-7-6e61b7be23c4@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/microchip/ksz8.c
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/microchip/lan937x_main.c

index c0420954cb10c600d160cc7f59ae4ff8d4d001e2..6ae0226c49a31802dcb8d85137b695dbb1c96d44 100644 (file)
@@ -2556,8 +2556,6 @@ const struct dsa_switch_ops ksz8463_switch_ops = {
        .get_pause_stats        = ksz_get_pause_stats,
        .port_change_mtu        = ksz8_change_mtu,
        .port_max_mtu           = ksz_max_mtu,
-       .get_wol                = ksz_get_wol,
-       .set_wol                = ksz_set_wol,
        .suspend                = ksz_suspend,
        .resume                 = ksz_resume,
        .get_ts_info            = ksz_get_ts_info,
@@ -2611,8 +2609,6 @@ const struct dsa_switch_ops ksz87xx_switch_ops = {
        .get_pause_stats        = ksz_get_pause_stats,
        .port_change_mtu        = ksz8_change_mtu,
        .port_max_mtu           = ksz_max_mtu,
-       .get_wol                = ksz_get_wol,
-       .set_wol                = ksz_set_wol,
        .suspend                = ksz_suspend,
        .resume                 = ksz_resume,
        .get_ts_info            = ksz_get_ts_info,
index bebf697ec60a36252ea257d51f2a6be4bd08b905..809a0bc3c01e2aaa750c2e719c204f26a253e1d7 100644 (file)
@@ -3756,9 +3756,6 @@ void ksz_get_wol(struct dsa_switch *ds, int port,
        u8 pme_ctrl;
        int ret;
 
-       if (!is_ksz9477(dev) && !ksz_is_ksz87xx(dev))
-               return;
-
        if (!dev->wakeup_source)
                return;
 
@@ -3809,9 +3806,6 @@ int ksz_set_wol(struct dsa_switch *ds, int port,
        if (wol->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
                return -EINVAL;
 
-       if (!is_ksz9477(dev) && !ksz_is_ksz87xx(dev))
-               return -EOPNOTSUPP;
-
        if (!dev->wakeup_source)
                return -EOPNOTSUPP;
 
@@ -3871,12 +3865,13 @@ static void ksz_wol_pre_shutdown(struct ksz_device *dev)
 {
        const struct ksz_dev_ops *ops = dev->dev_ops;
        const u16 *regs = dev->info->regs;
+       struct dsa_switch *ds = dev->ds;
        u8 pme_pin_en = PME_ENABLE;
        bool wol_enabled = false;
        struct dsa_port *dp;
        int ret;
 
-       if (!is_ksz9477(dev) && !ksz_is_ksz87xx(dev))
+       if (!ds->ops->set_wol)
                return;
 
        if (!dev->wakeup_source)
@@ -3924,7 +3919,8 @@ int ksz_port_set_mac_address(struct dsa_switch *ds, int port,
         */
        wol.wolopts = 0;
 
-       ksz_get_wol(ds, dp->index, &wol);
+       if (ds->ops->get_wol)
+               ds->ops->get_wol(ds, dp->index, &wol);
        if (wol.wolopts & WAKE_MAGIC) {
                dev_err(ds->dev,
                        "Cannot change MAC address on port %d with active Wake on Magic Packet\n",
index e1aba93d14385a0989b275ee9143d17698867ca6..6b1306e81558f8ef9dcb066f1ae581f2f6cb0a32 100644 (file)
@@ -893,8 +893,6 @@ const struct dsa_switch_ops lan937x_switch_ops = {
        .get_pause_stats        = ksz_get_pause_stats,
        .port_change_mtu        = lan937x_change_mtu,
        .port_max_mtu           = ksz_max_mtu,
-       .get_wol                = ksz_get_wol,
-       .set_wol                = ksz_set_wol,
        .suspend                = ksz_suspend,
        .resume                 = ksz_resume,
        .get_ts_info            = ksz_get_ts_info,