{"id":817677,"url":"http://patchwork.ozlabs.org/api/patches/817677/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170922194045.18814-2-vivien.didelot@savoirfairelinux.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170922194045.18814-2-vivien.didelot@savoirfairelinux.com>","list_archive_url":null,"date":"2017-09-22T19:40:43","name":"[net-next,v2,1/3] net: dsa: use slave device phydev","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":true,"hash":"fc2bcce86b2296db8cbdfc1cdf92aa9d4e1485a4","submitter":{"id":15889,"url":"http://patchwork.ozlabs.org/api/people/15889/?format=json","name":"Vivien Didelot","email":"vivien.didelot@savoirfairelinux.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170922194045.18814-2-vivien.didelot@savoirfairelinux.com/mbox/","series":[{"id":4699,"url":"http://patchwork.ozlabs.org/api/series/4699/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=4699","date":"2017-09-22T19:40:43","name":"net: dsa: use slave device phydev","version":2,"mbox":"http://patchwork.ozlabs.org/series/4699/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/817677/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/817677/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xzP802hKnz9sxR\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 23 Sep 2017 05:44:48 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752005AbdIVTo2 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 22 Sep 2017 15:44:28 -0400","from mail.savoirfairelinux.com ([208.88.110.44]:53344 \"EHLO\n\tmail.savoirfairelinux.com\" rhost-flags-OK-OK-OK-OK) by\n\tvger.kernel.org with ESMTP id S1751852AbdIVTo0 (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Fri, 22 Sep 2017 15:44:26 -0400","from localhost (localhost [127.0.0.1])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTP id BFC2C9C2D08;\n\tFri, 22 Sep 2017 15:44:25 -0400 (EDT)","from mail.savoirfairelinux.com ([127.0.0.1])\n\tby localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new,\n\tport 10032)\n\twith ESMTP id fm3BXDR-SJzg; Fri, 22 Sep 2017 15:44:25 -0400 (EDT)","from localhost (localhost [127.0.0.1])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTP id E34F49C2D13;\n\tFri, 22 Sep 2017 15:44:24 -0400 (EDT)","from mail.savoirfairelinux.com ([127.0.0.1])\n\tby localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new,\n\tport 10026)\n\twith ESMTP id v5_X4V1mUsO9; Fri, 22 Sep 2017 15:44:24 -0400 (EDT)","from weeman.mtl.sfl (unknown [192.168.49.104])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTPSA id A30A09C28FF;\n\tFri, 22 Sep 2017 15:44:24 -0400 (EDT)"],"X-Virus-Scanned":"amavisd-new at mail.savoirfairelinux.com","From":"Vivien Didelot <vivien.didelot@savoirfairelinux.com>","To":"netdev@vger.kernel.org","Cc":"linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com,\n\t\"David S. Miller\" <davem@davemloft.net>,\n\tFlorian Fainelli <f.fainelli@gmail.com>, Andrew Lunn <andrew@lunn.ch>,\n\tVivien Didelot <vivien.didelot@savoirfairelinux.com>","Subject":"[PATCH net-next v2 1/3] net: dsa: use slave device phydev","Date":"Fri, 22 Sep 2017 15:40:43 -0400","Message-Id":"<20170922194045.18814-2-vivien.didelot@savoirfairelinux.com>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20170922194045.18814-1-vivien.didelot@savoirfairelinux.com>","References":"<20170922194045.18814-1-vivien.didelot@savoirfairelinux.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"There is no need to store a phy_device in dsa_slave_priv since\nnet_device already provides one. Simply s/p->phy/dev->phydev/.\n\nWhile at it, return -ENODEV when it is NULL instead of -EOPNOTSUPP.\n\nSigned-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>\n---\n net/dsa/slave.c | 126 ++++++++++++++++++++++++++------------------------------\n 1 file changed, 58 insertions(+), 68 deletions(-)","diff":"diff --git a/net/dsa/slave.c b/net/dsa/slave.c\nindex 02ace7d462c4..3760472bf41d 100644\n--- a/net/dsa/slave.c\n+++ b/net/dsa/slave.c\n@@ -99,15 +99,15 @@ static int dsa_slave_open(struct net_device *dev)\n \t}\n \n \tif (ds->ops->port_enable) {\n-\t\terr = ds->ops->port_enable(ds, p->dp->index, p->phy);\n+\t\terr = ds->ops->port_enable(ds, p->dp->index, dev->phydev);\n \t\tif (err)\n \t\t\tgoto clear_promisc;\n \t}\n \n \tdsa_port_set_state_now(p->dp, stp_state);\n \n-\tif (p->phy)\n-\t\tphy_start(p->phy);\n+\tif (dev->phydev)\n+\t\tphy_start(dev->phydev);\n \n \treturn 0;\n \n@@ -130,8 +130,8 @@ static int dsa_slave_close(struct net_device *dev)\n \tstruct net_device *master = dsa_master_netdev(p);\n \tstruct dsa_switch *ds = p->dp->ds;\n \n-\tif (p->phy)\n-\t\tphy_stop(p->phy);\n+\tif (dev->phydev)\n+\t\tphy_stop(dev->phydev);\n \n \tdev_mc_unsync(master, dev);\n \tdev_uc_unsync(master, dev);\n@@ -144,7 +144,7 @@ static int dsa_slave_close(struct net_device *dev)\n \t\tdev_uc_del(master, dev->dev_addr);\n \n \tif (ds->ops->port_disable)\n-\t\tds->ops->port_disable(ds, p->dp->index, p->phy);\n+\t\tds->ops->port_disable(ds, p->dp->index, dev->phydev);\n \n \tdsa_port_set_state_now(p->dp, BR_STATE_DISABLED);\n \n@@ -273,12 +273,10 @@ dsa_slave_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,\n \n static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)\n {\n-\tstruct dsa_slave_priv *p = netdev_priv(dev);\n+\tif (!dev->phydev)\n+\t\treturn -ENODEV;\n \n-\tif (p->phy != NULL)\n-\t\treturn phy_mii_ioctl(p->phy, ifr, cmd);\n-\n-\treturn -EOPNOTSUPP;\n+\treturn phy_mii_ioctl(dev->phydev, ifr, cmd);\n }\n \n static int dsa_slave_port_attr_set(struct net_device *dev,\n@@ -435,12 +433,10 @@ static int\n dsa_slave_get_link_ksettings(struct net_device *dev,\n \t\t\t     struct ethtool_link_ksettings *cmd)\n {\n-\tstruct dsa_slave_priv *p = netdev_priv(dev);\n+\tif (!dev->phydev)\n+\t\treturn -ENODEV;\n \n-\tif (!p->phy)\n-\t\treturn -EOPNOTSUPP;\n-\n-\tphy_ethtool_ksettings_get(p->phy, cmd);\n+\tphy_ethtool_ksettings_get(dev->phydev, cmd);\n \n \treturn 0;\n }\n@@ -449,12 +445,10 @@ static int\n dsa_slave_set_link_ksettings(struct net_device *dev,\n \t\t\t     const struct ethtool_link_ksettings *cmd)\n {\n-\tstruct dsa_slave_priv *p = netdev_priv(dev);\n+\tif (!dev->phydev)\n+\t\treturn -ENODEV;\n \n-\tif (p->phy != NULL)\n-\t\treturn phy_ethtool_ksettings_set(p->phy, cmd);\n-\n-\treturn -EOPNOTSUPP;\n+\treturn phy_ethtool_ksettings_set(dev->phydev, cmd);\n }\n \n static void dsa_slave_get_drvinfo(struct net_device *dev,\n@@ -488,24 +482,20 @@ dsa_slave_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *_p)\n \n static int dsa_slave_nway_reset(struct net_device *dev)\n {\n-\tstruct dsa_slave_priv *p = netdev_priv(dev);\n+\tif (!dev->phydev)\n+\t\treturn -ENODEV;\n \n-\tif (p->phy != NULL)\n-\t\treturn genphy_restart_aneg(p->phy);\n-\n-\treturn -EOPNOTSUPP;\n+\treturn genphy_restart_aneg(dev->phydev);\n }\n \n static u32 dsa_slave_get_link(struct net_device *dev)\n {\n-\tstruct dsa_slave_priv *p = netdev_priv(dev);\n+\tif (!dev->phydev)\n+\t\treturn -ENODEV;\n \n-\tif (p->phy != NULL) {\n-\t\tgenphy_update_link(p->phy);\n-\t\treturn p->phy->link;\n-\t}\n+\tgenphy_update_link(dev->phydev);\n \n-\treturn -EOPNOTSUPP;\n+\treturn dev->phydev->link;\n }\n \n static int dsa_slave_get_eeprom_len(struct net_device *dev)\n@@ -640,7 +630,7 @@ static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e)\n \tint ret;\n \n \t/* Port's PHY and MAC both need to be EEE capable */\n-\tif (!p->phy)\n+\tif (!dev->phydev)\n \t\treturn -ENODEV;\n \n \tif (!ds->ops->set_mac_eee)\n@@ -651,12 +641,12 @@ static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e)\n \t\treturn ret;\n \n \tif (e->eee_enabled) {\n-\t\tret = phy_init_eee(p->phy, 0);\n+\t\tret = phy_init_eee(dev->phydev, 0);\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\n \n-\treturn phy_ethtool_set_eee(p->phy, e);\n+\treturn phy_ethtool_set_eee(dev->phydev, e);\n }\n \n static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e)\n@@ -666,7 +656,7 @@ static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e)\n \tint ret;\n \n \t/* Port's PHY and MAC both need to be EEE capable */\n-\tif (!p->phy)\n+\tif (!dev->phydev)\n \t\treturn -ENODEV;\n \n \tif (!ds->ops->get_mac_eee)\n@@ -676,7 +666,7 @@ static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e)\n \tif (ret)\n \t\treturn ret;\n \n-\treturn phy_ethtool_get_eee(p->phy, e);\n+\treturn phy_ethtool_get_eee(dev->phydev, e);\n }\n \n #ifdef CONFIG_NET_POLL_CONTROLLER\n@@ -985,26 +975,26 @@ static void dsa_slave_adjust_link(struct net_device *dev)\n \tstruct dsa_switch *ds = p->dp->ds;\n \tunsigned int status_changed = 0;\n \n-\tif (p->old_link != p->phy->link) {\n+\tif (p->old_link != dev->phydev->link) {\n \t\tstatus_changed = 1;\n-\t\tp->old_link = p->phy->link;\n+\t\tp->old_link = dev->phydev->link;\n \t}\n \n-\tif (p->old_duplex != p->phy->duplex) {\n+\tif (p->old_duplex != dev->phydev->duplex) {\n \t\tstatus_changed = 1;\n-\t\tp->old_duplex = p->phy->duplex;\n+\t\tp->old_duplex = dev->phydev->duplex;\n \t}\n \n-\tif (p->old_pause != p->phy->pause) {\n+\tif (p->old_pause != dev->phydev->pause) {\n \t\tstatus_changed = 1;\n-\t\tp->old_pause = p->phy->pause;\n+\t\tp->old_pause = dev->phydev->pause;\n \t}\n \n \tif (ds->ops->adjust_link && status_changed)\n-\t\tds->ops->adjust_link(ds, p->dp->index, p->phy);\n+\t\tds->ops->adjust_link(ds, p->dp->index, dev->phydev);\n \n \tif (status_changed)\n-\t\tphy_print_status(p->phy);\n+\t\tphy_print_status(dev->phydev);\n }\n \n static int dsa_slave_fixed_link_update(struct net_device *dev,\n@@ -1029,17 +1019,18 @@ static int dsa_slave_phy_connect(struct net_device *slave_dev, int addr)\n \tstruct dsa_slave_priv *p = netdev_priv(slave_dev);\n \tstruct dsa_switch *ds = p->dp->ds;\n \n-\tp->phy = mdiobus_get_phy(ds->slave_mii_bus, addr);\n-\tif (!p->phy) {\n+\tslave_dev->phydev = mdiobus_get_phy(ds->slave_mii_bus, addr);\n+\tif (!slave_dev->phydev) {\n \t\tnetdev_err(slave_dev, \"no phy at %d\\n\", addr);\n \t\treturn -ENODEV;\n \t}\n \n \t/* Use already configured phy mode */\n \tif (p->phy_interface == PHY_INTERFACE_MODE_NA)\n-\t\tp->phy_interface = p->phy->interface;\n-\treturn phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,\n-\t\t\t\t  p->phy_interface);\n+\t\tp->phy_interface = slave_dev->phydev->interface;\n+\n+\treturn phy_connect_direct(slave_dev, slave_dev->phydev,\n+\t\t\t\t  dsa_slave_adjust_link, p->phy_interface);\n }\n \n static int dsa_slave_phy_setup(struct net_device *slave_dev)\n@@ -1091,22 +1082,23 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)\n \t\t\t\treturn ret;\n \t\t\t}\n \t\t} else {\n-\t\t\tp->phy = of_phy_connect(slave_dev, phy_dn,\n-\t\t\t\t\t\tdsa_slave_adjust_link,\n-\t\t\t\t\t\tphy_flags,\n-\t\t\t\t\t\tp->phy_interface);\n+\t\t\tslave_dev->phydev = of_phy_connect(slave_dev, phy_dn,\n+\t\t\t\t\t\t\t   dsa_slave_adjust_link,\n+\t\t\t\t\t\t\t   phy_flags,\n+\t\t\t\t\t\t\t   p->phy_interface);\n \t\t}\n \n \t\tof_node_put(phy_dn);\n \t}\n \n-\tif (p->phy && phy_is_fixed)\n-\t\tfixed_phy_set_link_update(p->phy, dsa_slave_fixed_link_update);\n+\tif (slave_dev->phydev && phy_is_fixed)\n+\t\tfixed_phy_set_link_update(slave_dev->phydev,\n+\t\t\t\t\t  dsa_slave_fixed_link_update);\n \n \t/* We could not connect to a designated PHY, so use the switch internal\n \t * MDIO bus instead\n \t */\n-\tif (!p->phy) {\n+\tif (!slave_dev->phydev) {\n \t\tret = dsa_slave_phy_connect(slave_dev, p->dp->index);\n \t\tif (ret) {\n \t\t\tnetdev_err(slave_dev, \"failed to connect to port %d: %d\\n\",\n@@ -1117,7 +1109,7 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)\n \t\t}\n \t}\n \n-\tphy_attached_info(p->phy);\n+\tphy_attached_info(slave_dev->phydev);\n \n \treturn 0;\n }\n@@ -1137,12 +1129,12 @@ int dsa_slave_suspend(struct net_device *slave_dev)\n \n \tnetif_device_detach(slave_dev);\n \n-\tif (p->phy) {\n-\t\tphy_stop(p->phy);\n+\tif (slave_dev->phydev) {\n+\t\tphy_stop(slave_dev->phydev);\n \t\tp->old_pause = -1;\n \t\tp->old_link = -1;\n \t\tp->old_duplex = -1;\n-\t\tphy_suspend(p->phy);\n+\t\tphy_suspend(slave_dev->phydev);\n \t}\n \n \treturn 0;\n@@ -1150,13 +1142,11 @@ int dsa_slave_suspend(struct net_device *slave_dev)\n \n int dsa_slave_resume(struct net_device *slave_dev)\n {\n-\tstruct dsa_slave_priv *p = netdev_priv(slave_dev);\n-\n \tnetif_device_attach(slave_dev);\n \n-\tif (p->phy) {\n-\t\tphy_resume(p->phy);\n-\t\tphy_start(p->phy);\n+\tif (slave_dev->phydev) {\n+\t\tphy_resume(slave_dev->phydev);\n+\t\tphy_start(slave_dev->phydev);\n \t}\n \n \treturn 0;\n@@ -1249,8 +1239,8 @@ void dsa_slave_destroy(struct net_device *slave_dev)\n \tport_dn = p->dp->dn;\n \n \tnetif_carrier_off(slave_dev);\n-\tif (p->phy) {\n-\t\tphy_disconnect(p->phy);\n+\tif (slave_dev->phydev) {\n+\t\tphy_disconnect(slave_dev->phydev);\n \n \t\tif (of_phy_is_fixed_link(port_dn))\n \t\t\tof_phy_deregister_fixed_link(port_dn);\n","prefixes":["net-next","v2","1/3"]}