Skip to contentSkip to conversation

Add platform driver support to the CS890x driver

PATCH New Jaccon Bastiaansen 5 participants 17 messages Sep 7, 2011 – Nov 7, 2011 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

The CS89x0 ethernet controller is used on a number of evaluation boards, such as the MX31ADS. The current driver has memory address and IRQ settings for each board on which this controller is used. Driver updates are therefore required to support other boards that also use the CS89x0. To avoid these driver updates, a better mechanism (platform driver support) is added to communicate the board dependent settings to the driver.

---
 drivers/net/Kconfig  |   18 +++++++++--
 drivers/net/Space.c  |    2 +-
 drivers/net/cs89x0.c |   83 ++++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 96 insertions(+), 7 deletions(-)
drivers/net/Kconfig +15 -3
index 93359fa..17be84f 100644
@@ -1497,8 +1497,7 @@ config FORCEDETH
 
 config CS89x0
 	tristate "CS89x0 support"
-	depends on NET_ETHERNET && (ISA || EISA || MACH_IXDP2351 \
-		|| ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440)
+	depends on NET_ETHERNET
 	---help---
 	  Support for CS89x0 chipset based Ethernet cards. If you have a
 	  network (Ethernet) card of this type, say Y and read the
@@ -1509,10 +1508,23 @@ config CS89x0
 	  To compile this driver as a module, choose M here. The module
 	  will be called cs89x0.
 
+config CS89x0_PLATFORM
+	bool "CS89x0 platform driver support"
+	depends on CS89x0
+	default n
+	help
+	  Say Y to compile the cs890x0 driver as a platform driver. This
+	  makes this driver suitable for use on certain evaluation boards
+	  such as the IMX21ADS.
+
+	  If you are unsure, say N.
+
 config CS89x0_NONISA_IRQ
 	def_bool y
 	depends on CS89x0 != n
-	depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440
+	depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || \
+		   MACH_QQ2440 || CS89x0_PLATFORM
+
 
 config TC35815
 	tristate "TOSHIBA TC35815 Ethernet support"
drivers/net/Space.c +1 -1
index 068c356..3c53ab1 100644
@@ -189,7 +189,7 @@ static struct devprobe2 isa_probes[] __initdata = {
 #ifdef CONFIG_SEEQ8005
 	{seeq8005_probe, 0},
 #endif
-#ifdef CONFIG_CS89x0
+#if defined(CONFIG_CS89x0) && !defined(CONFIG_CS89x0_PLATFORM)
  	{cs89x0_probe, 0},
 #endif
 #ifdef CONFIG_AT1700
drivers/net/cs89x0.c +80 -3

113 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

Hello Jaccon,

Quoted 30 lines · Jaccon Bastiaansen

The CS89x0 ethernet controller is used on a number of evaluation boards, such as the MX31ADS. The current driver has memory address and IRQ settings for each board on which this controller is used. Driver updates are therefore required to support other boards that also use the CS89x0. To avoid these driver updates, a better mechanism (platform driver support) is added to communicate the board dependent settings to the driver.

---
 drivers/net/Kconfig  |   18 +++++++++--
 drivers/net/Space.c  |    2 +-
 drivers/net/cs89x0.c |   83 ++++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 96 insertions(+), 7 deletions(-)
drivers/net/Kconfig +1 -2
index 93359fa..17be84f 100644
@@ -1497,8 +1497,7 @@ config FORCEDETH
 
 config CS89x0
 	tristate "CS89x0 support"
-	depends on NET_ETHERNET && (ISA || EISA || MACH_IXDP2351 \
-		|| ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440)
+	depends on NET_ETHERNET
 	---help---
 	  Support for CS89x0 chipset based Ethernet cards. If you have a
 	  network (Ethernet) card of this type, say Y and read the

drivers/net/Kconfig config CS89x0 · line 1514

Quoted 7 lines
drivers/net/Kconfig +4 -0
@@ -1509,10 +1508,23 @@ config CS89x0
 	  To compile this driver as a module, choose M here. The module
 	  will be called cs89x0.
 
+config CS89x0_PLATFORM
+	bool "CS89x0 platform driver support"
+	depends on CS89x0
+	default n

default n is implicit so you don't need (and should not) add it here.

Quoted 44 lines
drivers/net/Kconfig +10 -1
+	help
+	  Say Y to compile the cs890x0 driver as a platform driver. This
+	  makes this driver suitable for use on certain evaluation boards
+	  such as the IMX21ADS.
+
+	  If you are unsure, say N.
+
 config CS89x0_NONISA_IRQ
 	def_bool y
 	depends on CS89x0 != n
-	depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440
+	depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || \
+		   MACH_QQ2440 || CS89x0_PLATFORM
+
 
 config TC35815
 	tristate "TOSHIBA TC35815 Ethernet support"
drivers/net/Space.c +1 -1
index 068c356..3c53ab1 100644
@@ -189,7 +189,7 @@ static struct devprobe2 isa_probes[] __initdata = {
 #ifdef CONFIG_SEEQ8005
 	{seeq8005_probe, 0},
 #endif
-#ifdef CONFIG_CS89x0
+#if defined(CONFIG_CS89x0) && !defined(CONFIG_CS89x0_PLATFORM)
  	{cs89x0_probe, 0},
 #endif
 #ifdef CONFIG_AT1700
drivers/net/cs89x0.c +2 -0
index 537a4b2..604c828 100644
@@ -98,6 +98,8 @@
   Domenico Andreoli : cavokz at gmail.com
                     : QQ2440 platform support
 
+  Jaccon Bastiaansen: jaccon.bastiaansen at gmail.com
+		    : added platform driver support
 */
 
 /* Always include 'config.h' first in case the user wants to turn on

drivers/net/cs89x0.c line 161

Quoted 7 lines
drivers/net/cs89x0.c +3 -1
@@ -154,7 +156,9 @@
 #if ALLOW_DMA
 #include <asm/dma.h>
 #endif
-
+#ifdef CONFIG_CS89x0_PLATFORM
+#include <linux/platform_device.h>
+#endif

IMHO better include that unconditionally.

Quoted 36 lines
drivers/net/cs89x0.c +13 -2
 #include "cs89x0.h"
 
 static char version[] __initdata =
@@ -189,6 +193,9 @@ static unsigned int netcard_portlist[] __used __initdata = {
 	PBC_BASE_ADDRESS + PBC_CS8900A_IOBASE + 0x300, 0
 };
 static unsigned cs8900_irq_map[] = {EXPIO_INT_ENET_INT, 0, 0, 0};
+#elif defined(CONFIG_CS89x0_PLATFORM)
+static unsigned int netcard_portlist[] __used __initdata = {0, 0};
+static unsigned int cs8900_irq_map[] = {0, 0, 0, 0};
 #else
 static unsigned int netcard_portlist[] __used __initdata =
    { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};
@@ -1746,7 +1753,7 @@ static int set_mac_address(struct net_device *dev, void *p)
 	return 0;
 }
 
-#ifdef MODULE
+#if defined(MODULE) && !defined(CONFIG_CS89x0_PLATFORM)
 
 static struct net_device *dev_cs89x0;
 
@@ -1900,7 +1907,77 @@ cleanup_module(void)
 	release_region(dev_cs89x0->base_addr, NETCARD_IO_EXTENT);
 	free_netdev(dev_cs89x0);
 }
-#endif /* MODULE */
+#endif /* MODULE && !CONFIG_CS89x0_PLATFORM */
+
+#ifdef CONFIG_CS89x0_PLATFORM
+static int cs89x0_platform_probe(struct platform_device *pdev)
+{
+	struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
+	struct resource *mem_res;
+	struct resource *irq_res;
+	int err;

drivers/net/cs89x0.c cleanup_module(void) · line 1928

Quoted 10 lines
drivers/net/cs89x0.c +10 -0
+
+	if (!dev)
+		return -ENODEV;
+
+	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (mem_res == NULL || irq_res == NULL) {
+		printk(KERN_WARNING
+		       DRV_NAME
+		       ": memory and/or interrupt resource missing.\n");

I'd prefer you do:

	#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

at the top of the driver and then just use:

	pr_warning("memory and/or interrupt resource missing\m");

drivers/net/cs89x0.c cleanup_module(void) · line 1934

Quoted 6 lines
drivers/net/cs89x0.c +6 -0
+		err = -ENOENT;
+		goto out;
+	}
+
+	cs8900_irq_map[0] = irq_res->start;
+	err = cs89x0_probe1(dev, mem_res->start, 0);

hmm, better switch the complete driver to be a platform driver and instead of the legacy probing let it create the corresponding device.

Quoted 33 lines
drivers/net/cs89x0.c +33 -0
+	if (err) {
+		printk(KERN_WARNING
+		       DRV_NAME
+		       ": no cs8900 or cs8920 detected.\n");
+		goto out;
+	}
+
+	platform_set_drvdata(pdev, dev);
+	return 0;
+out:
+	free_netdev(dev);
+	return err;
+}
+
+static int cs89x0_platform_remove(struct platform_device *pdev)
+{
+	struct net_device *dev = platform_get_drvdata(pdev);
+
+	unregister_netdev(dev);
+	free_netdev(dev);
+	return 0;
+}
+
+static struct platform_driver cs89x0_platform_driver = {
+	.driver	= {
+		.name	= DRV_NAME,
+		.owner	= THIS_MODULE,
+	},
+	.probe	= cs89x0_platform_probe,
+	.remove	= cs89x0_platform_remove,
+};
+
+static int __init cs89x0_init(void)

drivers/net/cs89x0.c cleanup_module(void) · line 1977

Quoted 10 lines
drivers/net/cs89x0.c +10 -0
+{
+	return platform_driver_register(&cs89x0_platform_driver);
+}
+
+static void __exit cs89x0_cleanup(void)
+{
+	platform_driver_unregister(&cs89x0_platform_driver);
+}
+
+module_init(cs89x0_init);

this line should go directly after the function definition.

Quoted 10 lines
drivers/net/cs89x0.c +3 -0
+module_exit(cs89x0_cleanup);
+
+#endif
 
 /*
  * Local variables:
Signature · 1 line
1.7.1
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#2 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

Hello Uwe,

2011/9/7 Uwe Kleine-K?nig <[email protected]>:

Quoted 36 lines

Hello Jaccon,

Quoted 33 lines · Jaccon Bastiaansen

The CS89x0 ethernet controller is used on a number of evaluation boards, such as the MX31ADS. The current driver has memory address and IRQ settings for each board on which this controller is used. Driver updates are therefore required to support other boards that also use the CS89x0. To avoid these driver updates, a better mechanism (platform driver support) is added to communicate the board dependent settings to the driver.

---

?drivers/net/Kconfig ?| ? 18 +++++++++--
?drivers/net/Space.c ?| ? ?2 +-
?drivers/net/cs89x0.c | ? 83 ++++++++++++++++++++++++++++++++++++++++++++++++--

?3 files changed, 96 insertions(+), 7 deletions(-)

drivers/net/Kconfig +0 -0
index 93359fa..17be84f 100644
@@ -1497,8 +1497,7 @@ config FORCEDETH
 

?config CS89x0
? ? ? tristate "CS89x0 support"
- ? ? depends on NET_ETHERNET && (ISA || EISA || MACH_IXDP2351 \
- ? ? ? ? ? ? || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440)
+ ? ? depends on NET_ETHERNET
? ? ? ---help---
? ? ? ? Support for CS89x0 chipset based Ethernet cards. If you have a ? ? ? ? network (Ethernet) card of this type, say Y and read the

drivers/net/Kconfig +0 -0
@@ -1509,10 +1508,23 @@ config CS89x0

? ? ? ? To compile this driver as a module, choose M here. The module ? ? ? ? will be called cs89x0.

Quoted 6 lines
Quoted 4 lines

+config CS89x0_PLATFORM
+ ? ? bool "CS89x0 platform driver support"
+ ? ? depends on CS89x0
+ ? ? default n

default n is implicit so you don't need (and should not) add it here.

Ok, I will fix this in the next version of the patch.

Quoted 42 lines
Quoted 42 lines

+ ? ? help
+ ? ? ? Say Y to compile the cs890x0 driver as a platform driver. This
+ ? ? ? makes this driver suitable for use on certain evaluation boards
+ ? ? ? such as the IMX21ADS.

drivers/net/Kconfig +3 -0
+
+ ? ? ? If you are unsure, say N.
+

?config CS89x0_NONISA_IRQ
? ? ? def_bool y
? ? ? depends on CS89x0 != n

- ? ? depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440
+ ? ? depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || \

+ ? ? ? ? ? ? ? ?MACH_QQ2440 || CS89x0_PLATFORM
+

?config TC35815
? ? ? tristate "TOSHIBA TC35815 Ethernet support"

drivers/net/Space.c +0 -0
index 068c356..3c53ab1 100644
@@ -189,7 +189,7 @@ static struct devprobe2 isa_probes[] __initdata = {

?#ifdef CONFIG_SEEQ8005
? ? ? {seeq8005_probe, 0},
?#endif

drivers/net/Space.c +1 -1
-#ifdef CONFIG_CS89x0
+#if defined(CONFIG_CS89x0) && !defined(CONFIG_CS89x0_PLATFORM)

? ? ? {cs89x0_probe, 0},
?#endif
?#ifdef CONFIG_AT1700

drivers/net/cs89x0.c +0 -0
index 537a4b2..604c828 100644
@@ -98,6 +98,8 @@

? ?Domenico Andreoli : cavokz at gmail.com
? ? ? ? ? ? ? ? ? ? ?: QQ2440 platform support

+ ?Jaccon Bastiaansen: jaccon.bastiaansen at gmail.com
+ ? ? ? ? ? ? ? ? : added platform driver support ?*/

Quoted 11 lines

drivers/net/cs89x0.c line 161

Quoted 9 lines

?/* Always include 'config.h' first in case the user wants to turn on

drivers/net/cs89x0.c +0 -0
@@ -154,7 +156,9 @@

?#if ALLOW_DMA
?#include <asm/dma.h>
?#endif

drivers/net/cs89x0.c +3 -1
-
+#ifdef CONFIG_CS89x0_PLATFORM
+#include <linux/platform_device.h>
+#endif

IMHO better include that unconditionally.

I will also fix this in the next version of this patch.

Quoted 48 lines
Quoted 36 lines

?#include "cs89x0.h"

?static char version[] __initdata =

drivers/net/cs89x0.c +0 -0
@@ -189,6 +193,9 @@ static unsigned int netcard_portlist[] __used __initdata = {

? ? ? PBC_BASE_ADDRESS + PBC_CS8900A_IOBASE + 0x300, 0 ?};
?static unsigned cs8900_irq_map[] = {EXPIO_INT_ENET_INT, 0, 0, 0};

drivers/net/cs89x0.c +3 -0
+#elif defined(CONFIG_CS89x0_PLATFORM)
+static unsigned int netcard_portlist[] __used __initdata = {0, 0};
+static unsigned int cs8900_irq_map[] = {0, 0, 0, 0};

?#else
?static unsigned int netcard_portlist[] __used __initdata =
? ? { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};

drivers/net/cs89x0.c +10 -2
@@ -1746,7 +1753,7 @@ static int set_mac_address(struct net_device *dev, void *p)
 ? ? ? return 0;
 ?}
 
-#ifdef MODULE
+#if defined(MODULE) && !defined(CONFIG_CS89x0_PLATFORM)
 
 ?static struct net_device *dev_cs89x0;
 
@@ -1900,7 +1907,77 @@ cleanup_module(void)
 ? ? ? release_region(dev_cs89x0->base_addr, NETCARD_IO_EXTENT);
 ? ? ? free_netdev(dev_cs89x0);
 ?}
-#endif /* MODULE */
+#endif /* MODULE && !CONFIG_CS89x0_PLATFORM */
+
+#ifdef CONFIG_CS89x0_PLATFORM
+static int cs89x0_platform_probe(struct platform_device *pdev)
+{
+ ? ? struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
+ ? ? struct resource *mem_res;
+ ? ? struct resource *irq_res;
+ ? ? int err;

drivers/net/cs89x0.c cleanup_module(void) · line 1928

Quoted 10 lines
drivers/net/cs89x0.c +10 -0
+
+ ? ? if (!dev)
+ ? ? ? ? ? ? return -ENODEV;
+
+ ? ? mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ ? ? irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ ? ? if (mem_res == NULL || irq_res == NULL) {
+ ? ? ? ? ? ? printk(KERN_WARNING
+ ? ? ? ? ? ? ? ? ? ?DRV_NAME
+ ? ? ? ? ? ? ? ? ? ?": memory and/or interrupt resource missing.\n");

I'd prefer you do:

Quoted 6 lines

? ? ? ?#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

at the top of the driver and then just use:

? ? ? ?pr_warning("memory and/or interrupt resource missing\m");

I agree.

Quoted 9 lines

drivers/net/cs89x0.c cleanup_module(void) · line 1934

Quoted 6 lines
drivers/net/cs89x0.c +6 -0
+ ? ? ? ? ? ? err = -ENOENT;
+ ? ? ? ? ? ? goto out;
+ ? ? }
+
+ ? ? cs8900_irq_map[0] = irq_res->start;
+ ? ? err = cs89x0_probe1(dev, mem_res->start, 0);

hmm, better switch the complete driver to be a platform driver and instead of the legacy probing let it create the corresponding device.

What exactly do you mean with "switch the complete driver to be a platform driver"? That I should remove all the legacy from the driver (which would break the driver for users who don't use it as a platform driver) or that I should add a new probe() function free of legacy (which would duplicate code of the existing cs89x0_probe1() function)?

Quoted 36 lines
Quoted 36 lines
drivers/net/cs89x0.c +36 -0
+ ? ? if (err) {
+ ? ? ? ? ? ? printk(KERN_WARNING
+ ? ? ? ? ? ? ? ? ? ?DRV_NAME
+ ? ? ? ? ? ? ? ? ? ?": no cs8900 or cs8920 detected.\n");
+ ? ? ? ? ? ? goto out;
+ ? ? }
+
+ ? ? platform_set_drvdata(pdev, dev);
+ ? ? return 0;
+out:
+ ? ? free_netdev(dev);
+ ? ? return err;
+}
+
+static int cs89x0_platform_remove(struct platform_device *pdev)
+{
+ ? ? struct net_device *dev = platform_get_drvdata(pdev);
+
+ ? ? unregister_netdev(dev);
+ ? ? free_netdev(dev);
+ ? ? return 0;
+}
+
+static struct platform_driver cs89x0_platform_driver = {
+ ? ? .driver = {
+ ? ? ? ? ? ? .name ? = DRV_NAME,
+ ? ? ? ? ? ? .owner ?= THIS_MODULE,
+ ? ? },
+ ? ? .probe ?= cs89x0_platform_probe,
+ ? ? .remove = cs89x0_platform_remove,
+};
+
+static int __init cs89x0_init(void)
+{
+ ? ? return platform_driver_register(&cs89x0_platform_driver);
+}
Quoted 9 lines

drivers/net/cs89x0.c cleanup_module(void) · line 1977

Quoted 7 lines
drivers/net/cs89x0.c +7 -0
+
+static void __exit cs89x0_cleanup(void)
+{
+ ? ? platform_driver_unregister(&cs89x0_platform_driver);
+}
+
+module_init(cs89x0_init);

this line should go directly after the function definition.

Ok, I will also fix this in the next version of this patch.

Quoted 12 lines
Quoted 10 lines
drivers/net/cs89x0.c +3 -0
+module_exit(cs89x0_cleanup);
+
+#endif
 

?/*
? * Local variables:
--
1.7.1

--

Quoted 3 lines
Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | Uwe Kleine-K?nig ? ? ? ? ? ?|
Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|

Regards,
Jaccon

#3 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

Hello Jaccon,

Quoted 171 lines · Jaccon Bastiaansen

Hello Uwe,

2011/9/7 Uwe Kleine-K?nig <[email protected]>:

Quoted 36 lines

Hello Jaccon,

Quoted 33 lines · Jaccon Bastiaansen

The CS89x0 ethernet controller is used on a number of evaluation boards, such as the MX31ADS. The current driver has memory address and IRQ settings for each board on which this controller is used. Driver updates are therefore required to support other boards that also use the CS89x0. To avoid these driver updates, a better mechanism (platform driver support) is added to communicate the board dependent settings to the driver.

---

?drivers/net/Kconfig ?| ? 18 +++++++++--
?drivers/net/Space.c ?| ? ?2 +-
?drivers/net/cs89x0.c | ? 83 ++++++++++++++++++++++++++++++++++++++++++++++++--

?3 files changed, 96 insertions(+), 7 deletions(-)

drivers/net/Kconfig +0 -0
index 93359fa..17be84f 100644
@@ -1497,8 +1497,7 @@ config FORCEDETH
 

?config CS89x0
? ? ? tristate "CS89x0 support"
- ? ? depends on NET_ETHERNET && (ISA || EISA || MACH_IXDP2351 \
- ? ? ? ? ? ? || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440)
+ ? ? depends on NET_ETHERNET
? ? ? ---help---
? ? ? ? Support for CS89x0 chipset based Ethernet cards. If you have a ? ? ? ? network (Ethernet) card of this type, say Y and read the

drivers/net/Kconfig +0 -0
@@ -1509,10 +1508,23 @@ config CS89x0

? ? ? ? To compile this driver as a module, choose M here. The module ? ? ? ? will be called cs89x0.

Quoted 6 lines
Quoted 4 lines

+config CS89x0_PLATFORM
+ ? ? bool "CS89x0 platform driver support"
+ ? ? depends on CS89x0
+ ? ? default n

default n is implicit so you don't need (and should not) add it here.

Ok, I will fix this in the next version of the patch.

Quoted 42 lines
Quoted 42 lines

+ ? ? help
+ ? ? ? Say Y to compile the cs890x0 driver as a platform driver. This
+ ? ? ? makes this driver suitable for use on certain evaluation boards
+ ? ? ? such as the IMX21ADS.

drivers/net/Kconfig +3 -0
+
+ ? ? ? If you are unsure, say N.
+

?config CS89x0_NONISA_IRQ
? ? ? def_bool y
? ? ? depends on CS89x0 != n

- ? ? depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440
+ ? ? depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || \

+ ? ? ? ? ? ? ? ?MACH_QQ2440 || CS89x0_PLATFORM
+

?config TC35815
? ? ? tristate "TOSHIBA TC35815 Ethernet support"

drivers/net/Space.c +0 -0
index 068c356..3c53ab1 100644
@@ -189,7 +189,7 @@ static struct devprobe2 isa_probes[] __initdata = {

?#ifdef CONFIG_SEEQ8005
? ? ? {seeq8005_probe, 0},
?#endif

drivers/net/Space.c +1 -1
-#ifdef CONFIG_CS89x0
+#if defined(CONFIG_CS89x0) && !defined(CONFIG_CS89x0_PLATFORM)

? ? ? {cs89x0_probe, 0},
?#endif
?#ifdef CONFIG_AT1700

drivers/net/cs89x0.c +0 -0
index 537a4b2..604c828 100644
@@ -98,6 +98,8 @@

? ?Domenico Andreoli : cavokz at gmail.com
? ? ? ? ? ? ? ? ? ? ?: QQ2440 platform support

+ ?Jaccon Bastiaansen: jaccon.bastiaansen at gmail.com
+ ? ? ? ? ? ? ? ? : added platform driver support ?*/

Quoted 11 lines

drivers/net/cs89x0.c line 161

Quoted 9 lines

?/* Always include 'config.h' first in case the user wants to turn on

drivers/net/cs89x0.c +0 -0
@@ -154,7 +156,9 @@

?#if ALLOW_DMA
?#include <asm/dma.h>
?#endif

drivers/net/cs89x0.c +3 -1
-
+#ifdef CONFIG_CS89x0_PLATFORM
+#include <linux/platform_device.h>
+#endif

IMHO better include that unconditionally.

I will also fix this in the next version of this patch.

Quoted 48 lines
Quoted 36 lines

?#include "cs89x0.h"

?static char version[] __initdata =

drivers/net/cs89x0.c +0 -0
@@ -189,6 +193,9 @@ static unsigned int netcard_portlist[] __used __initdata = {

? ? ? PBC_BASE_ADDRESS + PBC_CS8900A_IOBASE + 0x300, 0 ?};
?static unsigned cs8900_irq_map[] = {EXPIO_INT_ENET_INT, 0, 0, 0};

drivers/net/cs89x0.c +3 -0
+#elif defined(CONFIG_CS89x0_PLATFORM)
+static unsigned int netcard_portlist[] __used __initdata = {0, 0};
+static unsigned int cs8900_irq_map[] = {0, 0, 0, 0};

?#else
?static unsigned int netcard_portlist[] __used __initdata =
? ? { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};

drivers/net/cs89x0.c +10 -2
@@ -1746,7 +1753,7 @@ static int set_mac_address(struct net_device *dev, void *p)
 ? ? ? return 0;
 ?}
 
-#ifdef MODULE
+#if defined(MODULE) && !defined(CONFIG_CS89x0_PLATFORM)
 
 ?static struct net_device *dev_cs89x0;
 
@@ -1900,7 +1907,77 @@ cleanup_module(void)
 ? ? ? release_region(dev_cs89x0->base_addr, NETCARD_IO_EXTENT);
 ? ? ? free_netdev(dev_cs89x0);
 ?}
-#endif /* MODULE */
+#endif /* MODULE && !CONFIG_CS89x0_PLATFORM */
+
+#ifdef CONFIG_CS89x0_PLATFORM
+static int cs89x0_platform_probe(struct platform_device *pdev)
+{
+ ? ? struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
+ ? ? struct resource *mem_res;
+ ? ? struct resource *irq_res;
+ ? ? int err;

drivers/net/cs89x0.c cleanup_module(void) · line 1928

Quoted 10 lines
drivers/net/cs89x0.c +10 -0
+
+ ? ? if (!dev)
+ ? ? ? ? ? ? return -ENODEV;
+
+ ? ? mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ ? ? irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ ? ? if (mem_res == NULL || irq_res == NULL) {
+ ? ? ? ? ? ? printk(KERN_WARNING
+ ? ? ? ? ? ? ? ? ? ?DRV_NAME
+ ? ? ? ? ? ? ? ? ? ?": memory and/or interrupt resource missing.\n");

I'd prefer you do:

Quoted 6 lines

? ? ? ?#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

at the top of the driver and then just use:

? ? ? ?pr_warning("memory and/or interrupt resource missing\m");

I agree.

Quoted 9 lines

drivers/net/cs89x0.c cleanup_module(void) · line 1934

Quoted 6 lines
drivers/net/cs89x0.c +6 -0
+ ? ? ? ? ? ? err = -ENOENT;
+ ? ? ? ? ? ? goto out;
+ ? ? }
+
+ ? ? cs8900_irq_map[0] = irq_res->start;
+ ? ? err = cs89x0_probe1(dev, mem_res->start, 0);

hmm, better switch the complete driver to be a platform driver and instead of the legacy probing let it create the corresponding device.

Quoted 5 lines

What exactly do you mean with "switch the complete driver to be a platform driver"? That I should remove all the legacy from the driver (which would break the driver for users who don't use it as a platform driver) or that I should add a new probe() function free of legacy (which would duplicate code of the existing cs89x0_probe1() function)?

Of course you should not break it for legacy users. Just instead of the legacy stuff just add a platform device with the respective values such that the platform driver is used in all cases.

For extra points move the adding of the device to platform code.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#4 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

Hello Uwe,

2011/9/10 Uwe Kleine-K?nig <[email protected]>:

Quoted 179 lines

Hello Jaccon,

Quoted 171 lines · Jaccon Bastiaansen

Hello Uwe,

2011/9/7 Uwe Kleine-K?nig <[email protected]>:

Quoted 36 lines

Hello Jaccon,

Quoted 33 lines · Jaccon Bastiaansen

The CS89x0 ethernet controller is used on a number of evaluation boards, such as the MX31ADS. The current driver has memory address and IRQ settings for each board on which this controller is used. Driver updates are therefore required to support other boards that also use the CS89x0. To avoid these driver updates, a better mechanism (platform driver support) is added to communicate the board dependent settings to the driver.

---

?drivers/net/Kconfig ?| ? 18 +++++++++--
?drivers/net/Space.c ?| ? ?2 +-
?drivers/net/cs89x0.c | ? 83 ++++++++++++++++++++++++++++++++++++++++++++++++--

?3 files changed, 96 insertions(+), 7 deletions(-)

drivers/net/Kconfig +0 -0
index 93359fa..17be84f 100644
@@ -1497,8 +1497,7 @@ config FORCEDETH
 

?config CS89x0
? ? ? tristate "CS89x0 support"
- ? ? depends on NET_ETHERNET && (ISA || EISA || MACH_IXDP2351 \
- ? ? ? ? ? ? || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440)
+ ? ? depends on NET_ETHERNET
? ? ? ---help---
? ? ? ? Support for CS89x0 chipset based Ethernet cards. If you have a ? ? ? ? network (Ethernet) card of this type, say Y and read the

drivers/net/Kconfig +0 -0
@@ -1509,10 +1508,23 @@ config CS89x0

? ? ? ? To compile this driver as a module, choose M here. The module ? ? ? ? will be called cs89x0.

Quoted 6 lines
Quoted 4 lines

+config CS89x0_PLATFORM
+ ? ? bool "CS89x0 platform driver support"
+ ? ? depends on CS89x0
+ ? ? default n

default n is implicit so you don't need (and should not) add it here.

Ok, I will fix this in the next version of the patch.

Quoted 42 lines
Quoted 42 lines

+ ? ? help
+ ? ? ? Say Y to compile the cs890x0 driver as a platform driver. This
+ ? ? ? makes this driver suitable for use on certain evaluation boards
+ ? ? ? such as the IMX21ADS.

drivers/net/Kconfig +3 -0
+
+ ? ? ? If you are unsure, say N.
+

?config CS89x0_NONISA_IRQ
? ? ? def_bool y
? ? ? depends on CS89x0 != n

- ? ? depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440
+ ? ? depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || \

+ ? ? ? ? ? ? ? ?MACH_QQ2440 || CS89x0_PLATFORM
+

?config TC35815
? ? ? tristate "TOSHIBA TC35815 Ethernet support"

drivers/net/Space.c +0 -0
index 068c356..3c53ab1 100644
@@ -189,7 +189,7 @@ static struct devprobe2 isa_probes[] __initdata = {

?#ifdef CONFIG_SEEQ8005
? ? ? {seeq8005_probe, 0},
?#endif

drivers/net/Space.c +1 -1
-#ifdef CONFIG_CS89x0
+#if defined(CONFIG_CS89x0) && !defined(CONFIG_CS89x0_PLATFORM)

? ? ? {cs89x0_probe, 0},
?#endif
?#ifdef CONFIG_AT1700

drivers/net/cs89x0.c +0 -0
index 537a4b2..604c828 100644
@@ -98,6 +98,8 @@

? ?Domenico Andreoli : cavokz at gmail.com
? ? ? ? ? ? ? ? ? ? ?: QQ2440 platform support

+ ?Jaccon Bastiaansen: jaccon.bastiaansen at gmail.com
+ ? ? ? ? ? ? ? ? : added platform driver support ?*/

Quoted 11 lines

drivers/net/cs89x0.c

Quoted 9 lines

?/* Always include 'config.h' first in case the user wants to turn on

drivers/net/cs89x0.c +0 -0
@@ -154,7 +156,9 @@

?#if ALLOW_DMA
?#include <asm/dma.h>
?#endif

drivers/net/cs89x0.c +3 -1
-
+#ifdef CONFIG_CS89x0_PLATFORM
+#include <linux/platform_device.h>
+#endif

IMHO better include that unconditionally.

I will also fix this in the next version of this patch.

Quoted 48 lines
Quoted 36 lines

?#include "cs89x0.h"

?static char version[] __initdata =

drivers/net/cs89x0.c +0 -0
@@ -189,6 +193,9 @@ static unsigned int netcard_portlist[] __used __initdata = {

? ? ? PBC_BASE_ADDRESS + PBC_CS8900A_IOBASE + 0x300, 0 ?};
?static unsigned cs8900_irq_map[] = {EXPIO_INT_ENET_INT, 0, 0, 0};

drivers/net/cs89x0.c +3 -0
+#elif defined(CONFIG_CS89x0_PLATFORM)
+static unsigned int netcard_portlist[] __used __initdata = {0, 0};
+static unsigned int cs8900_irq_map[] = {0, 0, 0, 0};

?#else
?static unsigned int netcard_portlist[] __used __initdata =
? ? { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};

drivers/net/cs89x0.c +10 -2
@@ -1746,7 +1753,7 @@ static int set_mac_address(struct net_device *dev, void *p)
 ? ? ? return 0;
 ?}
 
-#ifdef MODULE
+#if defined(MODULE) && !defined(CONFIG_CS89x0_PLATFORM)
 
 ?static struct net_device *dev_cs89x0;
 
@@ -1900,7 +1907,77 @@ cleanup_module(void)
 ? ? ? release_region(dev_cs89x0->base_addr, NETCARD_IO_EXTENT);
 ? ? ? free_netdev(dev_cs89x0);
 ?}
-#endif /* MODULE */
+#endif /* MODULE && !CONFIG_CS89x0_PLATFORM */
+
+#ifdef CONFIG_CS89x0_PLATFORM
+static int cs89x0_platform_probe(struct platform_device *pdev)
+{
+ ? ? struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
+ ? ? struct resource *mem_res;
+ ? ? struct resource *irq_res;
+ ? ? int err;

drivers/net/cs89x0.c cleanup_module(void) · line 1928

Quoted 10 lines
drivers/net/cs89x0.c +10 -0
+
+ ? ? if (!dev)
+ ? ? ? ? ? ? return -ENODEV;
+
+ ? ? mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ ? ? irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ ? ? if (mem_res == NULL || irq_res == NULL) {
+ ? ? ? ? ? ? printk(KERN_WARNING
+ ? ? ? ? ? ? ? ? ? ?DRV_NAME
+ ? ? ? ? ? ? ? ? ? ?": memory and/or interrupt resource missing.\n");

I'd prefer you do:

Quoted 6 lines

? ? ? ?#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

at the top of the driver and then just use:

? ? ? ?pr_warning("memory and/or interrupt resource missing\m");

I agree.

Quoted 9 lines

drivers/net/cs89x0.c cleanup_module(void) · line 1934

Quoted 6 lines
drivers/net/cs89x0.c +6 -0
+ ? ? ? ? ? ? err = -ENOENT;
+ ? ? ? ? ? ? goto out;
+ ? ? }
+
+ ? ? cs8900_irq_map[0] = irq_res->start;
+ ? ? err = cs89x0_probe1(dev, mem_res->start, 0);

hmm, better switch the complete driver to be a platform driver and instead of the legacy probing let it create the corresponding device.

Quoted 5 lines

What exactly do you mean with "switch the complete driver to be a platform driver"? That I should remove all the legacy from the driver (which would break the driver for users who don't use it as a platform driver) or that I should add a new probe() function free of legacy (which would duplicate code of the existing cs89x0_probe1() function)?

Quoted 6 lines

Of course you should not break it for legacy users. Just instead of the legacy stuff just add a platform device with the respective values such that the platform driver is used in all cases.

For extra points move the adding of the device to platform code.

The platform device you mention is added by another patch that I also sent on the the 7th of September (not directly to you, but to Sascha and kernel at pengutronix.de). This patch was called:

[PATCH] Add CS890x0 ethernet controller support to the i.MX21ADS

In this patch I add a platform device to the i.MX21ADS evaluation board. All the required settings (memory address and IRQ) that the CS890x platform driver needs to run on the i.MX21ADS board are set in the i.MX21ADS specific code. You find the patch below. It this the approach you mean?

===================================
[PATCH] Add CS890x0 ethernet controller support to the i.MX21ADS

---
 arch/arm/mach-imx/mach-mx21ads.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
arch/arm/mach-imx/mach-mx21ads.c +21 -0
index 74ac889..62b4717 100644
@@ -159,6 +159,26 @@ static struct platform_device mx21ads_nor_mtd_device = {
       .resource = &mx21ads_flash_resource,
 };
 
+static struct resource mx21ads_cs8900_resources[] = {
+       {
+               .start  = (u32)MX21ADS_CS8900A_IOBASE_REG,
+               .end    = (u32)MX21ADS_CS8900A_IOBASE_REG + 0x200000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .start  = MX21ADS_CS8900A_IRQ,
+               .end    = MX21ADS_CS8900A_IRQ,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device mx21ads_cs8900_device = {
+       .name           = "cs89x0",
+       .id             = 0,
+       .num_resources  = ARRAY_SIZE(mx21ads_cs8900_resources),
+       .resource       = mx21ads_cs8900_resources,
+};
+
 static const struct imxuart_platform_data uart_pdata_rts __initconst = {
       .flags = IMXUART_HAVE_RTSCTS,
 };
@@ -275,6 +295,7 @@ static void __init mx21ads_map_io(void)
 
 static struct platform_device *platform_devices[] __initdata = {
       &mx21ads_nor_mtd_device,
+       &mx21ads_cs8900_device
 };
 
 static void __init mx21ads_board_init(void)

--
1.7.1

Quoted 7 lines

Best regards
Uwe

--

Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | Uwe Kleine-K?nig ? ? ? ? ? ?|
Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|

Regards,
Jaccon

#5 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

Hello Jaccon,

Quoted 20 lines · Jaccon Bastiaansen
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

hmm, better switch the complete driver to be a platform driver and instead of the legacy probing let it create the corresponding device.

What exactly do you mean with "switch the complete driver to be a platform driver"? That I should remove all the legacy from the driver (which would break the driver for users who don't use it as a platform driver) or that I should add a new probe() function free of legacy (which would duplicate code of the existing cs89x0_probe1() function)?

Quoted 6 lines

Of course you should not break it for legacy users. Just instead of the legacy stuff just add a platform device with the respective values such that the platform driver is used in all cases.

For extra points move the adding of the device to platform code.

The platform device you mention is added by another patch that I also sent on the the 7th of September (not directly to you, but to Sascha and kernel at pengutronix.de). This patch was called:

Quoted 7 lines

[PATCH] Add CS890x0 ethernet controller support to the i.MX21ADS

In this patch I add a platform device to the i.MX21ADS evaluation board. All the required settings (memory address and IRQ) that the CS890x platform driver needs to run on the i.MX21ADS board are set in the i.MX21ADS specific code. You find the patch below. It this the approach you mean?

not really. On some machines (e.g arm/imx/mx31ads) some magic constants are defined somewhere in arch/ to fill in netcard_portlist and cs8900_irq_map. On these machines the cs8900 driver does drive some hardware, but not via the platform bus. This is what i want to have changed.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#6 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

Hello Uwe,

2011/9/11 Uwe Kleine-K?nig <[email protected]>:

Quoted 30 lines

Hello Jaccon,

Quoted 20 lines · Jaccon Bastiaansen
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

hmm, better switch the complete driver to be a platform driver and instead of the legacy probing let it create the corresponding device.

What exactly do you mean with "switch the complete driver to be a platform driver"? That I should remove all the legacy from the driver (which would break the driver for users who don't use it as a platform driver) or that I should add a new probe() function free of legacy (which would duplicate code of the existing cs89x0_probe1() function)?

Quoted 6 lines

Of course you should not break it for legacy users. Just instead of the legacy stuff just add a platform device with the respective values such that the platform driver is used in all cases.

For extra points move the adding of the device to platform code.

The platform device you mention is added by another patch that I also sent on the the 7th of September (not directly to you, but to Sascha and kernel at pengutronix.de). This patch was called:

Quoted 7 lines

[PATCH] Add CS890x0 ethernet controller support to the i.MX21ADS

In this patch I add a platform device to the i.MX21ADS evaluation board. All the required settings (memory address and IRQ) that the CS890x platform driver needs to run on the i.MX21ADS board are set in the i.MX21ADS specific code. You find the patch below. It this the approach you mean?

Quoted 6 lines

not really. On some machines (e.g arm/imx/mx31ads) some magic constants are defined somewhere in arch/ to fill in netcard_portlist and cs8900_irq_map. On these machines the cs8900 driver does drive some hardware, but not via the platform bus. This is what i want to have changed.

Ok, so you would like to see the #ifdefs for the IXDP2351, IXDP2X01, QQ2440 and MX31ADS in the cs890x driver replaced by platform_device definitions in the platform specific code of those platforms (in the same way as I have done for the i.MX21ADS platform)? Is this correct?

Quoted 7 lines

Best regards
Uwe

--

Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | Uwe Kleine-K?nig ? ? ? ? ? ?|
Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|

Regards,
Jaccon

#7 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

Hello Jaccon,

Quoted 8 lines · Jaccon Bastiaansen

2011/9/11 Uwe Kleine-K?nig <[email protected]>:

Quoted 6 lines

On some machines (e.g arm/imx/mx31ads) some magic constants
are defined somewhere in arch/ to fill in netcard_portlist and cs8900_irq_map. On these machines the cs8900 driver does drive some hardware, but not via the platform bus. This is what i want to have changed.

Quoted 4 lines

Ok, so you would like to see the #ifdefs for the IXDP2351, IXDP2X01, QQ2440 and MX31ADS in the cs890x driver replaced by platform_device definitions in the platform specific code of those platforms (in the same way as I have done for the i.MX21ADS platform)? Is this correct?

More or less, yes. I would have started to keep the change local to the cs8900 driver, but moving the devices to arch is the final goal.

The upside of first reworking the driver and only then move the devices out is that it might be better/easier to bisect and review.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

Hello Domenico,

2011/9/28 Domenico Andreoli <[email protected]>:

Quoted 14 lines

Hi Jaccon,

Quoted 5 lines · Jaccon Bastiaansen

Ok, so you would like to see the #ifdefs for the IXDP2351, IXDP2X01, QQ2440 and MX31ADS in the cs890x driver replaced by platform_device definitions in the platform specific code of those platforms (in the same way as I have done for the i.MX21ADS platform)? Is this correct?

Feel free to completely dump the QQ2440 thing, the QQ2440 board support is not in mainline and will not until it can be implemented mostly with DT, I guess. ?At that time I will be happy to use your platform device conversion - with the OF initialization that sombody will write ;)

Quoted 5 lines

I will test it.

cheers,
Domenico

This patch does what you describe and removes the QQ2440 board support.

Regards,
Jaccon

#10 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

Quoted 16 lines · Jaccon Bastiaansen

Hello Domenico,

2011/9/28 Domenico Andreoli <[email protected]>:

Quoted 13 lines

Hi Jaccon,

Quoted 5 lines · Jaccon Bastiaansen

Ok, so you would like to see the #ifdefs for the IXDP2351, IXDP2X01, QQ2440 and MX31ADS in the cs890x driver replaced by platform_device definitions in the platform specific code of those platforms (in the same way as I have done for the i.MX21ADS platform)? Is this correct?

Feel free to completely dump the QQ2440 thing, the QQ2440 board support is not in mainline and will not until it can be implemented mostly with DT, I guess. ?At that time I will be happy to use your platform device conversion - with the OF initialization that sombody will write ;)

I don't have Domenico's original mail...

The QQ2440 thing got submitted into the patch system while the consolidation push was going on earlier in the year, so I ignored it (along with the other platforms which people submitted without regard to Linus' rant.)

It's now up to the SoC maintainers whether they want to accept this stuff, and if so how to get it into mainline (probably via Arnd) - be that in their current form or if they think that a DT based implementation is better.

I'll be discarding the four 'new' platforms (of which QQ2440 is one) which have been sitting in the patch system since March in the next few days.

#11 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

Quoted 13 lines · Russell King - ARM Linux
Quoted 12 lines · Jaccon Bastiaansen

Hello Domenico,

2011/9/28 Domenico Andreoli <[email protected]>:

Quoted 9 lines

Hi Jaccon,

Quoted 5 lines · Jaccon Bastiaansen

Ok, so you would like to see the #ifdefs for the IXDP2351, IXDP2X01, QQ2440 and MX31ADS in the cs890x driver replaced by platform_device definitions in the platform specific code of those platforms (in the same way as I have done for the i.MX21ADS platform)? Is this correct?

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

Feel free to completely dump the QQ2440 thing, the QQ2440 board support is not in mainline and will not until it can be implemented mostly with DT, I guess. ?At that time I will be happy to use your platform device conversion - with the OF initialization that sombody will write ;)

I don't have Domenico's original mail...

yes, there was a problem on my side that I hope is now fixed.

Quoted 7 lines

It's now up to the SoC maintainers whether they want to accept this stuff, and if so how to get it into mainline (probably via Arnd) - be that in their current form or if they think that a DT based implementation is better.

I'll be discarding the four 'new' platforms (of which QQ2440 is one) which have been sitting in the patch system since March in the next few days.

thank you.

Regards,
Domenico

maintainer
#12 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

In reply to Uwe Kleine-König
Quoted 143 lines · Uwe Kleine-K?nig

Hello Jaccon,

Quoted 30 lines · Jaccon Bastiaansen

The CS89x0 ethernet controller is used on a number of evaluation boards, such as the MX31ADS. The current driver has memory address and IRQ settings for each board on which this controller is used. Driver updates are therefore required to support other boards that also use the CS89x0. To avoid these driver updates, a better mechanism (platform driver support) is added to communicate the board dependent settings to the driver.

---
 drivers/net/Kconfig  |   18 +++++++++--
 drivers/net/Space.c  |    2 +-
 drivers/net/cs89x0.c |   83 ++++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 96 insertions(+), 7 deletions(-)
drivers/net/Kconfig +1 -2
index 93359fa..17be84f 100644
@@ -1497,8 +1497,7 @@ config FORCEDETH
 
 config CS89x0
 	tristate "CS89x0 support"
-	depends on NET_ETHERNET && (ISA || EISA || MACH_IXDP2351 \
-		|| ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440)
+	depends on NET_ETHERNET
 	---help---
 	  Support for CS89x0 chipset based Ethernet cards. If you have a
 	  network (Ethernet) card of this type, say Y and read the

drivers/net/Kconfig config CS89x0 · line 1514

Quoted 7 lines
drivers/net/Kconfig +4 -0
@@ -1509,10 +1508,23 @@ config CS89x0
 	  To compile this driver as a module, choose M here. The module
 	  will be called cs89x0.
 
+config CS89x0_PLATFORM
+	bool "CS89x0 platform driver support"
+	depends on CS89x0
+	default n

default n is implicit so you don't need (and should not) add it here.

Quoted 44 lines
drivers/net/Kconfig +10 -1
+	help
+	  Say Y to compile the cs890x0 driver as a platform driver. This
+	  makes this driver suitable for use on certain evaluation boards
+	  such as the IMX21ADS.
+
+	  If you are unsure, say N.
+
 config CS89x0_NONISA_IRQ
 	def_bool y
 	depends on CS89x0 != n
-	depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440
+	depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || \
+		   MACH_QQ2440 || CS89x0_PLATFORM
+
 
 config TC35815
 	tristate "TOSHIBA TC35815 Ethernet support"
drivers/net/Space.c +1 -1
index 068c356..3c53ab1 100644
@@ -189,7 +189,7 @@ static struct devprobe2 isa_probes[] __initdata = {
 #ifdef CONFIG_SEEQ8005
 	{seeq8005_probe, 0},
 #endif
-#ifdef CONFIG_CS89x0
+#if defined(CONFIG_CS89x0) && !defined(CONFIG_CS89x0_PLATFORM)
  	{cs89x0_probe, 0},
 #endif
 #ifdef CONFIG_AT1700
drivers/net/cs89x0.c +2 -0
index 537a4b2..604c828 100644
@@ -98,6 +98,8 @@
   Domenico Andreoli : cavokz at gmail.com
                     : QQ2440 platform support
 
+  Jaccon Bastiaansen: jaccon.bastiaansen at gmail.com
+		    : added platform driver support
 */
 
 /* Always include 'config.h' first in case the user wants to turn on

drivers/net/cs89x0.c line 161

Quoted 7 lines
drivers/net/cs89x0.c +3 -1
@@ -154,7 +156,9 @@
 #if ALLOW_DMA
 #include <asm/dma.h>
 #endif
-
+#ifdef CONFIG_CS89x0_PLATFORM
+#include <linux/platform_device.h>
+#endif

IMHO better include that unconditionally.

Quoted 36 lines
drivers/net/cs89x0.c +13 -2
 #include "cs89x0.h"
 
 static char version[] __initdata =
@@ -189,6 +193,9 @@ static unsigned int netcard_portlist[] __used __initdata = {
 	PBC_BASE_ADDRESS + PBC_CS8900A_IOBASE + 0x300, 0
 };
 static unsigned cs8900_irq_map[] = {EXPIO_INT_ENET_INT, 0, 0, 0};
+#elif defined(CONFIG_CS89x0_PLATFORM)
+static unsigned int netcard_portlist[] __used __initdata = {0, 0};
+static unsigned int cs8900_irq_map[] = {0, 0, 0, 0};
 #else
 static unsigned int netcard_portlist[] __used __initdata =
    { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};
@@ -1746,7 +1753,7 @@ static int set_mac_address(struct net_device *dev, void *p)
 	return 0;
 }
 
-#ifdef MODULE
+#if defined(MODULE) && !defined(CONFIG_CS89x0_PLATFORM)
 
 static struct net_device *dev_cs89x0;
 
@@ -1900,7 +1907,77 @@ cleanup_module(void)
 	release_region(dev_cs89x0->base_addr, NETCARD_IO_EXTENT);
 	free_netdev(dev_cs89x0);
 }
-#endif /* MODULE */
+#endif /* MODULE && !CONFIG_CS89x0_PLATFORM */
+
+#ifdef CONFIG_CS89x0_PLATFORM
+static int cs89x0_platform_probe(struct platform_device *pdev)
+{
+	struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
+	struct resource *mem_res;
+	struct resource *irq_res;
+	int err;

drivers/net/cs89x0.c cleanup_module(void) · line 1928

Quoted 10 lines
drivers/net/cs89x0.c +10 -0
+
+	if (!dev)
+		return -ENODEV;
+
+	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (mem_res == NULL || irq_res == NULL) {
+		printk(KERN_WARNING
+		       DRV_NAME
+		       ": memory and/or interrupt resource missing.\n");

I'd prefer you do:

Quoted 5 lines
	#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

at the top of the driver and then just use:

	pr_warning("memory and/or interrupt resource missing\m");

Why not use dev_warn??

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#13 lore raw

PATCH 1/1 Add platform driver support to the CS890x driver

Hello,

Quoted 6 lines · Sascha Hauer
Quoted 5 lines · Uwe Kleine-K?nig

drivers/net/cs89x0.c cleanup_module(void) · line 1928

Quoted 3 lines
drivers/net/cs89x0.c +3 -0
+		printk(KERN_WARNING
+		       DRV_NAME
+		       ": memory and/or interrupt resource missing.\n");

I'd prefer you do:

Quoted 7 lines
Quoted 5 lines
	#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

at the top of the driver and then just use:

	pr_warning("memory and/or interrupt resource missing\m");

Why not use dev_warn??

Yeah, that works, too.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#14 lore raw

PATCH v2 1/1 Add platform driver support to the CS890x driver

The CS89x0 ethernet controller is used on a number of evaluation boards, such as the MX31ADS. The current driver has memory address and IRQ settings for each board on which this controller is used. Driver updates are therefore required to support other boards that also use the CS89x0. To avoid these driver updates, a better mechanism (platform driver support) is added to communicate the board dependent settings to the driver.

---
 arch/arm/mach-imx/mach-mx31ads.c               |   40 ++++++-
 arch/arm/mach-ixp2000/ixdp2x01.c               |   24 +++-
 arch/arm/mach-ixp2000/pci.c                    |    3 +-
 arch/arm/mach-ixp23xx/ixdp2351.c               |   21 +++
 arch/arm/mach-ixp23xx/pci.c                    |    3 +-
 arch/arm/plat-mxc/include/mach/board-mx31ads.h |   33 -----
 drivers/net/Kconfig                            |   16 ++-
 drivers/net/Space.c                            |    2 +-
 drivers/net/cs89x0.c                           |  175 +++++++++++++++---------
 9 files changed, 210 insertions(+), 107 deletions(-)
 delete mode 100644 arch/arm/plat-mxc/include/mach/board-mx31ads.h
arch/arm/mach-imx/mach-mx31ads.c +39 -1
index f4dee02..007bd38 100644
@@ -28,7 +28,6 @@
 #include <asm/memory.h>
 #include <asm/mach/map.h>
 #include <mach/common.h>
-#include <mach/board-mx31ads.h>
 #include <mach/iomux-mx3.h>
 
 #ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
@@ -62,6 +61,7 @@
 #define PBC_INTMASK_CLEAR_REG	(PBC_INTMASK_CLEAR + PBC_BASE_ADDRESS)
 #define EXPIO_PARENT_INT	IOMUX_TO_IRQ(MX31_PIN_GPIO1_4)
 
+#define MXC_EXP_IO_BASE		(MXC_BOARD_IRQ_START)
 #define MXC_IRQ_TO_EXPIO(irq)	((irq) - MXC_EXP_IO_BASE)
 
 #define EXPIO_INT_XUART_INTA	(MXC_EXP_IO_BASE + 10)
@@ -69,6 +69,18 @@
 
 #define MXC_MAX_EXP_IO_LINES	16
 
+
+/* Base address of PBC controller */
+#define PBC_BASE_ADDRESS        MX31_CS4_BASE_ADDR_VIRT
+
+/* Offsets for the PBC Controller register */
+
+/* Ethernet Controller IO addresses */
+#define PBC_CS8900A_IOBASE      0x020000
+#define CS8900A_START		(PBC_BASE_ADDRESS + PBC_CS8900A_IOBASE + 0x300)
+
+#define EXPIO_INT_ENET_INT	(MXC_EXP_IO_BASE + 8)
+
 /*
  * The serial port definition structure.
  */
@@ -101,11 +113,36 @@ static struct platform_device serial_device = {
 	},
 };
 
+static struct resource mx31ads_cs8900_resources[] = {
+	{
+		.start	= (u32)CS8900A_START,
+		.end	= (u32)CS8900A_START + 0x1000 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= EXPIO_INT_ENET_INT,
+		.end	= EXPIO_INT_ENET_INT,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device mx31ads_cs8900_device = {
+	.name		= "cs89x0",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(mx31ads_cs8900_resources),
+	.resource	= mx31ads_cs8900_resources,
+};
+
 static int __init mxc_init_extuart(void)
 {
 	return platform_device_register(&serial_device);
 }
 
+static void __init mxc_init_ext_ethernet(void)
+{
+	platform_device_register(&mx31ads_cs8900_device);
+}
+
 static const struct imxuart_platform_data uart_pdata __initconst = {
 	.flags = IMXUART_HAVE_RTSCTS,
 };
@@ -520,6 +557,7 @@ static void __init mx31ads_init(void)
 	mxc_init_imx_uart();
 	mxc_init_i2c();
 	mxc_init_audio();
+	mxc_init_ext_ethernet();
 }
 
 static void __init mx31ads_timer_init(void)
arch/arm/mach-ixp2000/ixdp2x01.c +23 -1
index 84835b2..1ec4a74 100644
@@ -394,9 +394,31 @@ static struct platform_device ixdp2x01_i2c_controller = {
 	.num_resources	= 0
 };
 
+static struct resource ixdp2x01_cs8900_resources[] = {
+	{
+		.start	= (u32)IXDP2X01_CS8900_VIRT_BASE,
+		.end	= (u32)IXDP2X01_CS8900_VIRT_BASE + 0x1000 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= IRQ_IXDP2X01_CS8900,
+		.end	= IRQ_IXDP2X01_CS8900,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device ixdp2x01_cs8900 = {
+	.name		= "cs89x0",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(ixdp2x01_cs8900_resources),
+	.resource	= ixdp2x01_cs8900_resources,
+};
+
+
 static struct platform_device *ixdp2x01_devices[] __initdata = {
 	&ixdp2x01_flash,
-	&ixdp2x01_i2c_controller
+	&ixdp2x01_i2c_controller,
+	&ixdp2x01_cs8900
 };
 
 static void __init ixdp2x01_init_machine(void)
arch/arm/mach-ixp2000/pci.c +2 -1
index f797c5f..54bf1b8 100644
@@ -130,7 +130,8 @@ static struct pci_ops ixp2000_pci_ops = {
 	.write	= ixp2000_pci_write_config
 };
 
-struct pci_bus *ixp2000_pci_scan_bus(int nr, struct pci_sys_data *sysdata)
+struct pci_bus __devinit
+*ixp2000_pci_scan_bus(int nr, struct pci_sys_data *sysdata)
 {
 	return pci_scan_bus(sysdata->busnr, &ixp2000_pci_ops, sysdata);
 }
arch/arm/mach-ixp23xx/ixdp2351.c +21 -0
index 8dcba17..d559110 100644
@@ -311,6 +311,26 @@ static struct platform_device ixdp2351_flash = {
 	.resource	= &ixdp2351_flash_resource,
 };
 
+static struct resource ixdp2351_cs8900_resources[] = {
+	{
+		.start	= (u32)IXDP2351_VIRT_CS8900_BASE,
+		.end	= (u32)IXDP2351_VIRT_CS8900_BASE + 0x1000 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= IRQ_IXDP2351_CS8900,
+		.end	= IRQ_IXDP2351_CS8900,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device ixdp2351_cs8900 = {
+	.name		= "cs89x0",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(ixdp2351_cs8900_resources),
+	.resource	= ixdp2351_cs8900_resources,
+};
+
 static void __init ixdp2351_init(void)
 {
 	platform_device_register(&ixdp2351_flash);
@@ -323,6 +343,7 @@ static void __init ixdp2351_init(void)
 	IXP23XX_EXP_CS0[2] |= IXP23XX_FLASH_WRITABLE;
 	IXP23XX_EXP_CS0[3] |= IXP23XX_FLASH_WRITABLE;
 
+	platform_device_register(&ixdp2351_cs8900);
 	ixp23xx_sys_init();
 }
 
arch/arm/mach-ixp23xx/pci.c +2 -1
index 563819a..f82bb91 100644
@@ -141,7 +141,8 @@ struct pci_ops ixp23xx_pci_ops = {
 	.write	= ixp23xx_pci_write_config,
 };
 
-struct pci_bus *ixp23xx_pci_scan_bus(int nr, struct pci_sys_data *sysdata)
+struct pci_bus __devinit
+*ixp23xx_pci_scan_bus(int nr, struct pci_sys_data *sysdata)
 {
 	return pci_scan_bus(sysdata->busnr, &ixp23xx_pci_ops, sysdata);
 }
arch/arm/plat-mxc/include/mach/board-mx31ads.h deleted +0 -33
deleted file mode 100644
index 94b60dd..0000000
@@ -1,33 +0,0 @@
-/*
- * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef __ASM_ARCH_MXC_BOARD_MX31ADS_H__
-#define __ASM_ARCH_MXC_BOARD_MX31ADS_H__
-
-#include <mach/hardware.h>
-
-/*
- * These symbols are used by drivers/net/cs89x0.c.
- * This is ugly as hell, but we have to provide them until
- * someone fixed the driver.
- */
-
-/* Base address of PBC controller */
-#define PBC_BASE_ADDRESS        MX31_CS4_BASE_ADDR_VIRT
-/* Offsets for the PBC Controller register */
-
-/* Ethernet Controller IO base address */
-#define PBC_CS8900A_IOBASE      0x020000
-
-#define MXC_EXP_IO_BASE		(MXC_BOARD_IRQ_START)
-
-#define EXPIO_INT_ENET_INT	(MXC_EXP_IO_BASE + 8)
-
-#endif /* __ASM_ARCH_MXC_BOARD_MX31ADS_H__ */
drivers/net/Kconfig +10 -6
index 93359fa..2873f86 100644
@@ -1497,8 +1497,7 @@ config FORCEDETH
 
 config CS89x0
 	tristate "CS89x0 support"
-	depends on NET_ETHERNET && (ISA || EISA || MACH_IXDP2351 \
-		|| ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440)
+	depends on NET_ETHERNET
 	---help---
 	  Support for CS89x0 chipset based Ethernet cards. If you have a
 	  network (Ethernet) card of this type, say Y and read the
@@ -1509,10 +1508,15 @@ config CS89x0
 	  To compile this driver as a module, choose M here. The module
 	  will be called cs89x0.
 
-config CS89x0_NONISA_IRQ
-	def_bool y
-	depends on CS89x0 != n
-	depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440
+config CS89x0_PLATFORM
+	bool "CS89x0 platform driver support"
+	depends on CS89x0
+	help
+	  Say Y to compile the cs890x0 driver as a platform driver. This
+	  makes this driver suitable for use on certain evaluation boards
+	  such as the IMX21ADS.
+
+	  If you are unsure, say N.
 
 config TC35815
 	tristate "TOSHIBA TC35815 Ethernet support"
drivers/net/Space.c +1 -1
index 068c356..3c53ab1 100644
@@ -189,7 +189,7 @@ static struct devprobe2 isa_probes[] __initdata = {
 #ifdef CONFIG_SEEQ8005
 	{seeq8005_probe, 0},
 #endif
-#ifdef CONFIG_CS89x0
+#if defined(CONFIG_CS89x0) && !defined(CONFIG_CS89x0_PLATFORM)
  	{cs89x0_probe, 0},
 #endif
 #ifdef CONFIG_AT1700
drivers/net/cs89x0.c +112 -63

265 lines not on this page · raw message

Signature · 1 line
1.7.1
#15 lore raw

PATCH v2 1/1 Add platform driver support to the CS890x driver

Hello,

This patch hasn't been sent to the netdev mailing list before, sorry for that.

Jaccon

---------- Forwarded message ----------
From: Jaccon Bastiaansen <[email protected]>
Date: 2011/9/27
Subject: [PATCH V2] Add platform driver support to the CS890x driver
To: [email protected], [email protected], [email protected]
Cc: [email protected], Jaccon Bastiaansen <[email protected]>

The CS89x0 ethernet controller is used on a number of evaluation boards, such as the MX31ADS. The current driver has memory address and IRQ settings for each board on which this controller is used. Driver updates are therefore required to support other boards that also use the CS89x0. To avoid these driver updates, a better mechanism (platform driver support) is added to communicate the board dependent settings to the driver.

---
 arch/arm/mach-imx/mach-mx31ads.c               |   40 ++++++- arch/arm/mach-ixp2000/ixdp2x01.c               |   24 +++- arch/arm/mach-ixp2000/pci.c                    |    3 +- arch/arm/mach-ixp23xx/ixdp2351.c               |   21 +++ arch/arm/mach-ixp23xx/pci.c                    |    3 +- arch/arm/plat-mxc/include/mach/board-mx31ads.h |   33 ----- drivers/net/Kconfig                            |   16 ++- drivers/net/Space.c                            |    2 +- drivers/net/cs89x0.c                           |  175 +++++++++++++++---------

 9 files changed, 210 insertions(+), 107 deletions(-)

 delete mode 100644 arch/arm/plat-mxc/include/mach/board-mx31ads.h

arch/arm/mach-imx/mach-mx31ads.c +0 -0
index f4dee02..007bd38 100644
@@ -28,7 +28,6 @@

 #include <asm/memory.h>
 #include <asm/mach/map.h>
 #include <mach/common.h>
-#include <mach/board-mx31ads.h>
 #include <mach/iomux-mx3.h>

 #ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
@@ -62,6 +61,7 @@
 #define PBC_INTMASK_CLEAR_REG  (PBC_INTMASK_CLEAR + PBC_BASE_ADDRESS) #define EXPIO_PARENT_INT       IOMUX_TO_IRQ(MX31_PIN_GPIO1_4)

+#define MXC_EXP_IO_BASE                (MXC_BOARD_IRQ_START) #define MXC_IRQ_TO_EXPIO(irq)  ((irq) - MXC_EXP_IO_BASE)

 #define EXPIO_INT_XUART_INTA   (MXC_EXP_IO_BASE + 10) @@ -69,6 +69,18 @@

 #define MXC_MAX_EXP_IO_LINES   16

+
+/* Base address of PBC controller */
+#define PBC_BASE_ADDRESS        MX31_CS4_BASE_ADDR_VIRT
+
+/* Offsets for the PBC Controller register */
+
+/* Ethernet Controller IO addresses */
+#define PBC_CS8900A_IOBASE      0x020000
+#define CS8900A_START          (PBC_BASE_ADDRESS + PBC_CS8900A_IOBASE + 0x300) +
+#define EXPIO_INT_ENET_INT     (MXC_EXP_IO_BASE + 8)
+
 /*
 * The serial port definition structure.
 */
@@ -101,11 +113,36 @@ static struct platform_device serial_device = { },
 };

+static struct resource mx31ads_cs8900_resources[] = {
+       {
+               .start  = (u32)CS8900A_START,
+               .end    = (u32)CS8900A_START + 0x1000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .start  = EXPIO_INT_ENET_INT,
+               .end    = EXPIO_INT_ENET_INT,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device mx31ads_cs8900_device = {
+       .name           = "cs89x0",
+       .id             = 0,
+       .num_resources  = ARRAY_SIZE(mx31ads_cs8900_resources),
+       .resource       = mx31ads_cs8900_resources, +};
+
 static int __init mxc_init_extuart(void)
 {
       return platform_device_register(&serial_device); }

+static void __init mxc_init_ext_ethernet(void)
+{
+       platform_device_register(&mx31ads_cs8900_device); +}
+
 static const struct imxuart_platform_data uart_pdata __initconst = { .flags = IMXUART_HAVE_RTSCTS,
 };
@@ -520,6 +557,7 @@ static void __init mx31ads_init(void) mxc_init_imx_uart();
       mxc_init_i2c();
       mxc_init_audio();
+       mxc_init_ext_ethernet();
 }

 static void __init mx31ads_timer_init(void)

arch/arm/mach-ixp2000/ixdp2x01.c +0 -0
index 84835b2..1ec4a74 100644
@@ -394,9 +394,31 @@ static struct platform_device ixdp2x01_i2c_controller = {

       .num_resources  = 0
 };

+static struct resource ixdp2x01_cs8900_resources[] = {
+       {
+               .start  = (u32)IXDP2X01_CS8900_VIRT_BASE,
+               .end    = (u32)IXDP2X01_CS8900_VIRT_BASE + 0x1000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .start  = IRQ_IXDP2X01_CS8900,
+               .end    = IRQ_IXDP2X01_CS8900,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device ixdp2x01_cs8900 = {
+       .name           = "cs89x0",
+       .id             = 0,
+       .num_resources  = ARRAY_SIZE(ixdp2x01_cs8900_resources),
+       .resource       = ixdp2x01_cs8900_resources,
+};
+
+
 static struct platform_device *ixdp2x01_devices[] __initdata = { &ixdp2x01_flash,
-       &ixdp2x01_i2c_controller
+       &ixdp2x01_i2c_controller,
+       &ixdp2x01_cs8900
 };

 static void __init ixdp2x01_init_machine(void)

arch/arm/mach-ixp2000/pci.c +0 -0
index f797c5f..54bf1b8 100644
@@ -130,7 +130,8 @@ static struct pci_ops ixp2000_pci_ops = {

       .write  = ixp2000_pci_write_config
 };

-struct pci_bus *ixp2000_pci_scan_bus(int nr, struct pci_sys_data *sysdata) +struct pci_bus __devinit
+*ixp2000_pci_scan_bus(int nr, struct pci_sys_data *sysdata)
 {
       return pci_scan_bus(sysdata->busnr, &ixp2000_pci_ops, sysdata); }

arch/arm/mach-ixp23xx/ixdp2351.c +0 -0
index 8dcba17..d559110 100644
@@ -311,6 +311,26 @@ static struct platform_device ixdp2351_flash = {

       .resource       = &ixdp2351_flash_resource, };

+static struct resource ixdp2351_cs8900_resources[] = {
+       {
+               .start  = (u32)IXDP2351_VIRT_CS8900_BASE,
+               .end    = (u32)IXDP2351_VIRT_CS8900_BASE + 0x1000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .start  = IRQ_IXDP2351_CS8900,
+               .end    = IRQ_IXDP2351_CS8900,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device ixdp2351_cs8900 = {
+       .name           = "cs89x0",
+       .id             = 0,
+       .num_resources  = ARRAY_SIZE(ixdp2351_cs8900_resources),
+       .resource       = ixdp2351_cs8900_resources,
+};
+
 static void __init ixdp2351_init(void)
 {
       platform_device_register(&ixdp2351_flash);
@@ -323,6 +343,7 @@ static void __init ixdp2351_init(void) IXP23XX_EXP_CS0[2] |= IXP23XX_FLASH_WRITABLE; IXP23XX_EXP_CS0[3] |= IXP23XX_FLASH_WRITABLE;

+       platform_device_register(&ixdp2351_cs8900); ixp23xx_sys_init();
 }

arch/arm/mach-ixp23xx/pci.c +0 -0
index 563819a..f82bb91 100644
@@ -141,7 +141,8 @@ struct pci_ops ixp23xx_pci_ops = {

       .write  = ixp23xx_pci_write_config,
 };

-struct pci_bus *ixp23xx_pci_scan_bus(int nr, struct pci_sys_data *sysdata) +struct pci_bus __devinit
+*ixp23xx_pci_scan_bus(int nr, struct pci_sys_data *sysdata)
 {
       return pci_scan_bus(sysdata->busnr, &ixp23xx_pci_ops, sysdata); }

(quoted diff) +0 -0

b/arch/arm/plat-mxc/include/mach/board-mx31ads.h
deleted file mode 100644
index 94b60dd..0000000

arch/arm/plat-mxc/include/mach/board-mx31ads.h deleted +0 -33
@@ -1,33 +0,0 @@
-/*
- * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef __ASM_ARCH_MXC_BOARD_MX31ADS_H__
-#define __ASM_ARCH_MXC_BOARD_MX31ADS_H__
-
-#include <mach/hardware.h>
-
-/*
- * These symbols are used by drivers/net/cs89x0.c.
- * This is ugly as hell, but we have to provide them until
- * someone fixed the driver.
- */
-
-/* Base address of PBC controller */
-#define PBC_BASE_ADDRESS        MX31_CS4_BASE_ADDR_VIRT
-/* Offsets for the PBC Controller register */
-
-/* Ethernet Controller IO base address */
-#define PBC_CS8900A_IOBASE      0x020000
-
-#define MXC_EXP_IO_BASE                (MXC_BOARD_IRQ_START)
-
-#define EXPIO_INT_ENET_INT     (MXC_EXP_IO_BASE + 8)
-
-#endif /* __ASM_ARCH_MXC_BOARD_MX31ADS_H__ */
drivers/net/Kconfig +0 -0
index 93359fa..2873f86 100644
@@ -1497,8 +1497,7 @@ config FORCEDETH
 

 config CS89x0
       tristate "CS89x0 support"
-       depends on NET_ETHERNET && (ISA || EISA || MACH_IXDP2351 \
-               || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440)
+       depends on NET_ETHERNET
       ---help---
         Support for CS89x0 chipset based Ethernet cards. If you have a network (Ethernet) card of this type, say Y and read the @@ -1509,10 +1508,15 @@ config CS89x0
         To compile this driver as a module, choose M here. The module will be called cs89x0.

-config CS89x0_NONISA_IRQ
-       def_bool y
-       depends on CS89x0 != n
-       depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440 +config CS89x0_PLATFORM
+       bool "CS89x0 platform driver support"
+       depends on CS89x0
+       help
+         Say Y to compile the cs890x0 driver as a platform driver. This
+         makes this driver suitable for use on certain evaluation boards
+         such as the IMX21ADS.
+
+         If you are unsure, say N.

 config TC35815
       tristate "TOSHIBA TC35815 Ethernet support"

drivers/net/Space.c +0 -0
index 068c356..3c53ab1 100644
@@ -189,7 +189,7 @@ static struct devprobe2 isa_probes[] __initdata = {

 #ifdef CONFIG_SEEQ8005
       {seeq8005_probe, 0},
 #endif
-#ifdef CONFIG_CS89x0
+#if defined(CONFIG_CS89x0) && !defined(CONFIG_CS89x0_PLATFORM) {cs89x0_probe, 0},
 #endif
 #ifdef CONFIG_AT1700

drivers/net/cs89x0.c +0 -0
index 537a4b2..b7fb3bc 100644
@@ -12,6 +12,14 @@

        The author may be reached at [email protected], Crynwr Software, 521 Pleasant Valley Rd., Potsdam, NY 13676

+Sources
+
+       Crynwr packet driver epktisa.
+
+       Crystal Semiconductor data sheets.
+
+
+
  Changelog:

  Mike Cruse        : [email protected]
@@ -98,39 +106,14 @@
  Domenico Andreoli : [email protected]
                    : QQ2440 platform support

+  Jaccon Bastiaansen: [email protected]
+                   : added platform driver support */

-/* Always include 'config.h' first in case the user wants to turn on
-   or override something. */
-#include <linux/module.h>
-
-/*
- * Set this to zero to disable DMA code
- *
- * Note that even if DMA is turned off we still support the 'dma' and 'use_dma'
- * module options so we don't break any startup scripts.
- */
-#ifndef CONFIG_ISA_DMA_API
-#define ALLOW_DMA      0
-#else
-#define ALLOW_DMA      1
-#endif
-
-/*
- * Set this to zero to remove all the debug statements via
- * dead code elimination
- */
-#define DEBUGGING      1
-
-/*
-  Sources:
-
-       Crynwr packet driver epktisa.
-
-       Crystal Semiconductor data sheets.
-
-*/
+#define pr_fmt(fmt)    KBUILD_MODNAME ": " fmt

+#include <linux/module.h>
+#include <linux/printk.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -147,21 +130,36 @@
 #include <linux/bitops.h>
 #include <linux/delay.h>
 #include <linux/gfp.h>
-
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
-#if ALLOW_DMA
+#include <linux/platform_device.h>
+#include "cs89x0.h"
+
+/*
+ * Set this to zero to disable DMA code
+ *
+ * Note that even if DMA is turned off we still support the 'dma' and 'use_dma'
+ * module options so we don't break any startup scripts.
+ */
+#ifndef CONFIG_ISA_DMA_API
+#define ALLOW_DMA      0
+#else
+#define ALLOW_DMA      1
 #include <asm/dma.h>
 #endif

-#include "cs89x0.h"
-
-static char version[] __initdata =
-"cs89x0.c: v2.4.3-pre1 Russell Nelson <[email protected]>, Andrew Morton\n"; +/*
+ * Set this to zero to remove all the debug statements via
+ * dead code elimination
+ */
+#define DEBUGGING      1

 #define DRV_NAME "cs89x0"

+static char version[] =
+"cs89x0.c: v2.4.3-pre1 Russell Nelson <[email protected]>, Andrew Morton\n"; +
 /* First, a few definitions that the brave might change.
   A zero-terminated list of I/O addresses to be probed. Some special flags.. Addr & 1 = Read back the address port, look for signature and reset @@ -173,22 +171,9 @@ static char version[] __initdata =
 /* The cs8900 has 4 IRQ pins, software selectable. cs8900_irq_map maps them to system IRQ numbers. This mapping is card specific and is set to the configuration of the Cirrus Eval board for this chip. */ -#if defined(CONFIG_MACH_IXDP2351)
-static unsigned int netcard_portlist[] __used __initdata = {IXDP2351_VIRT_CS8900_BASE, 0};
-static unsigned int cs8900_irq_map[] = {IRQ_IXDP2351_CS8900, 0, 0, 0}; -#elif defined(CONFIG_ARCH_IXDP2X01)
-static unsigned int netcard_portlist[] __used __initdata = {IXDP2X01_CS8900_VIRT_BASE, 0};
-static unsigned int cs8900_irq_map[] = {IRQ_IXDP2X01_CS8900, 0, 0, 0}; -#elif defined(CONFIG_MACH_QQ2440)
-#include <mach/qq2440.h>
-static unsigned int netcard_portlist[] __used __initdata = { QQ2440_CS8900_VIRT_BASE + 0x300, 0 };
-static unsigned int cs8900_irq_map[] = { QQ2440_CS8900_IRQ, 0, 0, 0 }; -#elif defined(CONFIG_MACH_MX31ADS)
-#include <mach/board-mx31ads.h>
-static unsigned int netcard_portlist[] __used __initdata = {
-       PBC_BASE_ADDRESS + PBC_CS8900A_IOBASE + 0x300, 0
-};
-static unsigned cs8900_irq_map[] = {EXPIO_INT_ENET_INT, 0, 0, 0}; +#if defined(CONFIG_CS89x0_PLATFORM)
+static unsigned int netcard_portlist[] __used __initdata = {0, 0}; +static unsigned int cs8900_irq_map[] = {0, 0, 0, 0};
 #else
 static unsigned int netcard_portlist[] __used __initdata =
   { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};
@@ -424,7 +409,7 @@ writereg(struct net_device *dev, u16 regno, u16 value) writeword(dev->base_addr, DATA_PORT, value);
 }

-static int __init
+static int
 wait_eeprom_ready(struct net_device *dev)
 {
       int timeout = jiffies;
@@ -437,7 +422,7 @@ wait_eeprom_ready(struct net_device *dev) return 0;
 }

-static int __init
+static int
 get_eeprom_data(struct net_device *dev, int off, int len, int *buffer) {
       int i;
@@ -455,7 +440,7 @@ get_eeprom_data(struct net_device *dev, int off, int len, int *buffer)
        return 0;
 }

-static int  __init
+static int
 get_eeprom_cksum(int off, int len, int *buffer)
 {
       int i, cksum;
@@ -503,7 +488,7 @@ static const struct net_device_ops net_ops = { Return 0 on success.
 */

-static int __init
+static int
 cs89x0_probe1(struct net_device *dev, int ioaddr, int modular) {
       struct net_local *lp = netdev_priv(dev);
@@ -529,9 +514,6 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
               lp->force = g_cs89x0_media__force;
 #endif

-#if defined(CONFIG_MACH_QQ2440)
-               lp->force |= FORCE_RJ45 | FORCE_FULL; -#endif
        }

       /* Grab the region so we can find another board if autoIRQ fails. */ @@ -737,7 +719,7 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
       } else {
               i = lp->isa_config & INT_NO_MASK;
               if (lp->chip_type == CS8900) {
-#ifdef CONFIG_CS89x0_NONISA_IRQ
+#ifdef CONFIG_CS89x0_PLATFORM
                       i = cs8900_irq_map[0];
 #else
                       /* Translate the IRQ using the IRQ mapping table. */ @@ -1228,7 +1210,7 @@ net_open(struct net_device *dev)
       }
       else
       {
-#ifndef CONFIG_CS89x0_NONISA_IRQ
+#ifndef CONFIG_CS89x0_PLATFORM
               if (((1 << dev->irq) & lp->irq_map) == 0) { printk(KERN_ERR "%s: IRQ %d is not in our map of allowable IRQs, which is %x\n",
                               dev->name, dev->irq, lp->irq_map); @@ -1746,7 +1728,7 @@ static int set_mac_address(struct net_device *dev, void *p)
       return 0;
 }

-#ifdef MODULE
+#if defined(MODULE) && !defined(CONFIG_CS89x0_PLATFORM)

 static struct net_device *dev_cs89x0;

@@ -1900,7 +1882,74 @@ cleanup_module(void) release_region(dev_cs89x0->base_addr, NETCARD_IO_EXTENT); free_netdev(dev_cs89x0);
 }
-#endif /* MODULE */
+#endif /* MODULE && !CONFIG_CS89x0_PLATFORM */
+
+#ifdef CONFIG_CS89x0_PLATFORM
+static int cs89x0_platform_probe(struct platform_device *pdev) +{
+       struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
+       struct resource *mem_res;
+       struct resource *irq_res;
+       int err;
+
+       if (!dev)
+               return -ENODEV;
+
+       mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+       if (mem_res == NULL || irq_res == NULL) {
+               pr_warning("memory and/or interrupt resource missing.\n");
+               err = -ENOENT;
+               goto out;
+       }
+
+       cs8900_irq_map[0] = irq_res->start;
+       err = cs89x0_probe1(dev, mem_res->start, 0);
+       if (err) {
+               pr_warning("no cs8900 or cs8920 detected.\n");
+               goto out;
+       }
+
+       platform_set_drvdata(pdev, dev);
+       return 0;
+out:
+       free_netdev(dev);
+       return err;
+}
+
+static int cs89x0_platform_remove(struct platform_device *pdev) +{
+       struct net_device *dev = platform_get_drvdata(pdev);
+
+       unregister_netdev(dev);
+       free_netdev(dev);
+       return 0;
+}
+
+static struct platform_driver cs89x0_platform_driver = {
+       .driver = {
+               .name   = DRV_NAME,
+               .owner  = THIS_MODULE,
+       },
+       .probe  = cs89x0_platform_probe,
+       .remove = cs89x0_platform_remove,
+};
+
+static int __init cs89x0_init(void)
+{
+       return platform_driver_register(&cs89x0_platform_driver); +}
+
+module_init(cs89x0_init);
+
+static void __exit cs89x0_cleanup(void)
+{
+       platform_driver_unregister(&cs89x0_platform_driver); +}
+
+module_exit(cs89x0_cleanup);
+
+#endif

 /*
 * Local variables:
--
1.7.1

maintainer
#16 lore raw

Hi Jaccon,

Quoted 3 lines · Jaccon Bastiaansen

Hello,

This patch hasn't been sent to the netdev mailing list before, sorry for that.

I appreciate what you are trying to do. The cs89x0 is still not dead and it's quite annoying that we do not have proper platform device driver support for it. Unfortunately your patch was ignored by the important people, so can you respin it? You should create a proper series from it with one patch for the driver and one patch per board. This helps to increase your visibility and also you can set the individual board maintainers on Cc for their board. Please also Cc [email protected] and the arm linux kernel mailing list. Your patch also contains some cleanups like the removal of the unused QQ2440. You should create a seperate patch for this, then it will be easier to review (and also people love to read 'cleanup' in a patch subject ;)

Your mailer turns tabs into spaces, you should fix this before resending.

Some more comments inline.

Quoted 7 lines

+static struct resource ixdp2x01_cs8900_resources[] = {
+       {
+               .start  = (u32)IXDP2X01_CS8900_VIRT_BASE,
+               .end    = (u32)IXDP2X01_CS8900_VIRT_BASE + 0x1000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },

This is wrong. resources are about physical addresses, not virtual. You have to ioremap them in the driver.

Quoted 8 lines
drivers/net/cs89x0.c +0 -0
index 537a4b2..b7fb3bc 100644
@@ -12,6 +12,14 @@

        The author may be reached at [email protected], Crynwr Software, 521 Pleasant Valley Rd., Potsdam, NY 13676

drivers/net/cs89x0.c

Quoted 8 lines
drivers/net/cs89x0.c +8 -0
+Sources
+
+       Crynwr packet driver epktisa.
+
+       Crystal Semiconductor data sheets.
+
+
+

This seems unrelated to this patch. Please drop.

Quoted 9 lines

  Changelog:

  Mike Cruse        : [email protected]

drivers/net/cs89x0.c +0 -0
@@ -98,39 +106,14 @@

  Domenico Andreoli : [email protected]
                    : QQ2440 platform support

+  Jaccon Bastiaansen: [email protected]
+                   : added platform driver support

The history in git is enough (and even better) than the changelog in the file headers. Please drop this.

Quoted 11 lines
drivers/net/cs89x0.c +11 -0
+
+#ifdef CONFIG_CS89x0_PLATFORM
+static int cs89x0_platform_probe(struct platform_device *pdev)
+{
+       struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
+       struct resource *mem_res;
+       struct resource *irq_res;
+       int err;
+
+       if (!dev)
+               return -ENODEV;

drivers/net/cs89x0.c

Quoted 10 lines
drivers/net/cs89x0.c +10 -0
+
+       mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+       if (mem_res == NULL || irq_res == NULL) {
+               pr_warning("memory and/or interrupt resource missing.\n");
+               err = -ENOENT;
+               goto out;
+       }
+
+       cs8900_irq_map[0] = irq_res->start;

This limits the driver to a single instance. I think this is ok for now as an intermediate step, but you should check this and bail out with -EBUSY if a second instance is registered.

drivers/net/cs89x0.c

Quoted 12 lines

+       err = cs89x0_probe1(dev, mem_res->start, 0);
+       if (err) {
+               pr_warning("no cs8900 or cs8920 detected.\n");
+               goto out;
+       }

drivers/net/cs89x0.c +7 -0
+
+       platform_set_drvdata(pdev, dev);
+       return 0;
+out:
+       free_netdev(dev);
+       return err;
+}

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#17 lore raw

Hello Sascha,

I will do this. Since I'm on holiday the rest of the week, it will take some time before I can post the new patches.

Regards,
Jaccon

2011/11/3 Sascha Hauer <[email protected]>:

Quoted 116 lines

Hi Jaccon,

Quoted 3 lines · Jaccon Bastiaansen

Hello,

This patch hasn't been sent to the netdev mailing list before, sorry for that.

I appreciate what you are trying to do. The cs89x0 is still not dead and it's quite annoying that we do not have proper platform device driver support for it. Unfortunately your patch was ignored by the important people, so can you respin it? You should create a proper series from it with one patch for the driver and one patch per board. This helps to increase your visibility and also you can set the individual board maintainers on Cc for their board. Please also Cc [email protected] and the arm linux kernel mailing list. Your patch also contains some cleanups like the removal of the unused QQ2440. You should create a seperate patch for this, then it will be easier to review (and also people love to read 'cleanup' in a patch subject ;)

Your mailer turns tabs into spaces, you should fix this before resending.

Some more comments inline.

Quoted 7 lines

+static struct resource ixdp2x01_cs8900_resources[] = {
+       {
+               .start  = (u32)IXDP2X01_CS8900_VIRT_BASE,
+               .end    = (u32)IXDP2X01_CS8900_VIRT_BASE + 0x1000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },

This is wrong. resources are about physical addresses, not virtual. You have to ioremap them in the driver.

Quoted 8 lines
drivers/net/cs89x0.c +0 -0
index 537a4b2..b7fb3bc 100644
@@ -12,6 +12,14 @@

        The author may be reached at [email protected], Crynwr Software, 521 Pleasant Valley Rd., Potsdam, NY 13676

drivers/net/cs89x0.c

Quoted 8 lines
drivers/net/cs89x0.c +8 -0
+Sources
+
+       Crynwr packet driver epktisa.
+
+       Crystal Semiconductor data sheets.
+
+
+

This seems unrelated to this patch. Please drop.

Quoted 9 lines

  Changelog:

  Mike Cruse        : [email protected]

drivers/net/cs89x0.c +0 -0
@@ -98,39 +106,14 @@

  Domenico Andreoli : [email protected]
                    : QQ2440 platform support

+  Jaccon Bastiaansen: [email protected]
+                   : added platform driver support

The history in git is enough (and even better) than the changelog in the file headers. Please drop this.

Quoted 11 lines
drivers/net/cs89x0.c +11 -0
+
+#ifdef CONFIG_CS89x0_PLATFORM
+static int cs89x0_platform_probe(struct platform_device *pdev)
+{
+       struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
+       struct resource *mem_res;
+       struct resource *irq_res;
+       int err;
+
+       if (!dev)
+               return -ENODEV;

drivers/net/cs89x0.c

Quoted 10 lines
drivers/net/cs89x0.c +10 -0
+
+       mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+       if (mem_res == NULL || irq_res == NULL) {
+               pr_warning("memory and/or interrupt resource missing.\n");
+               err = -ENOENT;
+               goto out;
+       }
+
+       cs8900_irq_map[0] = irq_res->start;

This limits the driver to a single instance. I think this is ok for now as an intermediate step, but you should check this and bail out with -EBUSY if a second instance is registered.

drivers/net/cs89x0.c

Quoted 12 lines

+       err = cs89x0_probe1(dev, mem_res->start, 0);
+       if (err) {
+               pr_warning("no cs8900 or cs8920 detected.\n");
+               goto out;
+       }

drivers/net/cs89x0.c +7 -0
+
+       platform_set_drvdata(pdev, dev);
+       return 0;
+out:
+       free_netdev(dev);
+       return err;
+}

Sascha

--
Pengutronix e.K.                           |                             | Industrial Linux Solutions                 | http://www.pengutronix.de/  | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    | Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |