kernel: use struct group to wipe psb6970 volatile priv data
[openwrt/openwrt.git] / target / linux / generic / files / drivers / net / phy / psb6970.c
index 97fb62ace2ab575a0fa9767a33e60404117c52aa..2587b9991384745ff5cad54524dc23e6a9e3aa43 100644 (file)
@@ -60,11 +60,13 @@ struct psb6970_priv {
        struct mutex reg_mutex;
 
        /* all fields below are cleared on reset */
-       bool vlan;
-       u16 vlan_id[PSB6970_MAX_VLANS];
-       u8 vlan_table[PSB6970_MAX_VLANS];
-       u8 vlan_tagged;
-       u16 pvid[PSB6970_NUM_PORTS];
+       struct_group(psb6970_priv_volatile,
+               bool vlan;
+               u16 vlan_id[PSB6970_MAX_VLANS];
+               u8 vlan_table[PSB6970_MAX_VLANS];
+               u8 vlan_tagged;
+               u16 pvid[PSB6970_NUM_PORTS];
+       );
 };
 
 #define to_psb6970(_dev) container_of(_dev, struct psb6970_priv, dev)
@@ -272,8 +274,8 @@ static int psb6970_reset_switch(struct switch_dev *dev)
 
        mutex_lock(&priv->reg_mutex);
 
-       memset(&priv->vlan, 0, sizeof(struct psb6970_priv) -
-              offsetof(struct psb6970_priv, vlan));
+       memset(&priv->psb6970_priv_volatile, 0,
+               sizeof(priv->psb6970_priv_volatile));
 
        for (i = 0; i < PSB6970_MAX_VLANS; i++)
                priv->vlan_id[i] = i;
@@ -307,7 +309,6 @@ static const struct switch_dev_ops psb6970_ops = {
 static int psb6970_config_init(struct phy_device *pdev)
 {
        struct psb6970_priv *priv;
-       struct net_device *dev = pdev->attached_dev;
        struct switch_dev *swdev;
        int ret;
 
@@ -326,13 +327,9 @@ static int psb6970_config_init(struct phy_device *pdev)
                return 0;
        }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
        linkmode_zero(pdev->supported);
        linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, pdev->supported);
        linkmode_copy(pdev->advertising, pdev->supported);
-#else
-       pdev->supported = pdev->advertising = SUPPORTED_100baseT_Full;
-#endif
 
        mutex_init(&priv->reg_mutex);
        priv->read = psb6970_mii_read;
@@ -359,8 +356,6 @@ static int psb6970_config_init(struct phy_device *pdev)
                goto done;
        }
 
-       dev->phy_ptr = priv;
-
 done:
        return ret;
 }