2013-05-16 07:30:52

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH 0/5] net: davinci: trivial cleanup

From: Lad, Prabhakar <[email protected]>

This patch series cleans up the davinci driver.

This patch series applies on 3.10.rc1 and is boot tested
on OMAP-L138 EVM.

Lad, Prabhakar (5):
davinci: net: cpdma: remove unwanted header file incusion and sort
thme alphabetically
net: davinci_emac: remove unwanted header inclusion and sort the
alphabetically
net: davinci: emac: Convert to devm_* api
net: davinci_emac: simplify the OF parser code
net: davinci_mdio: trivial cleanup

drivers/net/ethernet/ti/davinci_cpdma.c | 10 +--
drivers/net/ethernet/ti/davinci_emac.c | 159 ++++++++-----------------------
drivers/net/ethernet/ti/davinci_mdio.c | 23 ++---
3 files changed, 55 insertions(+), 137 deletions(-)

--
1.7.4.1


2013-05-16 07:31:09

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH 1/5] davinci: net: cpdma: remove unwanted header file incusion and sort thme alphabetically

From: Lad, Prabhakar <[email protected]>

Signed-off-by: Lad, Prabhakar <[email protected]>
---
drivers/net/ethernet/ti/davinci_cpdma.c | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index 49dfd59..f7ce97f 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -12,15 +12,11 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <linux/device.h>
+
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
#include <linux/module.h>
#include <linux/slab.h>
-#include <linux/err.h>
-#include <linux/dma-mapping.h>
-#include <linux/io.h>
-#include <linux/delay.h>

#include "davinci_cpdma.h"

--
1.7.4.1

2013-05-16 07:31:12

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH 2/5] net: davinci_emac: remove unwanted header inclusion and sort the alphabetically

From: Lad, Prabhakar <[email protected]>

This patch removes unwanted header inclusion and sorts them alphabetically

Signed-off-by: Lad, Prabhakar <[email protected]>
---
drivers/net/ethernet/ti/davinci_emac.c | 42 +++++++-------------------------
1 files changed, 9 insertions(+), 33 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 860e15d..609f6d1 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -29,43 +29,19 @@
* PHY layer usage
*/

-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/errno.h>
-#include <linux/in.h>
-#include <linux/ioport.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
+#include <linux/clk.h>
+#include <linux/davinci_emac.h>
+#include <linux/dma-mapping.h>
+#include <linux/etherdevice.h>
+#include <linux/io.h>
#include <linux/interrupt.h>
-#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/ethtool.h>
-#include <linux/highmem.h>
-#include <linux/proc_fs.h>
-#include <linux/ctype.h>
-#include <linux/spinlock.h>
-#include <linux/dma-mapping.h>
-#include <linux/clk.h>
-#include <linux/platform_device.h>
-#include <linux/semaphore.h>
+#include <linux/of_net.h>
#include <linux/phy.h>
-#include <linux/bitops.h>
-#include <linux/io.h>
-#include <linux/uaccess.h>
+#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
-#include <linux/davinci_emac.h>
-#include <linux/of.h>
-#include <linux/of_address.h>
-#include <linux/of_irq.h>
-#include <linux/of_net.h>
-
-#include <asm/irq.h>
-#include <asm/page.h>

#include "davinci_cpdma.h"

--
1.7.4.1

2013-05-16 07:31:20

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH 3/5] net: davinci: emac: Convert to devm_* api

From: Lad, Prabhakar <[email protected]>

Use devm_ioremap_resource instead of devm_request_mem_region()/devm_ioremap()
and devm_request_irq() instead of request_irq().

This ensures more consistent error values and simplifies error paths.

Signed-off-by: Lad, Prabhakar <[email protected]>
---
drivers/net/ethernet/ti/davinci_emac.c | 50 ++++++--------------------------
1 files changed, 9 insertions(+), 41 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 609f6d1..a8b5c6b 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1508,7 +1508,7 @@ static int emac_dev_open(struct net_device *ndev)
struct device *emac_dev = &ndev->dev;
u32 cnt;
struct resource *res;
- int q, m, ret;
+ int ret;
int i = 0;
int k = 0;
struct emac_priv *priv = netdev_priv(ndev);
@@ -1543,8 +1543,9 @@ static int emac_dev_open(struct net_device *ndev)

while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) {
for (i = res->start; i <= res->end; i++) {
- if (request_irq(i, emac_irq, IRQF_DISABLED,
- ndev->name, ndev))
+ if (devm_request_irq(&priv->pdev->dev, i, emac_irq,
+ IRQF_DISABLED,
+ ndev->name, ndev))
goto rollback;
}
k++;
@@ -1617,15 +1618,7 @@ static int emac_dev_open(struct net_device *ndev)

rollback:

- dev_err(emac_dev, "DaVinci EMAC: request_irq() failed");
-
- for (q = k; k >= 0; k--) {
- for (m = i; m >= res->start; m--)
- free_irq(m, ndev);
- res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k-1);
- m = res->end;
- }
-
+ dev_err(emac_dev, "DaVinci EMAC: devm_request_irq() failed");
ret = -EBUSY;
err:
pm_runtime_put(&priv->pdev->dev);
@@ -1643,9 +1636,6 @@ err:
*/
static int emac_dev_stop(struct net_device *ndev)
{
- struct resource *res;
- int i = 0;
- int irq_num;
struct emac_priv *priv = netdev_priv(ndev);
struct device *emac_dev = &ndev->dev;

@@ -1661,13 +1651,6 @@ static int emac_dev_stop(struct net_device *ndev)
if (priv->phydev)
phy_disconnect(priv->phydev);

- /* Free IRQ */
- while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, i))) {
- for (irq_num = res->start; irq_num <= res->end; irq_num++)
- free_irq(irq_num, priv->ndev);
- i++;
- }
-
if (netif_msg_drv(priv))
dev_notice(emac_dev, "DaVinci EMAC: %s stopped\n", ndev->name);

@@ -1832,7 +1815,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
struct resource *res;
struct net_device *ndev;
struct emac_priv *priv;
- unsigned long size, hw_ram_addr;
+ unsigned long hw_ram_addr;
struct emac_platform_data *pdata;
struct device *emac_dev;
struct cpdma_params dma_params;
@@ -1883,25 +1866,10 @@ static int davinci_emac_probe(struct platform_device *pdev)
emac_dev = &ndev->dev;
/* Get EMAC platform data */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(&pdev->dev,"error getting res\n");
- rc = -ENOENT;
- goto no_pdata;
- }
-
- priv->emac_base_phys = res->start + pdata->ctrl_reg_offset;
- size = resource_size(res);
- if (!devm_request_mem_region(&pdev->dev, res->start,
- size, ndev->name)) {
- dev_err(&pdev->dev, "failed request_mem_region() for regs\n");
- rc = -ENXIO;
- goto no_pdata;
- }
-
- priv->remap_addr = devm_ioremap(&pdev->dev, res->start, size);
- if (!priv->remap_addr) {
+ priv->remap_addr = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(priv->remap_addr)) {
dev_err(&pdev->dev, "unable to map IO\n");
- rc = -ENOMEM;
+ rc = PTR_ERR(priv->remap_addr);
goto no_pdata;
}
priv->emac_base = priv->remap_addr + pdata->ctrl_reg_offset;
--
1.7.4.1

2013-05-16 07:31:31

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH 4/5] net: davinci_emac: simplify the OF parser code

From: Lad, Prabhakar <[email protected]>

This patch cleans up the OF parser code, removes unnecessary checks
on of_property_read_*() and guards davinci_emac_of_match table with
CONFIG_OF.

Signed-off-by: Lad, Prabhakar <[email protected]>
---
drivers/net/ethernet/ti/davinci_emac.c | 67 +++++++++++---------------------
1 files changed, 23 insertions(+), 44 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index a8b5c6b..17783a9 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1730,29 +1730,22 @@ static const struct net_device_ops emac_netdev_ops = {
#endif
};

-#ifdef CONFIG_OF
-static struct emac_platform_data
- *davinci_emac_of_get_pdata(struct platform_device *pdev,
- struct emac_priv *priv)
+static struct emac_platform_data *
+davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
{
struct device_node *np;
struct emac_platform_data *pdata = NULL;
const u8 *mac_addr;
- u32 data;
- int ret;

- pdata = pdev->dev.platform_data;
- if (!pdata) {
- pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
- if (!pdata)
- goto nodata;
- }
+ if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node)
+ return pdev->dev.platform_data;
+
+ pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+ if (!pdata)
+ return NULL;

np = pdev->dev.of_node;
- if (!np)
- goto nodata;
- else
- pdata->version = EMAC_VERSION_2;
+ pdata->version = EMAC_VERSION_2;

if (!is_valid_ether_addr(pdata->mac_addr)) {
mac_addr = of_get_mac_address(np);
@@ -1760,47 +1753,31 @@ static struct emac_platform_data
memcpy(pdata->mac_addr, mac_addr, ETH_ALEN);
}

- ret = of_property_read_u32(np, "ti,davinci-ctrl-reg-offset", &data);
- if (!ret)
- pdata->ctrl_reg_offset = data;
+ of_property_read_u32(np, "ti,davinci-ctrl-reg-offset",
+ &pdata->ctrl_reg_offset);

- ret = of_property_read_u32(np, "ti,davinci-ctrl-mod-reg-offset",
- &data);
- if (!ret)
- pdata->ctrl_mod_reg_offset = data;
+ of_property_read_u32(np, "ti,davinci-ctrl-mod-reg-offset",
+ &pdata->ctrl_mod_reg_offset);

- ret = of_property_read_u32(np, "ti,davinci-ctrl-ram-offset", &data);
- if (!ret)
- pdata->ctrl_ram_offset = data;
+ of_property_read_u32(np, "ti,davinci-ctrl-ram-offset",
+ &pdata->ctrl_ram_offset);

- ret = of_property_read_u32(np, "ti,davinci-ctrl-ram-size", &data);
- if (!ret)
- pdata->ctrl_ram_size = data;
+ of_property_read_u32(np, "ti,davinci-ctrl-ram-size",
+ &pdata->ctrl_ram_size);

- ret = of_property_read_u32(np, "ti,davinci-rmii-en", &data);
- if (!ret)
- pdata->rmii_en = data;
+ of_property_read_u8(np, "ti,davinci-rmii-en", &pdata->rmii_en);

- ret = of_property_read_u32(np, "ti,davinci-no-bd-ram", &data);
- if (!ret)
- pdata->no_bd_ram = data;
+ pdata->no_bd_ram = of_property_read_bool(np, "ti,davinci-no-bd-ram");

priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
if (!priv->phy_node)
pdata->phy_id = "";

pdev->dev.platform_data = pdata;
-nodata:
+
return pdata;
}
-#else
-static struct emac_platform_data
- *davinci_emac_of_get_pdata(struct platform_device *pdev,
- struct emac_priv *priv)
-{
- return pdev->dev.platform_data;
-}
-#endif
+
/**
* davinci_emac_probe - EMAC device probe
* @pdev: The DaVinci EMAC device that we are removing
@@ -2022,11 +1999,13 @@ static const struct dev_pm_ops davinci_emac_pm_ops = {
.resume = davinci_emac_resume,
};

+#if IS_ENABLED(CONFIG_OF)
static const struct of_device_id davinci_emac_of_match[] = {
{.compatible = "ti,davinci-dm6467-emac", },
{},
};
MODULE_DEVICE_TABLE(of, davinci_emac_of_match);
+#endif

/* davinci_emac_driver: EMAC platform driver structure */
static struct platform_driver davinci_emac_driver = {
--
1.7.4.1

2013-05-16 07:31:37

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH 5/5] net: davinci_mdio: trivial cleanup

From: Lad, Prabhakar <[email protected]>

remove unwanted header inclusion and sort the alphabetically
also guard the davinci_mdio_of_mtable table and davinci_mdio_probe_dt()
with CONFIG_OF.

Signed-off-by: Lad, Prabhakar <[email protected]>
---
drivers/net/ethernet/ti/davinci_mdio.c | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 12aec17..bc6cfec 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -24,20 +24,16 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* ---------------------------------------------------------------------------
*/
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/phy.h>
+
#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/io.h>
-#include <linux/pm_runtime.h>
#include <linux/davinci_emac.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/module.h>
#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/phy.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>

/*
* This timeout definition is a worst-case ultra defensive measure against
@@ -291,6 +287,7 @@ static int davinci_mdio_write(struct mii_bus *bus, int phy_id,
return 0;
}

+#if IS_ENABLED(CONFIG_OF)
static int davinci_mdio_probe_dt(struct mdio_platform_data *data,
struct platform_device *pdev)
{
@@ -308,7 +305,7 @@ static int davinci_mdio_probe_dt(struct mdio_platform_data *data,

return 0;
}
-
+#endif

static int davinci_mdio_probe(struct platform_device *pdev)
{
@@ -481,11 +478,13 @@ static const struct dev_pm_ops davinci_mdio_pm_ops = {
.resume = davinci_mdio_resume,
};

+#if IS_ENABLED(CONFIG_OF)
static const struct of_device_id davinci_mdio_of_mtable[] = {
{ .compatible = "ti,davinci_mdio", },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, davinci_mdio_of_mtable);
+#endif

static struct platform_driver davinci_mdio_driver = {
.driver = {
--
1.7.4.1

2013-05-16 18:53:15

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH 1/5] davinci: net: cpdma: remove unwanted header file incusion and sort thme alphabetically

Hello.

On 16-05-2013 11:30, Lad Prabhakar wrote:

s/incusion/inclusion/, s/thme/them/ in the subject. Though instead
of "them" it would be better to write "headers".

> From: Lad, Prabhakar <[email protected]>

Changelog won't hurt here... which unwanted #include's you are
removing and why are they unwanted?

> Signed-off-by: Lad, Prabhakar <[email protected]>
> ---
> drivers/net/ethernet/ti/davinci_cpdma.c | 10 +++-------
> 1 files changed, 3 insertions(+), 7 deletions(-)

> diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
> index 49dfd59..f7ce97f 100644
> --- a/drivers/net/ethernet/ti/davinci_cpdma.c
> +++ b/drivers/net/ethernet/ti/davinci_cpdma.c
> @@ -12,15 +12,11 @@
> * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> * GNU General Public License for more details.
> */
> -#include <linux/kernel.h>
> -#include <linux/spinlock.h>
> -#include <linux/device.h>
> +
> +#include <linux/delay.h>
> +#include <linux/dma-mapping.h>
> #include <linux/module.h>
> #include <linux/slab.h>
> -#include <linux/err.h>
> -#include <linux/dma-mapping.h>
> -#include <linux/io.h>
> -#include <linux/delay.h>
>
> #include "davinci_cpdma.h"

WBR, Sergei

2013-05-16 18:55:32

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH 2/5] net: davinci_emac: remove unwanted header inclusion and sort the alphabetically

On 16-05-2013 11:30, Lad Prabhakar wrote:

> From: Lad, Prabhakar <[email protected]>

> This patch removes unwanted header inclusion

Why are they unwanted?

> and sorts them alphabetically

In the subject you typed "the" instead of "them".

> Signed-off-by: Lad, Prabhakar <[email protected]>

WBR, Sergei

2013-05-16 18:58:06

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH 5/5] net: davinci_mdio: trivial cleanup

On 16-05-2013 11:30, Lad Prabhakar wrote:

> From: Lad, Prabhakar <[email protected]>

> remove unwanted header inclusion and sort the alphabetically

s/the/them/.

> also guard the davinci_mdio_of_mtable table and davinci_mdio_probe_dt()
> with CONFIG_OF.

Saying "also" in the changelog is often a good sign there should be
one more patch -- as in this case.

> Signed-off-by: Lad, Prabhakar <[email protected]>

WBR, Sergei

2013-05-17 04:46:54

by Lad, Prabhakar

[permalink] [raw]
Subject: Re: [PATCH 5/5] net: davinci_mdio: trivial cleanup

Hi Sergei,

Thanks for the review.

On Fri, May 17, 2013 at 12:28 AM, Sergei Shtylyov
<[email protected]> wrote:
> On 16-05-2013 11:30, Lad Prabhakar wrote:
>
>> From: Lad, Prabhakar <[email protected]>
>
>
>> remove unwanted header inclusion and sort the alphabetically
>
>
> s/the/them/.
OK
>
>
>> also guard the davinci_mdio_of_mtable table and davinci_mdio_probe_dt()
>> with CONFIG_OF.
>
>
> Saying "also" in the changelog is often a good sign there should be one
> more patch -- as in this case.
>
OK I'll split the patch.

Regards,
--Prabhakar Lad

2013-05-17 04:53:38

by Lad, Prabhakar

[permalink] [raw]
Subject: Re: [PATCH 2/5] net: davinci_emac: remove unwanted header inclusion and sort the alphabetically

Hi Sergei,

Thanks for the review.

On Fri, May 17, 2013 at 12:25 AM, Sergei Shtylyov
<[email protected]> wrote:
> On 16-05-2013 11:30, Lad Prabhakar wrote:
>
>> From: Lad, Prabhakar <[email protected]>
>
>
>> This patch removes unwanted header inclusion
>
>
> Why are they unwanted?
>
The driver builds without this includes.

This is arguable, if I would have added a new driver with the only
#includes which were required to build thats accepted. But when I remove
unnecessary #includes from the existing drivers that's not acceptable ?

This applies to rest of the similar patches in the series.

>> and sorts them alphabetically
>
>
> In the subject you typed "the" instead of "them".
>
Hmm carry forwarded this copy paste error every where will fix it in V2.

Regards,
--Prabhakar Lad