* [PATCH v3 0/8] net/fec: several cleanups and bugfixes
@ 2011-12-08 7:59 Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 1/8] net/fec: misc cleanups Lothar Waßmann
2011-12-09 0:54 ` [PATCH v3 0/8] net/fec: several cleanups and bugfixes David Miller
0 siblings, 2 replies; 10+ messages in thread
From: Lothar Waßmann @ 2011-12-08 7:59 UTC (permalink / raw)
To: netdev; +Cc: David Miller, linux-kernel, Shawn Guo, Lothar Waßmann
The following set of patches provides some cleanup and bugfixes for
drivers/net/ethernet/freescale/fec.c and makes the driver buildable as
a module.
Changes wrt v2:
- subject prefix changed to be in sync with existing commits
- added Acked-by:
Lothar WaÃmann (8):
misc cleanups
set con_id in clk_get() call to NULL
prevent dobule restart of interface on FDX/HDX change
don't request invalid IRQ
don't munge MAC address from platform data
preserve MII/RMII setting in fec_stop()
fix the .remove code
make FEC driver buildable as module
drivers/net/ethernet/freescale/Kconfig | 2 +-
drivers/net/ethernet/freescale/fec.c | 63 ++++++++++++++++++++++----------
2 files changed, 44 insertions(+), 21 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 1/8] net/fec: misc cleanups
2011-12-08 7:59 [PATCH v3 0/8] net/fec: several cleanups and bugfixes Lothar Waßmann
@ 2011-12-08 7:59 ` Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 2/8] net/fec: set con_id in clk_get() call to NULL Lothar Waßmann
2011-12-09 0:54 ` [PATCH v3 0/8] net/fec: several cleanups and bugfixes David Miller
1 sibling, 1 reply; 10+ messages in thread
From: Lothar Waßmann @ 2011-12-08 7:59 UTC (permalink / raw)
To: netdev; +Cc: David Miller, linux-kernel, Shawn Guo, Lothar Waßmann
- remove some bogus whitespace
- remove line wraps from printk messages
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/net/ethernet/freescale/fec.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index 1124ce0..f224e58 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -99,7 +99,7 @@ static struct platform_device_id fec_devtype[] = {
MODULE_DEVICE_TABLE(platform, fec_devtype);
enum imx_fec_type {
- IMX25_FEC = 1, /* runs on i.mx25/50/53 */
+ IMX25_FEC = 1, /* runs on i.mx25/50/53 */
IMX27_FEC, /* runs on i.mx27/35/51 */
IMX28_FEC,
IMX6Q_FEC,
@@ -132,7 +132,7 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");
#elif defined (CONFIG_M5272C3)
#define FEC_FLASHMAC (0xffe04000 + 4)
#elif defined(CONFIG_MOD5272)
-#define FEC_FLASHMAC 0xffc0406b
+#define FEC_FLASHMAC 0xffc0406b
#else
#define FEC_FLASHMAC 0
#endif
@@ -972,8 +972,9 @@ static int fec_enet_mii_probe(struct net_device *ndev)
}
if (phy_id >= PHY_MAX_ADDR) {
- printk(KERN_INFO "%s: no PHY, assuming direct connection "
- "to switch\n", ndev->name);
+ printk(KERN_INFO
+ "%s: no PHY, assuming direct connection to switch\n",
+ ndev->name);
strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE);
phy_id = 0;
}
@@ -998,8 +999,9 @@ static int fec_enet_mii_probe(struct net_device *ndev)
fep->link = 0;
fep->full_duplex = 0;
- printk(KERN_INFO "%s: Freescale FEC PHY driver [%s] "
- "(mii_bus:phy_addr=%s, irq=%d)\n", ndev->name,
+ printk(KERN_INFO
+ "%s: Freescale FEC PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
+ ndev->name,
fep->phy_dev->drv->name, dev_name(&fep->phy_dev->dev),
fep->phy_dev->irq);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 2/8] net/fec: set con_id in clk_get() call to NULL
2011-12-08 7:59 ` [PATCH v3 1/8] net/fec: misc cleanups Lothar Waßmann
@ 2011-12-08 7:59 ` Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 3/8] net/fec: prevent dobule restart of interface on FDX/HDX change Lothar Waßmann
0 siblings, 1 reply; 10+ messages in thread
From: Lothar Waßmann @ 2011-12-08 7:59 UTC (permalink / raw)
To: netdev; +Cc: David Miller, linux-kernel, Shawn Guo, Lothar Waßmann
The con_id is actually not needed for clk_get().
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/net/ethernet/freescale/fec.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index f224e58..65ee506 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -1585,7 +1585,7 @@ fec_probe(struct platform_device *pdev)
}
}
- fep->clk = clk_get(&pdev->dev, "fec_clk");
+ fep->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(fep->clk)) {
ret = PTR_ERR(fep->clk);
goto failed_clk;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 3/8] net/fec: prevent dobule restart of interface on FDX/HDX change
2011-12-08 7:59 ` [PATCH v3 2/8] net/fec: set con_id in clk_get() call to NULL Lothar Waßmann
@ 2011-12-08 7:59 ` Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 4/8] net/fec: don't request invalid IRQ Lothar Waßmann
0 siblings, 1 reply; 10+ messages in thread
From: Lothar Waßmann @ 2011-12-08 7:59 UTC (permalink / raw)
To: netdev; +Cc: David Miller, linux-kernel, Shawn Guo, Lothar Waßmann
Upon detection of a FDX/HDX change the interface is restarted twice.
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/net/ethernet/freescale/fec.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index 65ee506..7ef408f 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -865,6 +865,8 @@ static void fec_enet_adjust_link(struct net_device *ndev)
if (phy_dev->link) {
if (fep->full_duplex != phy_dev->duplex) {
fec_restart(ndev, phy_dev->duplex);
+ /* prevent unnecessary second fec_restart() below */
+ fep->link = phy_dev->link;
status_change = 1;
}
}
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 4/8] net/fec: don't request invalid IRQ
2011-12-08 7:59 ` [PATCH v3 3/8] net/fec: prevent dobule restart of interface on FDX/HDX change Lothar Waßmann
@ 2011-12-08 7:59 ` Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 5/8] net/fec: don't munge MAC address from platform data Lothar Waßmann
0 siblings, 1 reply; 10+ messages in thread
From: Lothar Waßmann @ 2011-12-08 7:59 UTC (permalink / raw)
To: netdev; +Cc: David Miller, linux-kernel, Shawn Guo, Lothar Waßmann
prevent calling request_irq() with a known invalid IRQ number and
preserve the return value of the platform_get_irq() function
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/net/ethernet/freescale/fec.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index 7ef408f..e2b5ce6 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -1575,8 +1575,12 @@ fec_probe(struct platform_device *pdev)
for (i = 0; i < FEC_IRQ_NUM; i++) {
irq = platform_get_irq(pdev, i);
- if (i && irq < 0)
- break;
+ if (irq < 0) {
+ if (i)
+ break;
+ ret = irq;
+ goto failed_irq;
+ }
ret = request_irq(irq, fec_enet_interrupt, IRQF_DISABLED, pdev->name, ndev);
if (ret) {
while (--i >= 0) {
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 5/8] net/fec: don't munge MAC address from platform data
2011-12-08 7:59 ` [PATCH v3 4/8] net/fec: don't request invalid IRQ Lothar Waßmann
@ 2011-12-08 7:59 ` Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 6/8] net/fec: preserve MII/RMII setting in fec_stop() Lothar Waßmann
0 siblings, 1 reply; 10+ messages in thread
From: Lothar Waßmann @ 2011-12-08 7:59 UTC (permalink / raw)
To: netdev; +Cc: David Miller, linux-kernel, Shawn Guo, Lothar Waßmann
When the MAC address is supplied via platform_data it should be OK as
it is and should not be modified in case of a dual FEC setup.
Also copying the MAC from platform_data to the single 'macaddr'
variable will overwrite the MAC for the first interface in case of a
dual FEC setup.
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/net/ethernet/freescale/fec.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index e2b5ce6..11534b9 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -818,7 +818,7 @@ static void __inline__ fec_get_mac(struct net_device *ndev)
iap = (unsigned char *)FEC_FLASHMAC;
#else
if (pdata)
- memcpy(iap, pdata->mac, ETH_ALEN);
+ iap = (unsigned char *)&pdata->mac;
#endif
}
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 6/8] net/fec: preserve MII/RMII setting in fec_stop()
2011-12-08 7:59 ` [PATCH v3 5/8] net/fec: don't munge MAC address from platform data Lothar Waßmann
@ 2011-12-08 7:59 ` Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 7/8] net/fec: fix the .remove code Lothar Waßmann
0 siblings, 1 reply; 10+ messages in thread
From: Lothar Waßmann @ 2011-12-08 7:59 UTC (permalink / raw)
To: netdev; +Cc: David Miller, linux-kernel, Shawn Guo, Lothar Waßmann
Additionally to setting the ETHER_EN bit in FEC_ECNTRL the MII/RMII
setting in FEC_R_CNTRL needs to be preserved to keep the MII interface
functional.
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/net/ethernet/freescale/fec.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index 11534b9..ab0afb5 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -515,6 +515,7 @@ fec_stop(struct net_device *ndev)
struct fec_enet_private *fep = netdev_priv(ndev);
const struct platform_device_id *id_entry =
platform_get_device_id(fep->pdev);
+ u32 rmii_mode = readl(fep->hwp + FEC_R_CNTRL) & (1 << 8);
/* We cannot expect a graceful transmit stop without link !!! */
if (fep->link) {
@@ -531,8 +532,10 @@ fec_stop(struct net_device *ndev)
writel(FEC_DEFAULT_IMASK, fep->hwp + FEC_IMASK);
/* We have to keep ENET enabled to have MII interrupt stay working */
- if (id_entry->driver_data & FEC_QUIRK_ENET_MAC)
+ if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) {
writel(2, fep->hwp + FEC_ECNTRL);
+ writel(rmii_mode, fep->hwp + FEC_R_CNTRL);
+ }
}
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 7/8] net/fec: fix the .remove code
2011-12-08 7:59 ` [PATCH v3 6/8] net/fec: preserve MII/RMII setting in fec_stop() Lothar Waßmann
@ 2011-12-08 7:59 ` Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 8/8] net/fec: make FEC driver buildable as module Lothar Waßmann
0 siblings, 1 reply; 10+ messages in thread
From: Lothar Waßmann @ 2011-12-08 7:59 UTC (permalink / raw)
To: netdev; +Cc: David Miller, linux-kernel, Shawn Guo, Lothar Waßmann
The .remove code is broken in several ways.
- mdiobus_unregister() is called twice for the same object in case of dual FEC
- phy_disconnect() is being called when the PHY is already disconnected
- the requested IRQ(s) are not freed
- fec_stop() is being called with the inteface already stopped
All of those lead to kernel crashes if the remove function is actually used.
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/net/ethernet/freescale/fec.c | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index ab0afb5..01ee9cc 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -259,6 +259,8 @@ struct fec_enet_private {
/* Transmitter timeout */
#define TX_TIMEOUT (2 * HZ)
+static int mii_cnt;
+
static void *swap_buffer(void *bufaddr, int len)
{
int i;
@@ -1040,8 +1042,12 @@ static int fec_enet_mii_init(struct platform_device *pdev)
*/
if ((id_entry->driver_data & FEC_QUIRK_ENET_MAC) && pdev->id > 0) {
/* fec1 uses fec0 mii_bus */
- fep->mii_bus = fec0_mii_bus;
- return 0;
+ if (mii_cnt && fec0_mii_bus) {
+ fep->mii_bus = fec0_mii_bus;
+ mii_cnt++;
+ return 0;
+ }
+ return -ENOENT;
}
fep->mii_timeout = 0;
@@ -1086,6 +1092,8 @@ static int fec_enet_mii_init(struct platform_device *pdev)
if (mdiobus_register(fep->mii_bus))
goto err_out_free_mdio_irq;
+ mii_cnt++;
+
/* save fec0 mii_bus */
if (id_entry->driver_data & FEC_QUIRK_ENET_MAC)
fec0_mii_bus = fep->mii_bus;
@@ -1102,11 +1110,11 @@ err_out:
static void fec_enet_mii_remove(struct fec_enet_private *fep)
{
- if (fep->phy_dev)
- phy_disconnect(fep->phy_dev);
- mdiobus_unregister(fep->mii_bus);
- kfree(fep->mii_bus->irq);
- mdiobus_free(fep->mii_bus);
+ if (--mii_cnt == 0) {
+ mdiobus_unregister(fep->mii_bus);
+ kfree(fep->mii_bus->irq);
+ mdiobus_free(fep->mii_bus);
+ }
}
static int fec_enet_get_settings(struct net_device *ndev,
@@ -1646,13 +1654,18 @@ fec_drv_remove(struct platform_device *pdev)
struct net_device *ndev = platform_get_drvdata(pdev);
struct fec_enet_private *fep = netdev_priv(ndev);
struct resource *r;
+ int i;
- fec_stop(ndev);
+ unregister_netdev(ndev);
fec_enet_mii_remove(fep);
+ for (i = 0; i < FEC_IRQ_NUM; i++) {
+ int irq = platform_get_irq(pdev, i);
+ if (irq > 0)
+ free_irq(irq, ndev);
+ }
clk_disable(fep->clk);
clk_put(fep->clk);
iounmap(fep->hwp);
- unregister_netdev(ndev);
free_netdev(ndev);
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 8/8] net/fec: make FEC driver buildable as module
2011-12-08 7:59 ` [PATCH v3 7/8] net/fec: fix the .remove code Lothar Waßmann
@ 2011-12-08 7:59 ` Lothar Waßmann
0 siblings, 0 replies; 10+ messages in thread
From: Lothar Waßmann @ 2011-12-08 7:59 UTC (permalink / raw)
To: netdev; +Cc: David Miller, linux-kernel, Shawn Guo, Lothar Waßmann
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/net/ethernet/freescale/Kconfig | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/ethernet/freescale/Kconfig b/drivers/net/ethernet/freescale/Kconfig
index c520cfd..b02e315 100644
--- a/drivers/net/ethernet/freescale/Kconfig
+++ b/drivers/net/ethernet/freescale/Kconfig
@@ -21,7 +21,7 @@ config NET_VENDOR_FREESCALE
if NET_VENDOR_FREESCALE
config FEC
- bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)"
+ tristate "FEC ethernet controller (of ColdFire and some i.MX CPUs)"
depends on (M523x || M527x || M5272 || M528x || M520x || M532x || \
ARCH_MXC || ARCH_MXS)
select PHYLIB
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 0/8] net/fec: several cleanups and bugfixes
2011-12-08 7:59 [PATCH v3 0/8] net/fec: several cleanups and bugfixes Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 1/8] net/fec: misc cleanups Lothar Waßmann
@ 2011-12-09 0:54 ` David Miller
1 sibling, 0 replies; 10+ messages in thread
From: David Miller @ 2011-12-09 0:54 UTC (permalink / raw)
To: LW; +Cc: netdev, linux-kernel, shawn.guo
From: Lothar Waßmann <LW@KARO-electronics.de>
Date: Thu, 8 Dec 2011 08:59:24 +0100
> The following set of patches provides some cleanup and bugfixes for
> drivers/net/ethernet/freescale/fec.c and makes the driver buildable as
> a module.
>
> Changes wrt v2:
> - subject prefix changed to be in sync with existing commits
> - added Acked-by:
All applied.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-12-09 0:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-08 7:59 [PATCH v3 0/8] net/fec: several cleanups and bugfixes Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 1/8] net/fec: misc cleanups Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 2/8] net/fec: set con_id in clk_get() call to NULL Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 3/8] net/fec: prevent dobule restart of interface on FDX/HDX change Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 4/8] net/fec: don't request invalid IRQ Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 5/8] net/fec: don't munge MAC address from platform data Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 6/8] net/fec: preserve MII/RMII setting in fec_stop() Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 7/8] net/fec: fix the .remove code Lothar Waßmann
2011-12-08 7:59 ` [PATCH v3 8/8] net/fec: make FEC driver buildable as module Lothar Waßmann
2011-12-09 0:54 ` [PATCH v3 0/8] net/fec: several cleanups and bugfixes David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).