Teach phylib hard-resetting devices
Subsystems (3)
v2 cover Teach phylib hard-resetting devices
Hello.
Here's the set of 2 patches against DaveM's 'net-next.git' repo. They add to
the 'phylib' support for resetting devices via GPIO and do some clean up after doing that...
[1/2] phylib: add device reset GPIO support
[2/2] macb: kill PHY reset code
MBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 2/2 macb: kill PHY reset code
With the 'phylib' now being aware of the "reset-gpios" PHY node property, there should be no need to frob the PHY reset in this driver anymore...
--- drivers/net/ethernet/cadence/macb.c | 17 ----------------- drivers/net/ethernet/cadence/macb.h | 1 - 2 files changed, 18 deletions(-)
drivers/net/ethernet/cadence/macb.c +0 -17
@@ -2884,7 +2884,6 @@ static int macb_probe(struct platform_de = macb_clk_init;int (*init)(struct platform_device *) = macb_init;struct device_node *np = pdev->dev.of_node; -struct device_node *phy_node;const struct macb_config *macb_config =NULL ;struct clk *pclk, *hclk =NULL , *tx_clk =NULL ;unsigned int queue_mask, num_queues;
@@ -2977,18 +2976,6 @@ static int macb_probe(struct platform_deelse macb_get_hwaddr (bp); -/* Power up the PHY if there is a GPIO reset */ - phy_node =of_get_next_available_child (np,NULL ); -if (phy_node) { -int gpio =of_get_named_gpio (phy_node,"reset-gpios" ,0 ); - -if (gpio_is_valid (gpio)) { - bp->reset_gpio =gpio_to_desc (gpio); -gpiod_direction_output (bp->reset_gpio,1 ); - } - } -of_node_put (phy_node); - err =of_get_phy_mode (np);if (err <0 ) { pdata =dev_get_platdata (&pdev->dev);
@@ -3054,10 +3041,6 @@ static int macb_remove(struct platform_dmdiobus_unregister (bp->mii_bus);mdiobus_free (bp->mii_bus); -/* Shutdown the PHY if there is a GPIO reset */ -if (bp->reset_gpio) -gpiod_set_value (bp->reset_gpio,0 ); -unregister_netdev (dev);clk_disable_unprepare (bp->tx_clk);clk_disable_unprepare (bp->hclk);
drivers/net/ethernet/cadence/macb.h +0 -1
@@ -832,7 +832,6 @@ struct macb {unsigned int dma_burst_length;phy_interface_t phy_interface; -struct gpio_desc *reset_gpio;/* AT91RM9200 transmit */ struct sk_buff *skb;/* holds skb until xmit interrupt completes */
Re: [PATCH RFT v2 2/2] macb: kill PHY reset code
Quoted 4 lines · Sergei Shtylyov
With the 'phylib' now being aware of the "reset-gpios" PHY node property, there should be no need to frob the PHY reset in this driver anymore...
Signed-off-by Sergei Shtylyov <[email protected]>
So I queue my DT patch through arm-soc.
Thanks Sergei, bye.
Quoted 61 lines
--- drivers/net/ethernet/cadence/macb.c | 17 ----------------- drivers/net/ethernet/cadence/macb.h | 1 - 2 files changed, 18 deletions(-)Index:
net-next/drivers/net/ethernet/cadence/macb.c
===================================================================drivers/net/ethernet/cadence/macb.c +0
-17@@ -2884,7 +2884,6 @@ static int macb_probe(struct platform_de = macb_clk_init;int (*init)(struct platform_device *) = macb_init;struct device_node *np = pdev->dev.of_node; -struct device_node *phy_node;const struct macb_config *macb_config =NULL ;struct clk *pclk, *hclk =NULL , *tx_clk =NULL ;unsigned int queue_mask, num_queues;@@ -2977,18 +2976,6 @@ static int macb_probe(struct platform_deelse macb_get_hwaddr (bp); -/* Power up the PHY if there is a GPIO reset */ - phy_node =of_get_next_available_child (np,NULL ); -if (phy_node) { -int gpio =of_get_named_gpio (phy_node,"reset-gpios" ,0 ); - -if (gpio_is_valid (gpio)) { - bp->reset_gpio =gpio_to_desc (gpio); -gpiod_direction_output (bp->reset_gpio,1 ); - } - } -of_node_put (phy_node); - err =of_get_phy_mode (np);if (err <0 ) { pdata =dev_get_platdata (&pdev->dev);@@ -3054,10 +3041,6 @@ static int macb_remove(struct platform_dmdiobus_unregister (bp->mii_bus);mdiobus_free (bp->mii_bus); -/* Shutdown the PHY if there is a GPIO reset */ -if (bp->reset_gpio) -gpiod_set_value (bp->reset_gpio,0 ); -unregister_netdev (dev);clk_disable_unprepare (bp->tx_clk);clk_disable_unprepare (bp->hclk);Index:
net-next/drivers/net/ethernet/cadence/macb.h
===================================================================drivers/net/ethernet/cadence/macb.h +0
-1@@ -832,7 +832,6 @@ struct macb {unsigned int dma_burst_length;phy_interface_t phy_interface; -struct gpio_desc *reset_gpio;/* AT91RM9200 transmit */ struct sk_buff *skb;/* holds skb until xmit interrupt completes */
Signature · 1 line
Nicolas Ferre
PATCH 1/1 pxa168_eth: fix mdiobus_scan() error check
In reply to Sergei ShtylyovSince mdiobus_scan() returns either an error code or NULL on error, the driver should check for both, not only for NULL, otherwise a crash is imminent...
---
The patch is against DaveM's 'net.git' repo.
drivers/net/ethernet/marvell/pxa168_eth.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/pxa168_eth.c +2 -0
@@ -979,6 +979,8 @@ static int pxa168_init_phy(struct net_dereturn 0 ; pep->phy =mdiobus_scan (pep->smi_bus, pep->phy_addr); +if (IS_ERR (pep->phy)) +return PTR_ERR (pep->phy);if (!pep->phy)return -ENODEV ;
Re: [PATCH] pxa168_eth: fix mdiobus_scan() error check
Quoted 18 lines · Sergei Shtylyov
Since
mdiobus_scan()returns either an error code or NULL on error, the driver should check for both, not only for NULL, otherwise a crash is imminent...Reported-by Arnd Bergmann <[email protected]>Signed-off-by Sergei Shtylyov <[email protected]>---
The patch is against DaveM's 'net.git' repo.drivers/net/ethernet/marvell/pxa168_eth.c | 2 ++ 1 file changed, 2 insertions(+)Index:
net/drivers/net/ethernet/marvell/pxa168_eth.c
===================================================================
drivers/net/ethernet/marvell/pxa168_eth.c static int pxa168_init_phy(struct net_de · line 985
Quoted 7 lines
drivers/net/ethernet/marvell/pxa168_eth.c +2
-0@@ -979,6 +979,8 @@ static int pxa168_init_phy(struct net_dereturn 0 ; pep->phy =mdiobus_scan (pep->smi_bus, pep->phy_addr); +if (IS_ERR (pep->phy)) +return PTR_ERR (pep->phy);if (!pep->phy)return -ENODEV ;
Should not this check be removed too and converted to a PTR_ERR(pep->phy) != -ENODEV?
Signature · 1 line
Florian
Re: [PATCH] pxa168_eth: fix mdiobus_scan() error check
Hello.
Quoted 20 lines · Florian Fainelli
Quoted 20 lines
Since
mdiobus_scan()returns either an error code or NULL on error, the driver should check for both, not only for NULL, otherwise a crash is imminent...Reported-by Arnd Bergmann <[email protected]>Signed-off-by Sergei Shtylyov <[email protected]>---
The patch is against DaveM's 'net.git' repo.drivers/net/ethernet/marvell/pxa168_eth.c | 2 ++ 1 file changed, 2 insertions(+)Index:
net/drivers/net/ethernet/marvell/pxa168_eth.c
===================================================================drivers/net/ethernet/marvell/pxa168_eth.c +0
-0@@ -979,6 +979,8 @@ static int pxa168_init_phy(struct net_dereturn 0 ;
Quoted 7 lines
drivers/net/ethernet/marvell/pxa168_eth.c static int pxa168_init_phy(struct net_de · line 985
Quoted 5 lines
drivers/net/ethernet/marvell/pxa168_eth.c +2
-0pep->phy =mdiobus_scan (pep->smi_bus, pep->phy_addr); +if (IS_ERR (pep->phy)) +return PTR_ERR (pep->phy);if (!pep->phy)return -ENODEV ;Should not this check be removed too and
That's my next move -- for now I'm fixing the existing bug in this driver
only.
Quoted 1 line
converted to a
PTR_ERR(pep->phy)!=-ENODEV?
I don't see what that would achieve, IMO it's enough to just drop this
*if* altogether.
MBR, Sergei
Re: [PATCH] pxa168_eth: fix mdiobus_scan() error check
Quoted 28 lines · Sergei Shtylyov
Quoted 20 lines
Quoted 20 lines
Since
mdiobus_scan()returns either an error code or NULL on error, the driver should check for both, not only for NULL, otherwise a crash is imminent...Reported-by Arnd Bergmann <[email protected]>Signed-off-by Sergei Shtylyov <[email protected]>---
The patch is against DaveM's 'net.git' repo.drivers/net/ethernet/marvell/pxa168_eth.c | 2 ++ 1 file changed, 2 insertions(+)Index:
net/drivers/net/ethernet/marvell/pxa168_eth.c
===================================================================drivers/net/ethernet/marvell/pxa168_eth.c +0
-0@@ -979,6 +979,8 @@ static int pxa168_init_phy(struct net_dereturn 0 ;Quoted 7 lines
drivers/net/ethernet/marvell/pxa168_eth.c static int pxa168_init_phy(struct net_de · line 985
Quoted 5 lines
drivers/net/ethernet/marvell/pxa168_eth.c +2
-0pep->phy =mdiobus_scan (pep->smi_bus, pep->phy_addr); +if (IS_ERR (pep->phy)) +return PTR_ERR (pep->phy);if (!pep->phy)return -ENODEV ;Should not this check be removed too and
Quoted 2 lines
That's my next move -- for now I'm fixing the existing bug in this driver
only.
In fact, it can't be removed yet as mdiobus_scan() may return NULL on
other error path. There's certainly a space for improvements yet... [...]
MBR, Sergei
Re: [PATCH] pxa168_eth: fix mdiobus_scan() error check
In reply to Sergei ShtylyovFrom: Sergei Shtylyov <[email protected]>
Date: Sat, 30 Apr 2016 23:35:11 +0300
Quoted 6 lines
Since
mdiobus_scan()returns either an error code or NULL on error, the driver should check for both, not only for NULL, otherwise a crash is imminent...Reported-by Arnd Bergmann <[email protected]>Signed-off-by Sergei Shtylyov <[email protected]>
Applied.
PATCH 1/1 pxa168_eth: mdiobus_scan() doesn't return NULL anymore
In reply to Sergei ShtylyovNow that mdiobus_scan() doesn't return NULL on failure anymore, this driver no longer needs to check for it...
---
The patch is against DaveM's 'net-next.git' repo.
drivers/net/ethernet/marvell/pxa168_eth.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/marvell/pxa168_eth.c +0 -2
@@ -981,8 +981,6 @@ static int pxa168_init_phy(struct net_de pep->phy =mdiobus_scan (pep->smi_bus, pep->phy_addr);if (IS_ERR (pep->phy))return PTR_ERR (pep->phy); -if (!pep->phy) -return -ENODEV ; err =phy_connect_direct (dev, pep->phy, pxa168_eth_adjust_link, pep->phy_intf);
Re: [PATCH] pxa168_eth: mdiobus_scan() doesn't return NULL anymore
From: Sergei Shtylyov <[email protected]>
Date: Sat, 07 May 2016 22:53:40 +0300
Quoted 4 lines
Now that
mdiobus_scan()doesn't return NULL on failure anymore, this driver no longer needs to check for it...Signed-off-by Sergei Shtylyov <[email protected]>
Applied.