net: bcmgenet: utilize MDIO unimac driver
Subsystems (4)
cover net: bcmgenet: utilize MDIO unimac driver
Hi all,
This patch series migrates the Broadcom GENET driver to use the mdio-bcm-unimac driver. This MDIO HW is the same as the one GENET internally embedds, yet for historical reasons the two drivers lived their own lives. Because of the GENET interrupt situation, we let it specify how it wants to signal MDIO operations completion using its driver-private waitqueue.
The diffstat is not super impressive, but it's still negative! This would make it easier in the future to absorb possible workarounds/bugs/features within the same location.
This was tested on BCM7260 (GENETv5, single instance), BCM7439 (GENETv4, triple instance) and BCM7445 (bcm_sf2 + mdio-bcm-unimac).
We also now have a nice /proc/iomem output:
f0b00000-f0b0fc4b : /rdb/ethernet@f0b00000
f0b00e14-f0b00e1c : unimac-mdio.0
f0b20000-f0b2fc4b : /rdb/ethernet@f0b20000
f0b20e14-f0b20e1c : unimac-mdio.1
f0b40000-f0b4fc4b : /rdb/ethernet@f0b40000
f0b40e14-f0b40e1c : unimac-mdio.2
Florian Fainelli (7):
net: phy: mdio-bcm-unimac: factor busy polling loop
net: phy: mdio-bcm-unimac: create unique bus names
net: phy: mdio-bcm-unimac: Add debug print for PHY workaround
net: phy: mdio-bcm-unimac: Allow specifying platform data
net: bcmgenet: utilize generic Broadcom UniMAC MDIO controller driver
net: bcmgenet: Drop legacy MDIO code
net: bcmgenet: Utilize bcmgenet_mii_exit() for error path
MAINTAINERS | 1 + drivers/net/ethernet/broadcom/Kconfig | 1 + drivers/net/ethernet/broadcom/genet/bcmgenet.h | 1 + drivers/net/ethernet/broadcom/genet/bcmmii.c | 256 ++++++++++--------------- drivers/net/phy/mdio-bcm-unimac.c | 71 ++++--- include/linux/platform_data/mdio-bcm-unimac.h | 13 ++ 6 files changed, 163 insertions(+), 180 deletions(-) create mode 100644 include/linux/platform_data/mdio-bcm-unimac.h
Signature · 1 line
2.9.3
PATCH 1/7 net: phy: mdio-bcm-unimac: factor busy polling loop
Factor the code that does the busy polling on the MDIO_BUSY bit since we will have different code-paths for for completion depending on whether we are using interrupts or polling.
--- drivers/net/phy/mdio-bcm-unimac.c | 43 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 22 deletions(-)
drivers/net/phy/mdio-bcm-unimac.c +21 -22
@@ -57,10 +57,26 @@ static inline unsigned int unimac_mdio_busy(struct unimac_mdio_priv *priv)return __raw_readl (priv->base +MDIO_CMD ) &MDIO_START_BUSY ; } +static int unimac_mdio_poll (struct unimac_mdio_priv *priv) +{ +unsigned int timeout =1000 ; + +do { +if (!unimac_mdio_busy (priv)) +return 0 ; + +usleep_range (1000 ,2000 ); + }while (timeout--); + +if (!timeout) +return -ETIMEDOUT ; + +return 0 ; +} +static int unimac_mdio_read (struct mii_bus *bus,int phy_id,int reg) {struct unimac_mdio_priv *priv = bus->priv; -unsigned int timeout =1000 ;u32 cmd;/* Prepare the read operation */
@@ -70,15 +86,9 @@ static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg)/* Start MDIO transaction */ unimac_mdio_start (priv); -do { -if (!unimac_mdio_busy (priv)) -break ; - -usleep_range (1000 ,2000 ); - }while (timeout--); - -if (!timeout) -return -ETIMEDOUT ; + ret =unimac_mdio_poll (priv); +if (ret) +return ret; cmd =__raw_readl (priv->base +MDIO_CMD );
@@ -97,7 +107,6 @@ static int unimac_mdio_write(struct mii_bus *bus, int phy_id, int reg, u16 val) {struct unimac_mdio_priv *priv = bus->priv; -unsigned int timeout =1000 ;u32 cmd;/* Prepare the write operation */
@@ -107,17 +116,7 @@ static int unimac_mdio_write(struct mii_bus *bus, int phy_id,unimac_mdio_start (priv); -do { -if (!unimac_mdio_busy (priv)) -break ; - -usleep_range (1000 ,2000 ); - }while (timeout--); - -if (!timeout) -return -ETIMEDOUT ; - -return 0 ; +return unimac_mdio_poll (priv); }/* Workaround for integrated BCM7xxx Gigabit PHYs which have a problem with
Signature · 1 line
2.9.3
kbuild test robot
build botRe: [PATCH net-next 1/7] net: phy: mdio-bcm-unimac: factor busy polling loop
url: https://github.com/0day-ci/linux/commits/Florian-Fainelli/net-bcmgenet-utilize-MDIO-unimac-driver/20170801-075847 config: xtensa-allmodconfig (attached as .config) compiler: xtensa-linux-gcc…
Hi Florian,
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Florian-Fainelli/net-bcmgenet-utilize-MDIO-unimac-driver/20170801-075847
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa
Note: the linux-review/Florian-Fainelli/net-bcmgenet-utilize-MDIO-unimac-driver/20170801-075847 HEAD 68043f6ab1b54d29abc5555fc56fdec46d280b76 builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
drivers/net/phy/mdio-bcm-unimac.c: In function 'unimac_mdio_read':
>> drivers/net/phy/mdio-bcm-unimac.c:89:2: error: 'ret' undeclared (first use in this function)
ret = unimac_mdio_poll(priv);
^ drivers/net/phy/mdio-bcm-unimac.c:89:2: note: each undeclared identifier is reported only once for each function it appears in
vim +/ret +89 drivers/net/phy/mdio-bcm-unimac.c
76
77 static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg)
78 {
79 struct unimac_mdio_priv *priv = bus->priv;
80 u32 cmd;
81
82 /* Prepare the read operation */
83 cmd = MDIO_RD | (phy_id << MDIO_PMD_SHIFT) | (reg << MDIO_REG_SHIFT);
84 __raw_writel(cmd, priv->base + MDIO_CMD);
85
86 /* Start MDIO transaction */
87 unimac_mdio_start(priv);
88
> 89 ret = unimac_mdio_poll(priv);
90 if (ret)
91 return ret;
92
93 cmd = __raw_readl(priv->base + MDIO_CMD);
94
95 /* Some broken devices are known not to release the line during
96 * turn-around, e.g: Broadcom BCM53125 external switches, so check for
97 * that condition here and ignore the MDIO controller read failure
98 * indication.
99 */ 100 if (!(bus->phy_ignore_ta_mask & 1 << phy_id) && (cmd & MDIO_READ_FAIL))
101 return -EIO;
102
103 return cmd & 0xffff;
104 }
105
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH net-next 1/7] net: phy: mdio-bcm-unimac: factor busy polling loop
Quoted 18 lines · kbuild test robot
Hi Florian,
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Florian-Fainelli/net-bcmgenet-utilize-MDIO-unimac-driver/20170801-075847
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensaNote: the linux-review/Florian-Fainelli/net-bcmgenet-utilize-MDIO-unimac-driver/20170801-075847 HEAD
68043f6ab1b54d29abc5555fc56fdec46d280b76builds fine.
It only hurts bisectibility.All errors (new ones prefixed by >>):
Quoted 7 lines
drivers/net/phy/mdio-bcm-unimac.c: In function 'unimac_mdio_read':Quoted 1 line
Quoted 1 line
drivers/net/phy/mdio-bcm-unimac.c:89:2: error: 'ret' undeclared (first use in this function)ret = unimac_mdio_poll(priv); ^
drivers/net/phy/mdio-bcm-unimac.c:89:2: note: each undeclared identifier is reported only once for each function it appears invim +/ret +89
drivers/net/phy/mdio-bcm-unimac.c
This is "just" a bisectability problem, patch 4 does actually add the int ret variable to store the return value...
I will still fix the unmet dependency warning, depends on would actually be more correct here anyway.
Quoted 36 lines
76 77 static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg) 78 { 79 struct unimac_mdio_priv *priv = bus->priv; 80 u32 cmd; 81 82 /* Prepare the read operation */ 83 cmd = MDIO_RD | (phy_id << MDIO_PMD_SHIFT) | (reg << MDIO_REG_SHIFT); 84 __raw_writel(cmd, priv->base + MDIO_CMD); 85 86 /* Start MDIO transaction */ 87 unimac_mdio_start(priv); 88Quoted 1 line
89 ret =
unimac_mdio_poll(priv);90 if (ret) 91 return ret; 92 93 cmd = __raw_readl(priv->base + MDIO_CMD); 94 95 /* Some broken devices are known not to release the line during 96 * turn-around, e.g: Broadcom BCM53125 external switches, so check for 97 * that condition here and ignore the MDIO controller read failure 98 * indication. 99 */ 100 if (!(bus->phy_ignore_ta_mask & 1 << phy_id) && (cmd & MDIO_READ_FAIL)) 101 return -EIO; 102 103 return cmd & 0xffff; 104 } 105---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Signature · 1 line
Florian
PATCH 2/7 net: phy: mdio-bcm-unimac: create unique bus names
In reply to Florian FainelliIn preparation for having multiple GENET instances in a system (up to 3), make sure that we do include the bus instance number in the name of the MDIO bus such that we change it from "unimac-mdio" to "unimac-mdio-0" for instance.
So far, the only user of this driver is using Device Tree, which uses a lookup/parenting based technique to map PHY devices to their respective MDIO bus controllers, hence causing no additional changes.
--- drivers/net/phy/mdio-bcm-unimac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/mdio-bcm-unimac.c +1 -1
@@ -197,7 +197,7 @@ static int unimac_mdio_probe(struct platform_device *pdev) bus->read = unimac_mdio_read; bus->write = unimac_mdio_write; bus->reset = unimac_mdio_reset; -snprintf (bus->id,MII_BUS_ID_SIZE ,"%s" , pdev->name); +snprintf (bus->id,MII_BUS_ID_SIZE ,"%s-%d" , pdev->name, pdev->id); ret =of_mdiobus_register (bus, np);if (ret) {
Signature · 1 line
2.9.3
PATCH 3/7 net: phy: mdio-bcm-unimac: Add debug print for PHY workaround
In reply to Florian FainelliIn order to be stricly identical to what bcmgenet does, add a debug print when a PHY workaround during bus->reset() is executed. Preliminary change to moving bcmgenet towards mdio-bcm-unimac.
--- drivers/net/phy/mdio-bcm-unimac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/phy/mdio-bcm-unimac.c +3 -1
@@ -154,8 +154,10 @@ static int unimac_mdio_reset(struct mii_bus *bus) }for (addr =0 ; addr <PHY_MAX_ADDR ; addr++) { -if (read_mask &1 << addr) +if (read_mask &1 << addr) { +dev_dbg (&bus->dev,"Workaround for PHY @ %d\n" , addr);mdiobus_read (bus, addr,MII_BMSR ); + } }return 0 ;
Signature · 1 line
2.9.3
PATCH 4/7 net: phy: mdio-bcm-unimac: Allow specifying platform data
In reply to Florian FainelliIn preparation for having the bcmgenet driver migrate over the mdio-bcm-unimac driver, add a platform data structure which allows passing integrating specific details like bus name, wait function to complete MDIO operations and PHY mask.
We also define what the platform device name contract is by defining UNIMAC_MDIO_DRV_NAME and moving it to the platform_data header.
--- MAINTAINERS | 1 + drivers/net/phy/mdio-bcm-unimac.c | 28 +++++++++++++++++++++------ include/linux/platform_data/mdio-bcm-unimac.h | 13 +++++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 include/linux/platform_data/mdio-bcm-unimac.h
MAINTAINERS +1 -0
@@ -5140,6 +5140,7 @@ L: [email protected] S: Maintained F: include/linux/phy.h F: include/linux/phy_fixed.h +F: include/linux/platform_data/mdio-bcm-unimac.h F: drivers/net/phy/ F: Documentation/networking/phy.txt F: drivers/of/of_mdio.c
drivers/net/phy/mdio-bcm-unimac.c +22 -6
@@ -21,6 +21,8 @@#include <linux/of_platform.h> #include <linux/of_mdio.h> +#include <linux/platform_data/mdio-bcm-unimac.h> +#define MDIO_CMD 0x00#define MDIO_START_BUSY (1 << 29)#define MDIO_READ_FAIL (1 << 28)
@@ -41,6 +43,8 @@struct unimac_mdio_priv {struct mii_bus *mii_bus;void __iomem *base; +int (*wait_func) (void *wait_func_data); +void *wait_func_data; };static inline void unimac_mdio_start (struct unimac_mdio_priv *priv)
@@ -57,8 +61,9 @@ static inline unsigned int unimac_mdio_busy(struct unimac_mdio_priv *priv)return __raw_readl (priv->base +MDIO_CMD ) &MDIO_START_BUSY ; } -static int unimac_mdio_poll (struct unimac_mdio_priv *priv) +static int unimac_mdio_poll (void *wait_func_data) { +struct unimac_mdio_priv *priv = wait_func_data;unsigned int timeout =1000 ; do {
@@ -77,6 +82,7 @@ static int unimac_mdio_poll(struct unimac_mdio_priv *priv)static int unimac_mdio_read (struct mii_bus *bus,int phy_id,int reg) {struct unimac_mdio_priv *priv = bus->priv; +int ret;u32 cmd;/* Prepare the read operation */
@@ -86,7 +92,7 @@ static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg)/* Start MDIO transaction */ unimac_mdio_start (priv); - ret =unimac_mdio_poll (priv); + ret = priv->wait_func (priv->wait_func_data);if (ret)return ret;
@@ -116,7 +122,7 @@ static int unimac_mdio_write(struct mii_bus *bus, int phy_id,unimac_mdio_start (priv); -return unimac_mdio_poll (priv); +return priv->wait_func (priv->wait_func_data); }/* Workaround for integrated BCM7xxx Gigabit PHYs which have a problem with
@@ -165,6 +171,7 @@ static int unimac_mdio_reset(struct mii_bus *bus)static int unimac_mdio_probe (struct platform_device *pdev) { +struct unimac_mdio_pdata *pdata = pdev->dev.platform_data;struct unimac_mdio_priv *priv;struct device_node *np;struct mii_bus *bus;
@@ -194,7 +201,16 @@ static int unimac_mdio_probe(struct platform_device *pdev) bus = priv->mii_bus; bus->priv = priv; - bus->name ="unimac MII bus" ; +if (pdata) { + bus->name = pdata->bus_name; + priv->wait_func = pdata->wait_func; + priv->wait_func_data = pdata->wait_func_data; + bus->phy_mask = ~pdata->phy_mask; + }else { + bus->name ="unimac MII bus" ; + priv->wait_func_data = priv; + priv->wait_func = unimac_mdio_poll; + } bus->parent = &pdev->dev; bus->read = unimac_mdio_read; bus->write = unimac_mdio_write;
@@ -241,7 +257,7 @@ MODULE_DEVICE_TABLE(of, unimac_mdio_ids);static struct platform_driver unimac_mdio_driver = { .driver = { - .name ="unimac-mdio" , + .name =UNIMAC_MDIO_DRV_NAME , .of_match_table = unimac_mdio_ids, }, .probe = unimac_mdio_probe,
@@ -252,4 +268,4 @@ module_platform_driver(unimac_mdio_driver);MODULE_AUTHOR ("Broadcom Corporation" );MODULE_DESCRIPTION ("Broadcom UniMAC MDIO bus controller" );MODULE_LICENSE ("GPL" ); -MODULE_ALIAS ("platform:unimac-mdio" ); +MODULE_ALIAS ("platform:" UNIMAC_MDIO_DRV_NAME );
include/linux/platform_data/mdio-bcm-unimac.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef __MDIO_BCM_UNIMAC_PDATA_H +#define __MDIO_BCM_UNIMAC_PDATA_H + +struct unimac_mdio_pdata { +u32 phy_mask; +int (*wait_func)(void *data); +void *wait_func_data; +const char *bus_name; +}; + +#define UNIMAC_MDIO_DRV_NAME "unimac-mdio" + +#endif /* __MDIO_BCM_UNIMAC_PDATA_H */
Signature · 1 line
2.9.3
PATCH 5/7 net: bcmgenet: utilize generic Broadcom UniMAC MDIO controller driver
In reply to Florian FainelliUpdate the GENET driver to register an UniMAC MDIO bus controller for the GENET internal MDIO bus, update the platform data code to attach the PHY to the correct MDIO bus controller.
The Device Tree portion of the code is mostly left unmodified since the lookup/binding is done via phandles and Device Tree nodes which are much more flexible in locating and binding PHYs to their respective MDIO bus controllers.
--- drivers/net/ethernet/broadcom/Kconfig | 1 + drivers/net/ethernet/broadcom/genet/bcmgenet.h | 1 + drivers/net/ethernet/broadcom/genet/bcmmii.c | 148 +++++++++++++++++++------ 3 files changed, 116 insertions(+), 34 deletions(-)
drivers/net/ethernet/broadcom/Kconfig +1 -0
@@ -65,6 +65,7 @@ config BCMGENET select PHYLIB select FIXED_PHY select BCM7XXX_PHY + select MDIO_BCM_UNIMAC help This driver supports the built-in Ethernet MACs found in the Broadcom BCM7xxx Set Top Box family chipset.
drivers/net/ethernet/broadcom/genet/bcmgenet.h +1 -0
@@ -657,6 +657,7 @@ struct bcmgenet_priv {struct clk *clk;struct platform_device *pdev; +struct platform_device *mii_pdev;/* WOL */ struct clk *clk_wol;
drivers/net/ethernet/broadcom/genet/bcmmii.c +114 -34
205 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 6/7 net: bcmgenet: Drop legacy MDIO code
In reply to Florian FainelliNow that we have fully migrated to the mdio-bcm-unimac driver, drop the legacy MDIO bus code which did duplicate a fair amount of code.
--- drivers/net/ethernet/broadcom/genet/bcmmii.c | 125 --------------------------- 1 file changed, 125 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmmii.c +0 -125
@@ -28,59 +28,6 @@#include "bcmgenet.h" -/* read a value from the MII */ -static int bcmgenet_mii_read (struct mii_bus *bus,int phy_id,int location) -{ -int ret; -struct net_device *dev = bus->priv; -struct bcmgenet_priv *priv =netdev_priv (dev); -u32 reg; - -bcmgenet_umac_writel (priv, (MDIO_RD | (phy_id <<MDIO_PMD_SHIFT ) | - (location <<MDIO_REG_SHIFT )),UMAC_MDIO_CMD ); -/* Start MDIO transaction*/ - reg =bcmgenet_umac_readl (priv,UMAC_MDIO_CMD ); - reg |=MDIO_START_BUSY ; -bcmgenet_umac_writel (priv, reg,UMAC_MDIO_CMD ); -wait_event_timeout (priv->wq, - !(bcmgenet_umac_readl (priv,UMAC_MDIO_CMD ) - &MDIO_START_BUSY ), -HZ /100 ); - ret =bcmgenet_umac_readl (priv,UMAC_MDIO_CMD ); - -/* Some broken devices are known not to release the line during -* turn-around, e.g: Broadcom BCM53125 external switches, so check for -* that condition here and ignore the MDIO controller read failure -* indication. -*/ -if (!(bus->phy_ignore_ta_mask &1 << phy_id) && (ret &MDIO_READ_FAIL )) -return -EIO ; - -return ret &0xffff ; -} - -/* write a value to the MII */ -static int bcmgenet_mii_write (struct mii_bus *bus,int phy_id, -int location,u16 val) -{ -struct net_device *dev = bus->priv; -struct bcmgenet_priv *priv =netdev_priv (dev); -u32 reg; - -bcmgenet_umac_writel (priv, (MDIO_WR | (phy_id <<MDIO_PMD_SHIFT ) | - (location <<MDIO_REG_SHIFT ) | (0xffff & val)), -UMAC_MDIO_CMD ); - reg =bcmgenet_umac_readl (priv,UMAC_MDIO_CMD ); - reg |=MDIO_START_BUSY ; -bcmgenet_umac_writel (priv, reg,UMAC_MDIO_CMD ); -wait_event_timeout (priv->wq, - !(bcmgenet_umac_readl (priv,UMAC_MDIO_CMD ) & -MDIO_START_BUSY ), -HZ /100 ); - -return 0 ; -} -/* setup netdev link state when PHY link status change and * update UMAC and RGMII block when link up */
@@ -393,78 +340,6 @@ int bcmgenet_mii_probe(struct net_device *dev)return 0 ; } -/* Workaround for integrated BCM7xxx Gigabit PHYs which have a problem with -* their internal MDIO management controller making them fail to successfully -* be read from or written to for the first transaction. We insert a dummy -* BMSR read here to make sure that phy_get_device() and get_phy_id() can -* correctly read the PHY MII_PHYSID1/2 registers and successfully register a -* PHY device for this peripheral. -* -* Once the PHY driver is registered, we can workaround subsequent reads from -* there (e.g: during system-wide power management). -* -* bus->reset is invoked before mdiobus_scan during mdiobus_register and is -* therefore the right location to stick that workaround. Since we do not want -* to read from non-existing PHYs, we either use bus->phy_mask or do a manual -* Device Tree scan to limit the search area. -*/ -static int bcmgenet_mii_bus_reset (struct mii_bus *bus) -{ -struct net_device *dev = bus->priv; -struct bcmgenet_priv *priv =netdev_priv (dev); -struct device_node *np = priv->mdio_dn; -struct device_node *child =NULL ; -u32 read_mask =0 ; -int addr =0 ; - -if (!np) { - read_mask =1 << priv->phy_addr; - }else { -for_each_available_child_of_node (np, child) { - addr =of_mdio_parse_addr (&dev->dev, child); -if (addr <0 ) -continue ; - - read_mask |=1 << addr; - } - } - -for (addr =0 ; addr <PHY_MAX_ADDR ; addr++) { -if (read_mask &1 << addr) { -dev_dbg (&dev->dev,"Workaround for PHY @ %d\n" , addr); -mdiobus_read (bus, addr,MII_BMSR ); - } - } - -return 0 ; -} - -static int bcmgenet_mii_alloc (struct bcmgenet_priv *priv) -{ -struct mii_bus *bus; - -if (priv->mii_bus) -return 0 ; - - priv->mii_bus =mdiobus_alloc (); -if (!priv->mii_bus) { -pr_err ("failed to allocate\n" ); -return -ENOMEM ; - } - - bus = priv->mii_bus; - bus->priv = priv->dev; - bus->name ="bcmgenet MII bus" ; - bus->parent = &priv->pdev->dev; - bus->read = bcmgenet_mii_read; - bus->write = bcmgenet_mii_write; - bus->reset = bcmgenet_mii_bus_reset; -snprintf (bus->id,MII_BUS_ID_SIZE ,"%s-%d" , - priv->pdev->name, priv->pdev->id); - -return 0 ; -} -static struct device_node *bcmgenet_mii_of_find_mdio (struct bcmgenet_priv *priv) {struct device_node *dn = priv->pdev->dev.of_node;
Signature · 1 line
2.9.3
PATCH 7/7 net: bcmgenet: Utilize bcmgenet_mii_exit() for error path
In reply to Florian Fainellibcmgenet_mii_init() has an error path which is strictly identical to the unwinding that bcmgenet_mii_exit() does, so have bcmgenet_mii_init() utilize bcmgenet_mii_exit() for that.
--- drivers/net/ethernet/broadcom/genet/bcmmii.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmmii.c +1 -6
@@ -563,7 +563,6 @@ static int bcmgenet_mii_bus_init(struct bcmgenet_priv *priv)int bcmgenet_mii_init (struct net_device *dev) {struct bcmgenet_priv *priv =netdev_priv (dev); -struct device_node *dn = priv->pdev->dev.of_node;int ret; ret =bcmgenet_mii_register (priv);
@@ -577,11 +576,7 @@ int bcmgenet_mii_init(struct net_device *dev)return 0 ; out: -if (of_phy_is_fixed_link (dn)) -of_phy_deregister_fixed_link (dn); -of_node_put (priv->phy_dn); -platform_device_unregister (priv->mii_pdev); -platform_device_put (priv->mii_pdev); +bcmgenet_mii_exit (dev);return ret; }
Signature · 1 line
2.9.3
From: Florian Fainelli <[email protected]>
Date: Mon, 31 Jul 2017 12:04:21 -0700
Quoted 15 lines
Hi all,
This patch series migrates the Broadcom GENET driver to use the mdio-bcm-unimac driver. This MDIO HW is the same as the one GENET internally embedds, yet for historical reasons the two drivers lived their own lives. Because of the GENET interrupt situation, we let it specify how it wants to signal MDIO operations completion using its driver-private waitqueue.
The diffstat is not super impressive, but it's still negative! This would make it easier in the future to absorb possible workarounds/bugs/features within the same location.
This was tested on BCM7260 (GENETv5, single instance), BCM7439 (GENETv4, triple instance) and BCM7445 (
bcm_sf2+ mdio-bcm-unimac).
Quoted 8 lines
We also now have a nice
/proc/iomemoutput:f0b00000-f0b0fc4b : /rdb/ethernet@f0b00000
f0b00e14-f0b00e1c : unimac-mdio.0
f0b20000-f0b2fc4b : /rdb/ethernet@f0b20000
f0b20e14-f0b20e1c : unimac-mdio.1
f0b40000-f0b4fc4b : /rdb/ethernet@f0b40000
f0b40e14-f0b40e1c : unimac-mdio.2
I love cleanups like this... even if the diffstat breaks even :-)
Applied, thanks.