mscc: ocelot: Implement ndo_get_port_parent_id()
authorFlorian Fainelli <f.fainelli@gmail.com>
Wed, 6 Feb 2019 17:45:40 +0000 (09:45 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Feb 2019 22:16:12 +0000 (14:16 -0800)
Ocelot only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID as a valid
switchdev attribute getter, convert it to use ndo_get_port_parent_id()
and get rid of the switchdev_ops::switchdev_port_attr_get altogether.

Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mscc/ocelot.c

index c6a575e..195306d 100644 (file)
@@ -916,6 +916,18 @@ static int ocelot_set_features(struct net_device *dev,
        return 0;
 }
 
+static int ocelot_get_port_parent_id(struct net_device *dev,
+                                    struct netdev_phys_item_id *ppid)
+{
+       struct ocelot_port *ocelot_port = netdev_priv(dev);
+       struct ocelot *ocelot = ocelot_port->ocelot;
+
+       ppid->id_len = sizeof(ocelot->base_mac);
+       memcpy(&ppid->id, &ocelot->base_mac, ppid->id_len);
+
+       return 0;
+}
+
 static const struct net_device_ops ocelot_port_netdev_ops = {
        .ndo_open                       = ocelot_port_open,
        .ndo_stop                       = ocelot_port_stop,
@@ -930,6 +942,7 @@ static const struct net_device_ops ocelot_port_netdev_ops = {
        .ndo_vlan_rx_add_vid            = ocelot_vlan_rx_add_vid,
        .ndo_vlan_rx_kill_vid           = ocelot_vlan_rx_kill_vid,
        .ndo_set_features               = ocelot_set_features,
+       .ndo_get_port_parent_id         = ocelot_get_port_parent_id,
 };
 
 static void ocelot_get_strings(struct net_device *netdev, u32 sset, u8 *data)
@@ -1013,25 +1026,6 @@ static const struct ethtool_ops ocelot_ethtool_ops = {
        .set_link_ksettings     = phy_ethtool_set_link_ksettings,
 };
 
-static int ocelot_port_attr_get(struct net_device *dev,
-                               struct switchdev_attr *attr)
-{
-       struct ocelot_port *ocelot_port = netdev_priv(dev);
-       struct ocelot *ocelot = ocelot_port->ocelot;
-
-       switch (attr->id) {
-       case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-               attr->u.ppid.id_len = sizeof(ocelot->base_mac);
-               memcpy(&attr->u.ppid.id, &ocelot->base_mac,
-                      attr->u.ppid.id_len);
-               break;
-       default:
-               return -EOPNOTSUPP;
-       }
-
-       return 0;
-}
-
 static int ocelot_port_attr_stp_state_set(struct ocelot_port *ocelot_port,
                                          struct switchdev_trans *trans,
                                          u8 state)
@@ -1331,7 +1325,6 @@ static int ocelot_port_obj_del(struct net_device *dev,
 }
 
 static const struct switchdev_ops ocelot_port_switchdev_ops = {
-       .switchdev_port_attr_get        = ocelot_port_attr_get,
        .switchdev_port_attr_set        = ocelot_port_attr_set,
 };