arc_emac: fix probe error path
Subsystems (3)
PATCH v2 1/2 arc_emac: fix probe error path
The probe function at the moment only frees the netdev but does not disconnect the phy or removes the mdio bus it registered.
---
changes since v1:
- fix duplicate netif_api_del found by Max Schwarz
drivers/net/ethernet/arc/emac_main.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/net/ethernet/arc/emac_main.c +14 -9
@@ -683,7 +683,7 @@ static int arc_emac_probe(struct platform_device *pdev) priv->regs =devm_ioremap_resource (&pdev->dev, &res_regs);if (IS_ERR (priv->regs)) { err =PTR_ERR (priv->regs); - goto out; + goto out_netdev; }dev_dbg (&pdev->dev,"Registers base address is 0x%p\n" , priv->regs);
@@ -693,7 +693,7 @@ static int arc_emac_probe(struct platform_device *pdev)if (!(id ==0x0005fd02 || id ==0x0007fd02 )) {dev_err (&pdev->dev,"ARC EMAC not detected, id=0x%x\n" , id); err = -ENODEV ; - goto out; + goto out_netdev; }dev_info (&pdev->dev,"ARC EMAC detected with id: 0x%x\n" , id);
@@ -708,7 +708,7 @@ static int arc_emac_probe(struct platform_device *pdev) ndev->name, ndev);if (err) {dev_err (&pdev->dev,"could not allocate IRQ\n" ); - goto out; + goto out_netdev; }/* Get MAC address from device tree */
@@ -729,7 +729,7 @@ static int arc_emac_probe(struct platform_device *pdev)if (!priv->rxbd) {dev_err (&pdev->dev,"failed to allocate data buffers\n" ); err = -ENOMEM ; - goto out; + goto out_netdev; } priv->txbd = priv->rxbd +RX_BD_NUM ;
@@ -741,7 +741,7 @@ static int arc_emac_probe(struct platform_device *pdev) err =arc_mdio_probe (pdev, priv);if (err) {dev_err (&pdev->dev,"failed to probe MII bus\n" ); - goto out; + goto out_netdev; } priv->phy_dev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0,
@@ -749,7 +749,7 @@ static int arc_emac_probe(struct platform_device *pdev)if (!priv->phy_dev) {dev_err (&pdev->dev,"of_phy_connect() failed\n" ); err = -ENODEV ; - goto out; + goto out_mdio; } dev_info(&pdev->dev, "connected to %s phy with id 0x%x\n",
@@ -759,14 +759,19 @@ static int arc_emac_probe(struct platform_device *pdev) err =register_netdev (ndev);if (err) { -netif_napi_del (&priv->napi);dev_err (&pdev->dev,"failed to register network device\n" ); - goto out; + goto out_netif_api; }return 0 ; -out: +out_netif_api: +netif_napi_del (&priv->napi); +phy_disconnect (priv->phy_dev); + priv->phy_dev =NULL ; +out_mdio: +arc_mdio_remove (priv); +out_netdev:free_netdev (ndev);return err; }
Signature · 1 line
1.9.0
PATCH v2 2/2 arc_emac: add clock handling
This adds ability for the arc_emac to really handle its supplying clock. To get the needed clock-frequency either a real clock or the previous clock-frequency property must be provided.
---
changes since v1:
- fix wrong clk error check found by Max Schwarz
Documentation/devicetree/bindings/net/arc_emac.txt | 12 +++++- drivers/net/ethernet/arc/emac.h | 2 + drivers/net/ethernet/arc/emac_main.c | 46 ++++++++++++++++------ 3 files changed, 47 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/net/arc_emac.txt +10 -2
@@ -4,11 +4,15 @@ Required properties: - compatible: Should be "snps,arc-emac" - reg: Address and length of the register set for the device - interrupts: Should contain the EMAC interrupts -- clock-frequency: CPU frequency. It is needed to calculate and set polling -period of EMAC. - max-speed: see ethernet.txt file in the same directory. - phy: see ethernet.txt file in the same directory. +Clock handling: +The clock frequency is needed to calculate and set polling period of EMAC. +It must be provided by one of: +- clock-frequency: CPU frequency. +- clocks: reference to the clock supplying the EMAC. + Child nodes of the driver are the individual PHY devices connected to the MDIO bus. They must have a "reg" property given the PHY address on the MDIO bus.
@@ -19,7 +23,11 @@ Examples: reg = <0xc0fc2000 0x3c>; interrupts = <6>; mac-address = [ 00 11 22 33 44 55 ]; + clock-frequency = <80000000>; + /* or */ + clocks = <&emac_clock>; + max-speed = <100>; phy = <&phy0>;
drivers/net/ethernet/arc/emac.h +2 -0
@@ -11,6 +11,7 @@#include <linux/dma-mapping.h> #include <linux/netdevice.h> #include <linux/phy.h> +#include <linux/clk.h> /* STATUS and ENABLE Register bit masks */ #define TXINT_MASK (1<<0)/* Transmit interrupt */
@@ -131,6 +132,7 @@ struct arc_emac_priv {struct mii_bus *bus;void __iomem *regs; +struct clk *clk;struct napi_struct napi;struct net_device_stats stats;
drivers/net/ethernet/arc/emac_main.c +35 -11
94 lines not on this page · raw message
Signature · 1 line
1.9.0
Re: [PATCH v2 2/2] arc_emac: add clock handling
From: Heiko Stübner <[email protected]>
Date: Fri, 25 Apr 2014 10:06:13 +0200
Quoted 6 lines
This adds ability for the
arc_emacto really handle its supplying clock. To get the needed clock-frequency either a real clock or the previous clock-frequency property must be provided.Signed-off-by Heiko Stuebner <[email protected]>Tested-by Max Schwarz <[email protected]>
Applied.
From: Heiko Stübner <[email protected]>
Date: Fri, 25 Apr 2014 10:03:29 +0200
Quoted 4 lines
The probe function at the moment only frees the netdev but does not disconnect the phy or removes the mdio bus it registered.
Signed-off-by Heiko Stuebner <[email protected]>
Applied.