* [PATCH RFC 1/5] net: macb: Migrate to dev_pm_ops
2013-10-14 23:58 [PATCH RFC 0/5] Ethernet support for Zynq Soren Brinkmann
@ 2013-10-14 23:58 ` Soren Brinkmann
2013-10-15 7:41 ` Nicolas Ferre
2013-10-14 23:58 ` [PATCH RFC 2/5] net: macb: Migrate to devm clock interface Soren Brinkmann
` (3 subsequent siblings)
4 siblings, 1 reply; 17+ messages in thread
From: Soren Brinkmann @ 2013-10-14 23:58 UTC (permalink / raw)
To: Nicolas Ferre; +Cc: netdev, linux-kernel, Michal Simek, Soren Brinkmann
Migrate the suspend/resume functions to use the dev_pm_ops PM interface.
Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
---
drivers/net/ethernet/cadence/macb.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 92578690f6de..389ccf1362d5 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -1946,8 +1946,9 @@ static int __exit macb_remove(struct platform_device *pdev)
}
#ifdef CONFIG_PM
-static int macb_suspend(struct platform_device *pdev, pm_message_t state)
+static int macb_suspend(struct device *dev)
{
+ struct platform_device *pdev = to_platform_device(dev);
struct net_device *netdev = platform_get_drvdata(pdev);
struct macb *bp = netdev_priv(netdev);
@@ -1960,8 +1961,9 @@ static int macb_suspend(struct platform_device *pdev, pm_message_t state)
return 0;
}
-static int macb_resume(struct platform_device *pdev)
+static int macb_resume(struct device *dev)
{
+ struct platform_device *pdev = to_platform_device(dev);
struct net_device *netdev = platform_get_drvdata(pdev);
struct macb *bp = netdev_priv(netdev);
@@ -1972,19 +1974,17 @@ static int macb_resume(struct platform_device *pdev)
return 0;
}
-#else
-#define macb_suspend NULL
-#define macb_resume NULL
#endif
+static SIMPLE_DEV_PM_OPS(macb_pm_ops, macb_suspend, macb_resume);
+
static struct platform_driver macb_driver = {
.remove = __exit_p(macb_remove),
- .suspend = macb_suspend,
- .resume = macb_resume,
.driver = {
.name = "macb",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(macb_dt_ids),
+ .pm = &macb_pm_ops,
},
};
--
1.8.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RFC 1/5] net: macb: Migrate to dev_pm_ops
2013-10-14 23:58 ` [PATCH RFC 1/5] net: macb: Migrate to dev_pm_ops Soren Brinkmann
@ 2013-10-15 7:41 ` Nicolas Ferre
0 siblings, 0 replies; 17+ messages in thread
From: Nicolas Ferre @ 2013-10-15 7:41 UTC (permalink / raw)
To: Soren Brinkmann, netdev, David Miller; +Cc: linux-kernel, Michal Simek
On 15/10/2013 01:58, Soren Brinkmann :
> Migrate the suspend/resume functions to use the dev_pm_ops PM interface.
>
> Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> drivers/net/ethernet/cadence/macb.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index 92578690f6de..389ccf1362d5 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -1946,8 +1946,9 @@ static int __exit macb_remove(struct platform_device *pdev)
> }
>
> #ifdef CONFIG_PM
> -static int macb_suspend(struct platform_device *pdev, pm_message_t state)
> +static int macb_suspend(struct device *dev)
> {
> + struct platform_device *pdev = to_platform_device(dev);
> struct net_device *netdev = platform_get_drvdata(pdev);
> struct macb *bp = netdev_priv(netdev);
>
> @@ -1960,8 +1961,9 @@ static int macb_suspend(struct platform_device *pdev, pm_message_t state)
> return 0;
> }
>
> -static int macb_resume(struct platform_device *pdev)
> +static int macb_resume(struct device *dev)
> {
> + struct platform_device *pdev = to_platform_device(dev);
> struct net_device *netdev = platform_get_drvdata(pdev);
> struct macb *bp = netdev_priv(netdev);
>
> @@ -1972,19 +1974,17 @@ static int macb_resume(struct platform_device *pdev)
>
> return 0;
> }
> -#else
> -#define macb_suspend NULL
> -#define macb_resume NULL
> #endif
>
> +static SIMPLE_DEV_PM_OPS(macb_pm_ops, macb_suspend, macb_resume);
> +
> static struct platform_driver macb_driver = {
> .remove = __exit_p(macb_remove),
> - .suspend = macb_suspend,
> - .resume = macb_resume,
> .driver = {
> .name = "macb",
> .owner = THIS_MODULE,
> .of_match_table = of_match_ptr(macb_dt_ids),
> + .pm = &macb_pm_ops,
> },
> };
>
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RFC 2/5] net: macb: Migrate to devm clock interface
2013-10-14 23:58 [PATCH RFC 0/5] Ethernet support for Zynq Soren Brinkmann
2013-10-14 23:58 ` [PATCH RFC 1/5] net: macb: Migrate to dev_pm_ops Soren Brinkmann
@ 2013-10-14 23:58 ` Soren Brinkmann
2013-10-15 7:44 ` Nicolas Ferre
2013-10-14 23:58 ` [PATCH RFC 3/5] net: macb: Use devm_ioremap() Soren Brinkmann
` (2 subsequent siblings)
4 siblings, 1 reply; 17+ messages in thread
From: Soren Brinkmann @ 2013-10-14 23:58 UTC (permalink / raw)
To: Nicolas Ferre; +Cc: netdev, linux-kernel, Michal Simek, Soren Brinkmann
Migrate to using the device managed intreface for clocks and clean up
the associated error paths.
Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
---
drivers/net/ethernet/cadence/macb.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 389ccf1362d5..62aa136889a4 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -1790,19 +1790,31 @@ static int __init macb_probe(struct platform_device *pdev)
spin_lock_init(&bp->lock);
INIT_WORK(&bp->tx_error_task, macb_tx_error_task);
- bp->pclk = clk_get(&pdev->dev, "pclk");
+ bp->pclk = devm_clk_get(&pdev->dev, "pclk");
if (IS_ERR(bp->pclk)) {
- dev_err(&pdev->dev, "failed to get macb_clk\n");
+ err = PTR_ERR(bp->pclk);
+ dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err);
goto err_out_free_dev;
}
- clk_prepare_enable(bp->pclk);
- bp->hclk = clk_get(&pdev->dev, "hclk");
+ bp->hclk = devm_clk_get(&pdev->dev, "hclk");
if (IS_ERR(bp->hclk)) {
- dev_err(&pdev->dev, "failed to get hclk\n");
- goto err_out_put_pclk;
+ err = PTR_ERR(bp->hclk);
+ dev_err(&pdev->dev, "failed to get hclk (%u)\n", err);
+ goto err_out_free_dev;
+ }
+
+ err = clk_prepare_enable(bp->pclk);
+ if (err) {
+ dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err);
+ goto err_out_free_dev;
+ }
+
+ err = clk_prepare_enable(bp->hclk);
+ if (err) {
+ dev_err(&pdev->dev, "failed to enable hclk (%u)\n", err);
+ goto err_out_disable_pclk;
}
- clk_prepare_enable(bp->hclk);
bp->regs = ioremap(regs->start, resource_size(regs));
if (!bp->regs) {
@@ -1908,10 +1920,8 @@ err_out_iounmap:
iounmap(bp->regs);
err_out_disable_clocks:
clk_disable_unprepare(bp->hclk);
- clk_put(bp->hclk);
+err_out_disable_pclk:
clk_disable_unprepare(bp->pclk);
-err_out_put_pclk:
- clk_put(bp->pclk);
err_out_free_dev:
free_netdev(dev);
err_out:
@@ -1936,9 +1946,7 @@ static int __exit macb_remove(struct platform_device *pdev)
free_irq(dev->irq, dev);
iounmap(bp->regs);
clk_disable_unprepare(bp->hclk);
- clk_put(bp->hclk);
clk_disable_unprepare(bp->pclk);
- clk_put(bp->pclk);
free_netdev(dev);
}
--
1.8.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RFC 2/5] net: macb: Migrate to devm clock interface
2013-10-14 23:58 ` [PATCH RFC 2/5] net: macb: Migrate to devm clock interface Soren Brinkmann
@ 2013-10-15 7:44 ` Nicolas Ferre
0 siblings, 0 replies; 17+ messages in thread
From: Nicolas Ferre @ 2013-10-15 7:44 UTC (permalink / raw)
To: Soren Brinkmann, netdev, David Miller; +Cc: linux-kernel, Michal Simek
On 15/10/2013 01:58, Soren Brinkmann :
> Migrate to using the device managed intreface for clocks and clean up
> the associated error paths.
>
> Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> drivers/net/ethernet/cadence/macb.c | 32 ++++++++++++++++++++------------
> 1 file changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index 389ccf1362d5..62aa136889a4 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -1790,19 +1790,31 @@ static int __init macb_probe(struct platform_device *pdev)
> spin_lock_init(&bp->lock);
> INIT_WORK(&bp->tx_error_task, macb_tx_error_task);
>
> - bp->pclk = clk_get(&pdev->dev, "pclk");
> + bp->pclk = devm_clk_get(&pdev->dev, "pclk");
> if (IS_ERR(bp->pclk)) {
> - dev_err(&pdev->dev, "failed to get macb_clk\n");
> + err = PTR_ERR(bp->pclk);
> + dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err);
> goto err_out_free_dev;
> }
> - clk_prepare_enable(bp->pclk);
>
> - bp->hclk = clk_get(&pdev->dev, "hclk");
> + bp->hclk = devm_clk_get(&pdev->dev, "hclk");
> if (IS_ERR(bp->hclk)) {
> - dev_err(&pdev->dev, "failed to get hclk\n");
> - goto err_out_put_pclk;
> + err = PTR_ERR(bp->hclk);
> + dev_err(&pdev->dev, "failed to get hclk (%u)\n", err);
> + goto err_out_free_dev;
> + }
> +
> + err = clk_prepare_enable(bp->pclk);
> + if (err) {
> + dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err);
> + goto err_out_free_dev;
> + }
> +
> + err = clk_prepare_enable(bp->hclk);
> + if (err) {
> + dev_err(&pdev->dev, "failed to enable hclk (%u)\n", err);
> + goto err_out_disable_pclk;
> }
> - clk_prepare_enable(bp->hclk);
>
> bp->regs = ioremap(regs->start, resource_size(regs));
> if (!bp->regs) {
> @@ -1908,10 +1920,8 @@ err_out_iounmap:
> iounmap(bp->regs);
> err_out_disable_clocks:
> clk_disable_unprepare(bp->hclk);
> - clk_put(bp->hclk);
> +err_out_disable_pclk:
> clk_disable_unprepare(bp->pclk);
> -err_out_put_pclk:
> - clk_put(bp->pclk);
> err_out_free_dev:
> free_netdev(dev);
> err_out:
> @@ -1936,9 +1946,7 @@ static int __exit macb_remove(struct platform_device *pdev)
> free_irq(dev->irq, dev);
> iounmap(bp->regs);
> clk_disable_unprepare(bp->hclk);
> - clk_put(bp->hclk);
> clk_disable_unprepare(bp->pclk);
> - clk_put(bp->pclk);
> free_netdev(dev);
> }
>
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RFC 3/5] net: macb: Use devm_ioremap()
2013-10-14 23:58 [PATCH RFC 0/5] Ethernet support for Zynq Soren Brinkmann
2013-10-14 23:58 ` [PATCH RFC 1/5] net: macb: Migrate to dev_pm_ops Soren Brinkmann
2013-10-14 23:58 ` [PATCH RFC 2/5] net: macb: Migrate to devm clock interface Soren Brinkmann
@ 2013-10-14 23:58 ` Soren Brinkmann
2013-10-15 7:45 ` Nicolas Ferre
2013-10-14 23:58 ` [PATCH RFC 4/5] net: macb: Use devm_request_irq() Soren Brinkmann
2013-10-14 23:59 ` [PATCH RFC 5/5] net: macb: Adjust tx_clk when link speed changes Soren Brinkmann
4 siblings, 1 reply; 17+ messages in thread
From: Soren Brinkmann @ 2013-10-14 23:58 UTC (permalink / raw)
To: Nicolas Ferre; +Cc: netdev, linux-kernel, Michal Simek, Soren Brinkmann
Use the device managed version of ioremap to remap IO memory,
simplifying error paths.
Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
---
drivers/net/ethernet/cadence/macb.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 62aa136889a4..436aecc31732 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -17,6 +17,7 @@
#include <linux/circ_buf.h>
#include <linux/slab.h>
#include <linux/init.h>
+#include <linux/io.h>
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/netdevice.h>
@@ -1816,7 +1817,7 @@ static int __init macb_probe(struct platform_device *pdev)
goto err_out_disable_pclk;
}
- bp->regs = ioremap(regs->start, resource_size(regs));
+ bp->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
if (!bp->regs) {
dev_err(&pdev->dev, "failed to map registers, aborting.\n");
err = -ENOMEM;
@@ -1828,7 +1829,7 @@ static int __init macb_probe(struct platform_device *pdev)
if (err) {
dev_err(&pdev->dev, "Unable to request IRQ %d (error %d)\n",
dev->irq, err);
- goto err_out_iounmap;
+ goto err_out_disable_clocks;
}
dev->netdev_ops = &macb_netdev_ops;
@@ -1916,8 +1917,6 @@ err_out_unregister_netdev:
unregister_netdev(dev);
err_out_free_irq:
free_irq(dev->irq, dev);
-err_out_iounmap:
- iounmap(bp->regs);
err_out_disable_clocks:
clk_disable_unprepare(bp->hclk);
err_out_disable_pclk:
@@ -1944,7 +1943,6 @@ static int __exit macb_remove(struct platform_device *pdev)
mdiobus_free(bp->mii_bus);
unregister_netdev(dev);
free_irq(dev->irq, dev);
- iounmap(bp->regs);
clk_disable_unprepare(bp->hclk);
clk_disable_unprepare(bp->pclk);
free_netdev(dev);
--
1.8.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RFC 3/5] net: macb: Use devm_ioremap()
2013-10-14 23:58 ` [PATCH RFC 3/5] net: macb: Use devm_ioremap() Soren Brinkmann
@ 2013-10-15 7:45 ` Nicolas Ferre
0 siblings, 0 replies; 17+ messages in thread
From: Nicolas Ferre @ 2013-10-15 7:45 UTC (permalink / raw)
To: Soren Brinkmann, netdev, David Miller; +Cc: linux-kernel, Michal Simek
On 15/10/2013 01:58, Soren Brinkmann :
> Use the device managed version of ioremap to remap IO memory,
> simplifying error paths.
>
> Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> drivers/net/ethernet/cadence/macb.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index 62aa136889a4..436aecc31732 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -17,6 +17,7 @@
> #include <linux/circ_buf.h>
> #include <linux/slab.h>
> #include <linux/init.h>
> +#include <linux/io.h>
> #include <linux/gpio.h>
> #include <linux/interrupt.h>
> #include <linux/netdevice.h>
> @@ -1816,7 +1817,7 @@ static int __init macb_probe(struct platform_device *pdev)
> goto err_out_disable_pclk;
> }
>
> - bp->regs = ioremap(regs->start, resource_size(regs));
> + bp->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
> if (!bp->regs) {
> dev_err(&pdev->dev, "failed to map registers, aborting.\n");
> err = -ENOMEM;
> @@ -1828,7 +1829,7 @@ static int __init macb_probe(struct platform_device *pdev)
> if (err) {
> dev_err(&pdev->dev, "Unable to request IRQ %d (error %d)\n",
> dev->irq, err);
> - goto err_out_iounmap;
> + goto err_out_disable_clocks;
> }
>
> dev->netdev_ops = &macb_netdev_ops;
> @@ -1916,8 +1917,6 @@ err_out_unregister_netdev:
> unregister_netdev(dev);
> err_out_free_irq:
> free_irq(dev->irq, dev);
> -err_out_iounmap:
> - iounmap(bp->regs);
> err_out_disable_clocks:
> clk_disable_unprepare(bp->hclk);
> err_out_disable_pclk:
> @@ -1944,7 +1943,6 @@ static int __exit macb_remove(struct platform_device *pdev)
> mdiobus_free(bp->mii_bus);
> unregister_netdev(dev);
> free_irq(dev->irq, dev);
> - iounmap(bp->regs);
> clk_disable_unprepare(bp->hclk);
> clk_disable_unprepare(bp->pclk);
> free_netdev(dev);
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RFC 4/5] net: macb: Use devm_request_irq()
2013-10-14 23:58 [PATCH RFC 0/5] Ethernet support for Zynq Soren Brinkmann
` (2 preceding siblings ...)
2013-10-14 23:58 ` [PATCH RFC 3/5] net: macb: Use devm_ioremap() Soren Brinkmann
@ 2013-10-14 23:58 ` Soren Brinkmann
2013-10-15 7:46 ` Nicolas Ferre
2013-10-15 19:21 ` Sergei Shtylyov
2013-10-14 23:59 ` [PATCH RFC 5/5] net: macb: Adjust tx_clk when link speed changes Soren Brinkmann
4 siblings, 2 replies; 17+ messages in thread
From: Soren Brinkmann @ 2013-10-14 23:58 UTC (permalink / raw)
To: Nicolas Ferre; +Cc: netdev, linux-kernel, Michal Simek, Soren Brinkmann
Use the device managed interface to request the IRQ, simplifying error
paths.
Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
---
drivers/net/ethernet/cadence/macb.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 436aecc31732..603844b1d483 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -1825,7 +1825,8 @@ static int __init macb_probe(struct platform_device *pdev)
}
dev->irq = platform_get_irq(pdev, 0);
- err = request_irq(dev->irq, macb_interrupt, 0, dev->name, dev);
+ err = devm_request_irq(&pdev->dev, dev->irq, macb_interrupt, 0,
+ dev->name, dev);
if (err) {
dev_err(&pdev->dev, "Unable to request IRQ %d (error %d)\n",
dev->irq, err);
@@ -1892,7 +1893,7 @@ static int __init macb_probe(struct platform_device *pdev)
err = register_netdev(dev);
if (err) {
dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
- goto err_out_free_irq;
+ goto err_out_disable_clocks;
}
err = macb_mii_init(bp);
@@ -1915,8 +1916,6 @@ static int __init macb_probe(struct platform_device *pdev)
err_out_unregister_netdev:
unregister_netdev(dev);
-err_out_free_irq:
- free_irq(dev->irq, dev);
err_out_disable_clocks:
clk_disable_unprepare(bp->hclk);
err_out_disable_pclk:
@@ -1942,7 +1941,6 @@ static int __exit macb_remove(struct platform_device *pdev)
kfree(bp->mii_bus->irq);
mdiobus_free(bp->mii_bus);
unregister_netdev(dev);
- free_irq(dev->irq, dev);
clk_disable_unprepare(bp->hclk);
clk_disable_unprepare(bp->pclk);
free_netdev(dev);
--
1.8.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RFC 4/5] net: macb: Use devm_request_irq()
2013-10-14 23:58 ` [PATCH RFC 4/5] net: macb: Use devm_request_irq() Soren Brinkmann
@ 2013-10-15 7:46 ` Nicolas Ferre
2013-10-15 19:21 ` Sergei Shtylyov
1 sibling, 0 replies; 17+ messages in thread
From: Nicolas Ferre @ 2013-10-15 7:46 UTC (permalink / raw)
To: Soren Brinkmann, netdev, David Miller; +Cc: linux-kernel, Michal Simek
On 15/10/2013 01:58, Soren Brinkmann :
> Use the device managed interface to request the IRQ, simplifying error
> paths.
>
> Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> drivers/net/ethernet/cadence/macb.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index 436aecc31732..603844b1d483 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -1825,7 +1825,8 @@ static int __init macb_probe(struct platform_device *pdev)
> }
>
> dev->irq = platform_get_irq(pdev, 0);
> - err = request_irq(dev->irq, macb_interrupt, 0, dev->name, dev);
> + err = devm_request_irq(&pdev->dev, dev->irq, macb_interrupt, 0,
> + dev->name, dev);
> if (err) {
> dev_err(&pdev->dev, "Unable to request IRQ %d (error %d)\n",
> dev->irq, err);
> @@ -1892,7 +1893,7 @@ static int __init macb_probe(struct platform_device *pdev)
> err = register_netdev(dev);
> if (err) {
> dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
> - goto err_out_free_irq;
> + goto err_out_disable_clocks;
> }
>
> err = macb_mii_init(bp);
> @@ -1915,8 +1916,6 @@ static int __init macb_probe(struct platform_device *pdev)
>
> err_out_unregister_netdev:
> unregister_netdev(dev);
> -err_out_free_irq:
> - free_irq(dev->irq, dev);
> err_out_disable_clocks:
> clk_disable_unprepare(bp->hclk);
> err_out_disable_pclk:
> @@ -1942,7 +1941,6 @@ static int __exit macb_remove(struct platform_device *pdev)
> kfree(bp->mii_bus->irq);
> mdiobus_free(bp->mii_bus);
> unregister_netdev(dev);
> - free_irq(dev->irq, dev);
> clk_disable_unprepare(bp->hclk);
> clk_disable_unprepare(bp->pclk);
> free_netdev(dev);
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RFC 4/5] net: macb: Use devm_request_irq()
2013-10-14 23:58 ` [PATCH RFC 4/5] net: macb: Use devm_request_irq() Soren Brinkmann
2013-10-15 7:46 ` Nicolas Ferre
@ 2013-10-15 19:21 ` Sergei Shtylyov
2013-10-15 20:20 ` Sören Brinkmann
1 sibling, 1 reply; 17+ messages in thread
From: Sergei Shtylyov @ 2013-10-15 19:21 UTC (permalink / raw)
To: Soren Brinkmann; +Cc: Nicolas Ferre, netdev, linux-kernel, Michal Simek
Hello.
On 10/15/2013 03:58 AM, Soren Brinkmann wrote:
> Use the device managed interface to request the IRQ, simplifying error
> paths.
> Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
> ---
> drivers/net/ethernet/cadence/macb.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index 436aecc31732..603844b1d483 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -1825,7 +1825,8 @@ static int __init macb_probe(struct platform_device *pdev)
> }
>
> dev->irq = platform_get_irq(pdev, 0);
> - err = request_irq(dev->irq, macb_interrupt, 0, dev->name, dev);
> + err = devm_request_irq(&pdev->dev, dev->irq, macb_interrupt, 0,
> + dev->name, dev);
You should start the continuation line right under &.
WBR, Sergei
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RFC 4/5] net: macb: Use devm_request_irq()
2013-10-15 19:21 ` Sergei Shtylyov
@ 2013-10-15 20:20 ` Sören Brinkmann
2013-10-15 20:38 ` Sergei Shtylyov
0 siblings, 1 reply; 17+ messages in thread
From: Sören Brinkmann @ 2013-10-15 20:20 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: Nicolas Ferre, netdev, linux-kernel, Michal Simek
On Tue, Oct 15, 2013 at 11:21:08PM +0400, Sergei Shtylyov wrote:
> Hello.
>
> On 10/15/2013 03:58 AM, Soren Brinkmann wrote:
>
> >Use the device managed interface to request the IRQ, simplifying error
> >paths.
>
> >Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
> >---
> > drivers/net/ethernet/cadence/macb.c | 8 +++-----
> > 1 file changed, 3 insertions(+), 5 deletions(-)
>
> >diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> >index 436aecc31732..603844b1d483 100644
> >--- a/drivers/net/ethernet/cadence/macb.c
> >+++ b/drivers/net/ethernet/cadence/macb.c
> >@@ -1825,7 +1825,8 @@ static int __init macb_probe(struct platform_device *pdev)
> > }
> >
> > dev->irq = platform_get_irq(pdev, 0);
> >- err = request_irq(dev->irq, macb_interrupt, 0, dev->name, dev);
> >+ err = devm_request_irq(&pdev->dev, dev->irq, macb_interrupt, 0,
> >+ dev->name, dev);
>
> You should start the continuation line right under &.
Actually this one is a good example why I don't do such alignment: You
do a simple search & replace - in this case request_irq ->
devm_request_irq - and all alignment is gone.
Sören
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RFC 4/5] net: macb: Use devm_request_irq()
2013-10-15 20:20 ` Sören Brinkmann
@ 2013-10-15 20:38 ` Sergei Shtylyov
0 siblings, 0 replies; 17+ messages in thread
From: Sergei Shtylyov @ 2013-10-15 20:38 UTC (permalink / raw)
To: Sören Brinkmann; +Cc: Nicolas Ferre, netdev, linux-kernel, Michal Simek
On 10/16/2013 12:20 AM, Sören Brinkmann wrote:
>>> Use the device managed interface to request the IRQ, simplifying error
>>> paths.
>>> Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
>>> ---
>>> drivers/net/ethernet/cadence/macb.c | 8 +++-----
>>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
>>> index 436aecc31732..603844b1d483 100644
>>> --- a/drivers/net/ethernet/cadence/macb.c
>>> +++ b/drivers/net/ethernet/cadence/macb.c
>>> @@ -1825,7 +1825,8 @@ static int __init macb_probe(struct platform_device *pdev)
>>> }
>>>
>>> dev->irq = platform_get_irq(pdev, 0);
>>> - err = request_irq(dev->irq, macb_interrupt, 0, dev->name, dev);
>>> + err = devm_request_irq(&pdev->dev, dev->irq, macb_interrupt, 0,
>>> + dev->name, dev);
>> You should start the continuation line right under &.
> Actually this one is a good example why I don't do such alignment: You
> do a simple search & replace - in this case request_irq ->
> devm_request_irq - and all alignment is gone.
I didn't understand why this is a good example. In this case you broke the
line yourself and did it incorrectly, not following the networking coding
style which assumes Emacs-style alignment for broken lines.
> Sören
WBR, Sergei
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RFC 5/5] net: macb: Adjust tx_clk when link speed changes
2013-10-14 23:58 [PATCH RFC 0/5] Ethernet support for Zynq Soren Brinkmann
` (3 preceding siblings ...)
2013-10-14 23:58 ` [PATCH RFC 4/5] net: macb: Use devm_request_irq() Soren Brinkmann
@ 2013-10-14 23:59 ` Soren Brinkmann
2013-10-15 7:54 ` Nicolas Ferre
4 siblings, 1 reply; 17+ messages in thread
From: Soren Brinkmann @ 2013-10-14 23:59 UTC (permalink / raw)
To: Nicolas Ferre; +Cc: netdev, linux-kernel, Michal Simek, Soren Brinkmann
Adjust the ethernet clock according to the negotiated link speed.
Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
---
drivers/net/ethernet/cadence/macb.c | 66 +++++++++++++++++++++++++++++++++++++
drivers/net/ethernet/cadence/macb.h | 1 +
2 files changed, 67 insertions(+)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 603844b1d483..beb9fa863811 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -204,6 +204,49 @@ static int macb_mdio_reset(struct mii_bus *bus)
return 0;
}
+/**
+ * macb_set_tx_clk() - Set a clock to a new frequency
+ * @clk Pointer to the clock to change
+ * @rate New frequency in Hz
+ * @dev Pointer to the struct net_device
+ */
+static void macb_set_tx_clk(struct clk *clk, int speed, struct net_device *dev)
+{
+ long ferr;
+ long rate;
+ long rate_rounded;
+
+ switch (speed) {
+ case SPEED_10:
+ rate = 2500000;
+ break;
+ case SPEED_100:
+ rate = 25000000;
+ break;
+ case SPEED_1000:
+ rate = 125000000;
+ break;
+ default:
+ break;
+ }
+
+ rate_rounded = clk_round_rate(clk, rate);
+ if (rate_rounded < 0)
+ return;
+
+ /* RGMII allows 50 ppm frequency error. Test and warn if this limit
+ * are not satisfied.
+ */
+ ferr = abs(rate_rounded - rate);
+ ferr = DIV_ROUND_UP(ferr, rate / 100000);
+ if (ferr > 5)
+ netdev_warn(dev, "unable to generate target frequency: %ld Hz\n",
+ rate);
+
+ if (clk_set_rate(clk, rate_rounded))
+ netdev_err(dev, "adjusting tx_clk failed.\n");
+}
+
static void macb_handle_link_change(struct net_device *dev)
{
struct macb *bp = netdev_priv(dev);
@@ -251,6 +294,9 @@ static void macb_handle_link_change(struct net_device *dev)
spin_unlock_irqrestore(&bp->lock, flags);
+ if (!IS_ERR(bp->tx_clk))
+ macb_set_tx_clk(bp->tx_clk, phydev->speed, dev);
+
if (status_change) {
if (phydev->link) {
netif_carrier_on(dev);
@@ -1805,6 +1851,8 @@ static int __init macb_probe(struct platform_device *pdev)
goto err_out_free_dev;
}
+ bp->tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
+
err = clk_prepare_enable(bp->pclk);
if (err) {
dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err);
@@ -1817,6 +1865,15 @@ static int __init macb_probe(struct platform_device *pdev)
goto err_out_disable_pclk;
}
+ if (!IS_ERR(bp->tx_clk)) {
+ err = clk_prepare_enable(bp->tx_clk);
+ if (err) {
+ dev_err(&pdev->dev, "failed to enable tx_clk (%u)\n",
+ err);
+ goto err_out_disable_hclk;
+ }
+ }
+
bp->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
if (!bp->regs) {
dev_err(&pdev->dev, "failed to map registers, aborting.\n");
@@ -1917,6 +1974,9 @@ static int __init macb_probe(struct platform_device *pdev)
err_out_unregister_netdev:
unregister_netdev(dev);
err_out_disable_clocks:
+ if (!IS_ERR(bp->tx_clk))
+ clk_disable_unprepare(bp->tx_clk);
+err_out_disable_hclk:
clk_disable_unprepare(bp->hclk);
err_out_disable_pclk:
clk_disable_unprepare(bp->pclk);
@@ -1941,6 +2001,8 @@ static int __exit macb_remove(struct platform_device *pdev)
kfree(bp->mii_bus->irq);
mdiobus_free(bp->mii_bus);
unregister_netdev(dev);
+ if (!IS_ERR(bp->tx_clk))
+ clk_disable_unprepare(bp->tx_clk);
clk_disable_unprepare(bp->hclk);
clk_disable_unprepare(bp->pclk);
free_netdev(dev);
@@ -1959,6 +2021,8 @@ static int macb_suspend(struct device *dev)
netif_carrier_off(netdev);
netif_device_detach(netdev);
+ if (!IS_ERR(bp->tx_clk))
+ clk_disable_unprepare(bp->tx_clk);
clk_disable_unprepare(bp->hclk);
clk_disable_unprepare(bp->pclk);
@@ -1973,6 +2037,8 @@ static int macb_resume(struct device *dev)
clk_prepare_enable(bp->pclk);
clk_prepare_enable(bp->hclk);
+ if (!IS_ERR(bp->tx_clk))
+ clk_prepare_enable(bp->tx_clk);
netif_device_attach(netdev);
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index f4076155bed7..51c02442160a 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -572,6 +572,7 @@ struct macb {
struct platform_device *pdev;
struct clk *pclk;
struct clk *hclk;
+ struct clk *tx_clk;
struct net_device *dev;
struct napi_struct napi;
struct work_struct tx_error_task;
--
1.8.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RFC 5/5] net: macb: Adjust tx_clk when link speed changes
2013-10-14 23:59 ` [PATCH RFC 5/5] net: macb: Adjust tx_clk when link speed changes Soren Brinkmann
@ 2013-10-15 7:54 ` Nicolas Ferre
2013-10-15 7:58 ` Michal Simek
2013-11-22 19:31 ` Sören Brinkmann
0 siblings, 2 replies; 17+ messages in thread
From: Nicolas Ferre @ 2013-10-15 7:54 UTC (permalink / raw)
To: Soren Brinkmann, netdev, David Miller; +Cc: linux-kernel, Michal Simek
On 15/10/2013 01:59, Soren Brinkmann :
> Adjust the ethernet clock according to the negotiated link speed.
>
> Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
I will need more time to study this one.
Moreover, I will have to add the "tx_clk" to every user of this driver
before switchin to the addition of this clock.
Best regards,
> ---
> drivers/net/ethernet/cadence/macb.c | 66 +++++++++++++++++++++++++++++++++++++
> drivers/net/ethernet/cadence/macb.h | 1 +
> 2 files changed, 67 insertions(+)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index 603844b1d483..beb9fa863811 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -204,6 +204,49 @@ static int macb_mdio_reset(struct mii_bus *bus)
> return 0;
> }
>
> +/**
> + * macb_set_tx_clk() - Set a clock to a new frequency
> + * @clk Pointer to the clock to change
> + * @rate New frequency in Hz
> + * @dev Pointer to the struct net_device
> + */
> +static void macb_set_tx_clk(struct clk *clk, int speed, struct net_device *dev)
> +{
> + long ferr;
> + long rate;
> + long rate_rounded;
> +
> + switch (speed) {
> + case SPEED_10:
> + rate = 2500000;
> + break;
> + case SPEED_100:
> + rate = 25000000;
> + break;
> + case SPEED_1000:
> + rate = 125000000;
> + break;
> + default:
> + break;
> + }
> +
> + rate_rounded = clk_round_rate(clk, rate);
> + if (rate_rounded < 0)
> + return;
> +
> + /* RGMII allows 50 ppm frequency error. Test and warn if this limit
> + * are not satisfied.
> + */
> + ferr = abs(rate_rounded - rate);
> + ferr = DIV_ROUND_UP(ferr, rate / 100000);
> + if (ferr > 5)
> + netdev_warn(dev, "unable to generate target frequency: %ld Hz\n",
> + rate);
> +
> + if (clk_set_rate(clk, rate_rounded))
> + netdev_err(dev, "adjusting tx_clk failed.\n");
> +}
> +
> static void macb_handle_link_change(struct net_device *dev)
> {
> struct macb *bp = netdev_priv(dev);
> @@ -251,6 +294,9 @@ static void macb_handle_link_change(struct net_device *dev)
>
> spin_unlock_irqrestore(&bp->lock, flags);
>
> + if (!IS_ERR(bp->tx_clk))
> + macb_set_tx_clk(bp->tx_clk, phydev->speed, dev);
> +
> if (status_change) {
> if (phydev->link) {
> netif_carrier_on(dev);
> @@ -1805,6 +1851,8 @@ static int __init macb_probe(struct platform_device *pdev)
> goto err_out_free_dev;
> }
>
> + bp->tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
> +
> err = clk_prepare_enable(bp->pclk);
> if (err) {
> dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err);
> @@ -1817,6 +1865,15 @@ static int __init macb_probe(struct platform_device *pdev)
> goto err_out_disable_pclk;
> }
>
> + if (!IS_ERR(bp->tx_clk)) {
> + err = clk_prepare_enable(bp->tx_clk);
> + if (err) {
> + dev_err(&pdev->dev, "failed to enable tx_clk (%u)\n",
> + err);
> + goto err_out_disable_hclk;
> + }
> + }
> +
> bp->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
> if (!bp->regs) {
> dev_err(&pdev->dev, "failed to map registers, aborting.\n");
> @@ -1917,6 +1974,9 @@ static int __init macb_probe(struct platform_device *pdev)
> err_out_unregister_netdev:
> unregister_netdev(dev);
> err_out_disable_clocks:
> + if (!IS_ERR(bp->tx_clk))
> + clk_disable_unprepare(bp->tx_clk);
> +err_out_disable_hclk:
> clk_disable_unprepare(bp->hclk);
> err_out_disable_pclk:
> clk_disable_unprepare(bp->pclk);
> @@ -1941,6 +2001,8 @@ static int __exit macb_remove(struct platform_device *pdev)
> kfree(bp->mii_bus->irq);
> mdiobus_free(bp->mii_bus);
> unregister_netdev(dev);
> + if (!IS_ERR(bp->tx_clk))
> + clk_disable_unprepare(bp->tx_clk);
> clk_disable_unprepare(bp->hclk);
> clk_disable_unprepare(bp->pclk);
> free_netdev(dev);
> @@ -1959,6 +2021,8 @@ static int macb_suspend(struct device *dev)
> netif_carrier_off(netdev);
> netif_device_detach(netdev);
>
> + if (!IS_ERR(bp->tx_clk))
> + clk_disable_unprepare(bp->tx_clk);
> clk_disable_unprepare(bp->hclk);
> clk_disable_unprepare(bp->pclk);
>
> @@ -1973,6 +2037,8 @@ static int macb_resume(struct device *dev)
>
> clk_prepare_enable(bp->pclk);
> clk_prepare_enable(bp->hclk);
> + if (!IS_ERR(bp->tx_clk))
> + clk_prepare_enable(bp->tx_clk);
>
> netif_device_attach(netdev);
>
> diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
> index f4076155bed7..51c02442160a 100644
> --- a/drivers/net/ethernet/cadence/macb.h
> +++ b/drivers/net/ethernet/cadence/macb.h
> @@ -572,6 +572,7 @@ struct macb {
> struct platform_device *pdev;
> struct clk *pclk;
> struct clk *hclk;
> + struct clk *tx_clk;
> struct net_device *dev;
> struct napi_struct napi;
> struct work_struct tx_error_task;
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RFC 5/5] net: macb: Adjust tx_clk when link speed changes
2013-10-15 7:54 ` Nicolas Ferre
@ 2013-10-15 7:58 ` Michal Simek
2013-10-15 15:34 ` Sören Brinkmann
2013-11-22 19:31 ` Sören Brinkmann
1 sibling, 1 reply; 17+ messages in thread
From: Michal Simek @ 2013-10-15 7:58 UTC (permalink / raw)
To: Nicolas Ferre
Cc: Soren Brinkmann, netdev, David Miller, linux-kernel, Michal Simek
On 10/15/2013 09:54 AM, Nicolas Ferre wrote:
> On 15/10/2013 01:59, Soren Brinkmann :
>> Adjust the ethernet clock according to the negotiated link speed.
>>
>> Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
>
> I will need more time to study this one.
>
> Moreover, I will have to add the "tx_clk" to every user of this driver before switchin to the addition of this clock.
As I am reading this patch, Soren just protected this
case that if this clk is not specified then it is not used.
But anyway feel free to take more time to study it.
If there is device-tree binding then it should be extend
by this optional value.
Thanks,
Michal
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RFC 5/5] net: macb: Adjust tx_clk when link speed changes
2013-10-15 7:58 ` Michal Simek
@ 2013-10-15 15:34 ` Sören Brinkmann
0 siblings, 0 replies; 17+ messages in thread
From: Sören Brinkmann @ 2013-10-15 15:34 UTC (permalink / raw)
To: Michal Simek; +Cc: Nicolas Ferre, netdev, David Miller, linux-kernel
On Tue, Oct 15, 2013 at 09:58:09AM +0200, Michal Simek wrote:
> On 10/15/2013 09:54 AM, Nicolas Ferre wrote:
> > On 15/10/2013 01:59, Soren Brinkmann :
> >> Adjust the ethernet clock according to the negotiated link speed.
> >>
> >> Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
> >
> > I will need more time to study this one.
> >
> > Moreover, I will have to add the "tx_clk" to every user of this driver before switchin to the addition of this clock.
>
> As I am reading this patch, Soren just protected this
> case that if this clk is not specified then it is not used.
That is how I sketched things in this patch. But as I said, I'm not
fully convinced this approach fits all or is the best. So, if anybody
has a better approach, let us know.
Sören
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RFC 5/5] net: macb: Adjust tx_clk when link speed changes
2013-10-15 7:54 ` Nicolas Ferre
2013-10-15 7:58 ` Michal Simek
@ 2013-11-22 19:31 ` Sören Brinkmann
1 sibling, 0 replies; 17+ messages in thread
From: Sören Brinkmann @ 2013-11-22 19:31 UTC (permalink / raw)
To: Nicolas Ferre; +Cc: netdev, David Miller, linux-kernel, Michal Simek
Hi Nicolas,
On Tue, Oct 15, 2013 at 09:54:21AM +0200, Nicolas Ferre wrote:
> On 15/10/2013 01:59, Soren Brinkmann :
> >Adjust the ethernet clock according to the negotiated link speed.
> >
> >Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
>
> I will need more time to study this one.
>
> Moreover, I will have to add the "tx_clk" to every user of this
> driver before switchin to the addition of this clock.
I just wanted to follow up on this. Did you have a chance to look at
this closer?
Thanks,
Sören
^ permalink raw reply [flat|nested] 17+ messages in thread