Skip to contentSkip to conversation

arm: omap: fix bug with multiple smsc911x devices

PATCH Superseded Igor Grinberg 4 participants 13 messages Apr 21, 2011 – May 3, 2011

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

PATCH 1/2 arm: omap: fix bug with multiple smsc911x devices

kobject (c06a4250): tried to init an initialized object, something is seriously wrong.

introduced by commit 66293989:
(omap: convert boards that use SMSC911x to use gpmc-smsc911x)

fixed by allocating struct platform_device dynamically.

---
This has been boot tested with nfs root on cm-t35, and build tested on all other affected boards.

 arch/arm/mach-omap2/board-cm-t35.c              |    2 ++
 arch/arm/mach-omap2/board-igep0020.c            |    1 +
 arch/arm/mach-omap2/board-ldp.c                 |    1 +
 arch/arm/mach-omap2/board-omap3evm.c            |    1 +
 arch/arm/mach-omap2/board-omap3logic.c          |    1 +
 arch/arm/mach-omap2/board-omap3stalker.c        |    1 +
 arch/arm/mach-omap2/board-overo.c               |    2 ++
 arch/arm/mach-omap2/board-zoom-debugboard.c     |    1 +
 arch/arm/mach-omap2/gpmc-smsc911x.c             |   16 +++++-----------
 arch/arm/plat-omap/include/plat/gpmc-smsc911x.h |    1 +
 10 files changed, 16 insertions(+), 11 deletions(-)
arch/arm/mach-omap2/board-cm-t35.c +2 -0
index b5772c1..7c70f56 100644
@@ -69,6 +69,7 @@
 #include <plat/gpmc-smsc911x.h>
 
 static struct omap_smsc911x_platform_data cm_t35_smsc911x_cfg = {
+	.id		= 0,
 	.cs             = CM_T35_SMSC911X_CS,
 	.gpio_irq       = CM_T35_SMSC911X_GPIO,
 	.gpio_reset     = -EINVAL,
@@ -76,6 +77,7 @@ static struct omap_smsc911x_platform_data cm_t35_smsc911x_cfg = {
 };
 
 static struct omap_smsc911x_platform_data sb_t35_smsc911x_cfg = {
+	.id		= 1,
 	.cs             = SB_T35_SMSC911X_CS,
 	.gpio_irq       = SB_T35_SMSC911X_GPIO,
 	.gpio_reset     = -EINVAL,
arch/arm/mach-omap2/board-igep0020.c +1 -0
index 5b9bde7..2bf12fb 100644
@@ -195,6 +195,7 @@ static void __init igep2_flash_init(void) {}
 #include <plat/gpmc-smsc911x.h>
 
 static struct omap_smsc911x_platform_data smsc911x_cfg = {
+	.id		= -1,
 	.cs             = IGEP2_SMSC911X_CS,
 	.gpio_irq       = IGEP2_SMSC911X_GPIO,
 	.gpio_reset     = -EINVAL,
arch/arm/mach-omap2/board-ldp.c +1 -0
index ea9f049..94cfd82 100644
@@ -218,6 +218,7 @@ static struct spi_board_info ldp_spi_board_info[] __initdata = {
 };
 
 static struct omap_smsc911x_platform_data smsc911x_cfg = {
+	.id		= -1,
 	.cs             = LDP_SMSC911X_CS,
 	.gpio_irq       = LDP_SMSC911X_GPIO,
 	.gpio_reset     = -EINVAL,
arch/arm/mach-omap2/board-omap3evm.c +1 -0
index 3fc85c6..fc5c1d8 100644
@@ -104,6 +104,7 @@ static void __init omap3_evm_get_revision(void)
 #include <plat/gpmc-smsc911x.h>
 
 static struct omap_smsc911x_platform_data smsc911x_cfg = {
+	.id		= -1,
 	.cs             = OMAP3EVM_SMSC911X_CS,
 	.gpio_irq       = OMAP3EVM_ETHR_GPIO_IRQ,
 	.gpio_reset     = -EINVAL,
arch/arm/mach-omap2/board-omap3logic.c +1 -0
index a49e6cf..06248e7 100644
@@ -144,6 +144,7 @@ static void __init board_mmc_init(void)
 }
 
 static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = {
+	.id		= -1,
 	.cs             = OMAP3LOGIC_SMSC911X_CS,
 	.gpio_irq       = -EINVAL,
 	.gpio_reset     = -EINVAL,
arch/arm/mach-omap2/board-omap3stalker.c +1 -0
index 848016c..ae4eaf5 100644
@@ -64,6 +64,7 @@
 #define OMAP3STALKER_SMC911X_CS	5
 
 static struct omap_smsc911x_platform_data smsc911x_cfg = {
+	.id		= -1,
 	.cs             = OMAP3STALKER_SMC911X_CS,
 	.gpio_irq       = OMAP3STALKER_ETHR_GPIO_IRQ,
 	.gpio_reset     = -EINVAL,
arch/arm/mach-omap2/board-overo.c +2 -0
index 4016166..165e1fa 100644
@@ -149,6 +149,7 @@ static inline void __init overo_ads7846_init(void) { return; }
 #include <plat/gpmc-smsc911x.h>
 
 static struct omap_smsc911x_platform_data smsc911x_cfg = {
+	.id		= 0,
 	.cs             = OVERO_SMSC911X_CS,
 	.gpio_irq       = OVERO_SMSC911X_GPIO,
 	.gpio_reset     = -EINVAL,
@@ -156,6 +157,7 @@ static struct omap_smsc911x_platform_data smsc911x_cfg = {
 };
 
 static struct omap_smsc911x_platform_data smsc911x2_cfg = {
+	.id		= 1,
 	.cs             = OVERO_SMSC911X2_CS,
 	.gpio_irq       = OVERO_SMSC911X2_GPIO,
 	.gpio_reset     = -EINVAL,
arch/arm/mach-omap2/board-zoom-debugboard.c +1 -0
index 2ee9ab9..d6f6e93 100644
@@ -28,6 +28,7 @@
 #define ZOOM_ETHR_START	DEBUG_BASE
 
 static struct omap_smsc911x_platform_data zoom_smsc911x_cfg = {
+	.id		= -1,
 	.cs             = ZOOM_SMSC911X_CS,
 	.gpio_irq       = ZOOM_SMSC911X_GPIO,
 	.gpio_reset     = -EINVAL,
arch/arm/mach-omap2/gpmc-smsc911x.c +5 -11
index b331f3c..d30293a 100644
@@ -41,16 +41,6 @@ static struct smsc911x_platform_config gpmc_smsc911x_config = {
 	.flags		= SMSC911X_USE_16BIT,
 };
 
-static struct platform_device gpmc_smsc911x_device = {
-	.name		= "smsc911x",
-	.id		= -1,
-	.num_resources	= ARRAY_SIZE(gpmc_smsc911x_resources),
-	.resource	= gpmc_smsc911x_resources,
-	.dev		= {
-		.platform_data = &gpmc_smsc911x_config,
-	},
-};
-
 /*
  * Initialize smsc911x device connected to the GPMC. Note that we
  * assume that pin multiplexing is done in the board-*.c file,
@@ -58,6 +48,7 @@ static struct platform_device gpmc_smsc911x_device = {
  */
 void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 {
+	struct platform_device *pdev;
 	unsigned long cs_mem_base;
 	int ret;
 
@@ -97,7 +88,10 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 	if (gpmc_cfg->flags)
 		gpmc_smsc911x_config.flags = gpmc_cfg->flags;
 
-	if (platform_device_register(&gpmc_smsc911x_device) < 0) {
+	pdev = platform_device_register_resndata(NULL, "smsc911x", gpmc_cfg->id,
+		 gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources),
+		 &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config));
+	if (!pdev) {
 		printk(KERN_ERR "Unable to register smsc911x device\n");
 		gpio_free(gpmc_cfg->gpio_reset);
 		goto free2;
arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +1 -0
index 872de0bf..d3f1579 100644
@@ -14,6 +14,7 @@
 #ifndef __ASM_ARCH_OMAP_GPMC_SMSC911X_H__
 
 struct omap_smsc911x_platform_data {
+	int	id;
 	int	cs;
 	int	gpio_irq;
 	int	gpio_reset;
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 2/2 arm: omap: gpmc-smsc911x: minor style fixes

replace "printk(KERN_ERR" by "pr_err("
and fix needlessly multi-lined #ifdef

---
 arch/arm/mach-omap2/gpmc-smsc911x.c             |   14 +++++++-------
 arch/arm/plat-omap/include/plat/gpmc-smsc911x.h |    3 +--
 2 files changed, 8 insertions(+), 9 deletions(-)
arch/arm/mach-omap2/gpmc-smsc911x.c +7 -7
index d30293a..b45efff 100644
@@ -55,7 +55,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 	gpmc_cfg = board_data;
 
 	if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) {
-		printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
+		pr_err("%s: Failed to request GPMC mem region\n", __func__);
 		return;
 	}
 
@@ -63,8 +63,8 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 	gpmc_smsc911x_resources[0].end = cs_mem_base + 0xff;
 
 	if (gpio_request(gpmc_cfg->gpio_irq, "smsc911x irq") < 0) {
-		printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
-				gpmc_cfg->gpio_irq);
+		pr_err("%s: Failed to request IRQ GPIO%d\n", __func__,
+		       gpmc_cfg->gpio_irq);
 		goto free1;
 	}
 
@@ -74,8 +74,8 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 	if (gpio_is_valid(gpmc_cfg->gpio_reset)) {
 		ret = gpio_request(gpmc_cfg->gpio_reset, "smsc911x reset");
 		if (ret) {
-			printk(KERN_ERR "Failed to request GPIO%d for smsc911x reset\n",
-					gpmc_cfg->gpio_reset);
+			pr_err("%s: Failed to request reset GPIO%d\n", __func__,
+			       gpmc_cfg->gpio_reset);
 			goto free2;
 		}
 
@@ -92,7 +92,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 		 gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources),
 		 &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config));
 	if (!pdev) {
-		printk(KERN_ERR "Unable to register smsc911x device\n");
+		pr_err("%s: Unable to register platform device\n", __func__);
 		gpio_free(gpmc_cfg->gpio_reset);
 		goto free2;
 	}
@@ -104,5 +104,5 @@ free2:
 free1:
 	gpmc_cs_free(gpmc_cfg->cs);
 
-	printk(KERN_ERR "Could not initialize smsc911x\n");
+	pr_err("Could not initialize smsc911x\n");
 }
arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +1 -2
index d3f1579..ea6c9c8 100644
@@ -21,8 +21,7 @@ struct omap_smsc911x_platform_data {
 	u32	flags;
 };
 
-#if defined(CONFIG_SMSC911X) || \
-	defined(CONFIG_SMSC911X_MODULE)
+#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 
 extern void gpmc_smsc911x_init(struct omap_smsc911x_platform_data *d);
 
Signature · 1 line
1.7.3.4
#2 lore raw

PATCH 2/2 arm: omap: gpmc-smsc911x: minor style fixes

arch/arm/mach-omap2/gpmc-smsc911x.c

Quoted 13 lines · Igor Grinberg

replace "printk(KERN_ERR" by "pr_err("
and fix needlessly multi-lined #ifdef

---
?arch/arm/mach-omap2/gpmc-smsc911x.c ? ? ? ? ? ? | ? 14 +++++++------- ?arch/arm/plat-omap/include/plat/gpmc-smsc911x.h | ? ?3 +-- ?2 files changed, 8 insertions(+), 9 deletions(-)

arch/arm/mach-omap2/gpmc-smsc911x.c +0 -0
index d30293a..b45efff 100644

minor suggestion: wont using pr_fmt help to reduce the need to add %s, __func__ for pr_err through out the file?

Regards,
Nishanth Menon

Quoted 69 lines
arch/arm/mach-omap2/gpmc-smsc911x.c +6 -6
@@ -55,7 +55,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ?gpmc_cfg = board_data;
 
 ? ? ? ?if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) {
- ? ? ? ? ? ? ? printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
+ ? ? ? ? ? ? ? pr_err("%s: Failed to request GPMC mem region\n", __func__);
 ? ? ? ? ? ? ? ?return;
 ? ? ? ?}
 
@@ -63,8 +63,8 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ?gpmc_smsc911x_resources[0].end = cs_mem_base + 0xff;
 
 ? ? ? ?if (gpio_request(gpmc_cfg->gpio_irq, "smsc911x irq") < 0) {
- ? ? ? ? ? ? ? printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? gpmc_cfg->gpio_irq);
+ ? ? ? ? ? ? ? pr_err("%s: Failed to request IRQ GPIO%d\n", __func__,
+ ? ? ? ? ? ? ? ? ? ? ?gpmc_cfg->gpio_irq);
 ? ? ? ? ? ? ? ?goto free1;
 ? ? ? ?}
 
@@ -74,8 +74,8 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ?if (gpio_is_valid(gpmc_cfg->gpio_reset)) {
 ? ? ? ? ? ? ? ?ret = gpio_request(gpmc_cfg->gpio_reset, "smsc911x reset");
 ? ? ? ? ? ? ? ?if (ret) {
- ? ? ? ? ? ? ? ? ? ? ? printk(KERN_ERR "Failed to request GPIO%d for smsc911x reset\n",
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? gpmc_cfg->gpio_reset);
+ ? ? ? ? ? ? ? ? ? ? ? pr_err("%s: Failed to request reset GPIO%d\n", __func__,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?gpmc_cfg->gpio_reset);
 ? ? ? ? ? ? ? ? ? ? ? ?goto free2;
 ? ? ? ? ? ? ? ?}
 
@@ -92,7 +92,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ? ? ? ? ? gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources),
 ? ? ? ? ? ? ? ? &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config));
 ? ? ? ?if (!pdev) {
- ? ? ? ? ? ? ? printk(KERN_ERR "Unable to register smsc911x device\n");
+ ? ? ? ? ? ? ? pr_err("%s: Unable to register platform device\n", __func__);
 ? ? ? ? ? ? ? ?gpio_free(gpmc_cfg->gpio_reset);
 ? ? ? ? ? ? ? ?goto free2;
 ? ? ? ?}
@@ -104,5 +104,5 @@ free2:

?free1:
? ? ? ?gpmc_cs_free(gpmc_cfg->cs);

- ? ? ? printk(KERN_ERR "Could not initialize smsc911x\n");
+ ? ? ? pr_err("Could not initialize smsc911x\n"); ?}

arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +1 -3
index d3f1579..ea6c9c8 100644
@@ -21,8 +21,7 @@ struct omap_smsc911x_platform_data {
 ? ? ? ?u32 ? ? flags;
 ?};
 
-#if defined(CONFIG_SMSC911X) || \
- ? ? ? defined(CONFIG_SMSC911X_MODULE)
+#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 
 ?extern void gpmc_smsc911x_init(struct omap_smsc911x_platform_data *d);
 
--

1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html

#3 lore raw

PATCH 2/2 arm: omap: gpmc-smsc911x: minor style fixes

Hi Nishanth,

Quoted 10 lines · Nishanth
Quoted 9 lines · Igor Grinberg

replace "printk(KERN_ERR" by "pr_err("
and fix needlessly multi-lined #ifdef

---
 arch/arm/mach-omap2/gpmc-smsc911x.c             |   14 +++++++-------
 arch/arm/plat-omap/include/plat/gpmc-smsc911x.h |    3 +--
 2 files changed, 8 insertions(+), 9 deletions(-)
Quoted 6 lines

arch/arm/mach-omap2/gpmc-smsc911x.c

Quoted 4 lines
arch/arm/mach-omap2/gpmc-smsc911x.c +0 -0
index d30293a..b45efff 100644

minor suggestion: wont using pr_fmt help to reduce the need to add %s, __func__ for pr_err through out the file?

I don't understand of what "need" are you talking about. I don't know of any need to add "%s, __func__" with pr_fmt... I've added "%s, __func__" as a meter of choice. IMO, it makes it easier to parse the dmesg output. If anyone objects it, I can remove them,
but I think both pr_fmt and __func__ are nice here and way better then "printk(KERN_*" with embedded "smsc911x".

Quoted 69 lines
Quoted 69 lines
arch/arm/mach-omap2/gpmc-smsc911x.c +7 -7
@@ -55,7 +55,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
       gpmc_cfg = board_data;
 
       if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) {
-               printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
+               pr_err("%s: Failed to request GPMC mem region\n", __func__);
               return;
       }
 
@@ -63,8 +63,8 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
       gpmc_smsc911x_resources[0].end = cs_mem_base + 0xff;
 
       if (gpio_request(gpmc_cfg->gpio_irq, "smsc911x irq") < 0) {
-               printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
-                               gpmc_cfg->gpio_irq);
+               pr_err("%s: Failed to request IRQ GPIO%d\n", __func__,
+                      gpmc_cfg->gpio_irq);
               goto free1;
       }
 
@@ -74,8 +74,8 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
       if (gpio_is_valid(gpmc_cfg->gpio_reset)) {
               ret = gpio_request(gpmc_cfg->gpio_reset, "smsc911x reset");
               if (ret) {
-                       printk(KERN_ERR "Failed to request GPIO%d for smsc911x reset\n",
-                                       gpmc_cfg->gpio_reset);
+                       pr_err("%s: Failed to request reset GPIO%d\n", __func__,
+                              gpmc_cfg->gpio_reset);
                       goto free2;
               }
 
@@ -92,7 +92,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
                gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources),
                &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config));
       if (!pdev) {
-               printk(KERN_ERR "Unable to register smsc911x device\n");
+               pr_err("%s: Unable to register platform device\n", __func__);
               gpio_free(gpmc_cfg->gpio_reset);
               goto free2;
       }
@@ -104,5 +104,5 @@ free2:
 free1:
       gpmc_cs_free(gpmc_cfg->cs);
 
-       printk(KERN_ERR "Could not initialize smsc911x\n");
+       pr_err("Could not initialize smsc911x\n");
 }
arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +1 -3
index d3f1579..ea6c9c8 100644
@@ -21,8 +21,7 @@ struct omap_smsc911x_platform_data {
       u32     flags;
 };
 
-#if defined(CONFIG_SMSC911X) || \
-       defined(CONFIG_SMSC911X_MODULE)
+#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 
 extern void gpmc_smsc911x_init(struct omap_smsc911x_platform_data *d);
 
--

1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Regards,
Igor.
#4 lore raw

PATCH 2/2 arm: omap: gpmc-smsc911x: minor style fixes

Quoted 21 lines · Igor Grinberg

Hi Nishanth,

Quoted 10 lines · Nishanth
Quoted 9 lines · Igor Grinberg

replace "printk(KERN_ERR" by "pr_err("
and fix needlessly multi-lined #ifdef

---
?arch/arm/mach-omap2/gpmc-smsc911x.c ? ? ? ? ? ? | ? 14 +++++++------- ?arch/arm/plat-omap/include/plat/gpmc-smsc911x.h | ? ?3 +-- ?2 files changed, 8 insertions(+), 9 deletions(-)

Quoted 6 lines

arch/arm/mach-omap2/gpmc-smsc911x.c

Quoted 4 lines
arch/arm/mach-omap2/gpmc-smsc911x.c +0 -0
index d30293a..b45efff 100644

minor suggestion: wont using pr_fmt help to reduce the need to add %s, __func__ for pr_err through out the file?

Quoted 7 lines

I don't understand of what "need" are you talking about. I don't know of any need to add "%s, __func__" with pr_fmt... I've added "%s, __func__" as a meter of choice. IMO, it makes it easier to parse the dmesg output. If anyone objects it, I can remove them,
but I think both pr_fmt and __func__ are nice here and way better then "printk(KERN_*" with embedded "smsc911x".

Allow me to rephrase.
I like the change of printk->pr_err - thanks for doing it. just suggesting a minor improvement

if you add the following line before the #includes #define pr_fmt(fmt) "%s: " fmt, __func__ then
- printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
- gpmc_cfg->gpio_irq);
+ pr_err("%s: Failed to request IRQ GPIO%d\n", __func__,
+ gpmc_cfg->gpio_irq);
becomes,
- printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
- gpmc_cfg->gpio_irq);
+ pr_err("Failed to request IRQ GPIO%d\n", gpmc_cfg->gpio_irq);

Both give you exactly the output you would like to see (which I personally prefer as well), but the second could be lesser lines of code change ;)

Regards,
Nishanth Menon

Quoted 76 lines
Quoted 62 lines
Quoted 62 lines
arch/arm/mach-omap2/gpmc-smsc911x.c +6 -6
@@ -55,7 +55,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ?gpmc_cfg = board_data;
 
 ? ? ? ?if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) {
- ? ? ? ? ? ? ? printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
+ ? ? ? ? ? ? ? pr_err("%s: Failed to request GPMC mem region\n", __func__);
 ? ? ? ? ? ? ? ?return;
 ? ? ? ?}
 
@@ -63,8 +63,8 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ?gpmc_smsc911x_resources[0].end = cs_mem_base + 0xff;
 
 ? ? ? ?if (gpio_request(gpmc_cfg->gpio_irq, "smsc911x irq") < 0) {
- ? ? ? ? ? ? ? printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? gpmc_cfg->gpio_irq);
+ ? ? ? ? ? ? ? pr_err("%s: Failed to request IRQ GPIO%d\n", __func__,
+ ? ? ? ? ? ? ? ? ? ? ?gpmc_cfg->gpio_irq);
 ? ? ? ? ? ? ? ?goto free1;
 ? ? ? ?}
 
@@ -74,8 +74,8 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ?if (gpio_is_valid(gpmc_cfg->gpio_reset)) {
 ? ? ? ? ? ? ? ?ret = gpio_request(gpmc_cfg->gpio_reset, "smsc911x reset");
 ? ? ? ? ? ? ? ?if (ret) {
- ? ? ? ? ? ? ? ? ? ? ? printk(KERN_ERR "Failed to request GPIO%d for smsc911x reset\n",
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? gpmc_cfg->gpio_reset);
+ ? ? ? ? ? ? ? ? ? ? ? pr_err("%s: Failed to request reset GPIO%d\n", __func__,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?gpmc_cfg->gpio_reset);
 ? ? ? ? ? ? ? ? ? ? ? ?goto free2;
 ? ? ? ? ? ? ? ?}
 
@@ -92,7 +92,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ? ? ? ? ? gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources),
 ? ? ? ? ? ? ? ? &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config));
 ? ? ? ?if (!pdev) {
- ? ? ? ? ? ? ? printk(KERN_ERR "Unable to register smsc911x device\n");
+ ? ? ? ? ? ? ? pr_err("%s: Unable to register platform device\n", __func__);
 ? ? ? ? ? ? ? ?gpio_free(gpmc_cfg->gpio_reset);
 ? ? ? ? ? ? ? ?goto free2;
 ? ? ? ?}
@@ -104,5 +104,5 @@ free2:

?free1:
? ? ? ?gpmc_cs_free(gpmc_cfg->cs);

- ? ? ? printk(KERN_ERR "Could not initialize smsc911x\n");
+ ? ? ? pr_err("Could not initialize smsc911x\n"); ?}

arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +1 -2
index d3f1579..ea6c9c8 100644
@@ -21,8 +21,7 @@ struct omap_smsc911x_platform_data {
 ? ? ? ?u32 ? ? flags;
 ?};
 
-#if defined(CONFIG_SMSC911X) || \
- ? ? ? defined(CONFIG_SMSC911X_MODULE)
+#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 
 ?extern void gpmc_smsc911x_init(struct omap_smsc911x_platform_data *d);
 
Quoted 8 lines
Quoted 8 lines

--
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html

--
Regards,
Igor.

#5 lore raw

PATCH 2/2 arm: omap: gpmc-smsc911x: minor style fixes

Quoted 44 lines · Nishanth
Quoted 20 lines · Igor Grinberg

Hi Nishanth,

Quoted 10 lines · Nishanth
Quoted 9 lines · Igor Grinberg

replace "printk(KERN_ERR" by "pr_err("
and fix needlessly multi-lined #ifdef

---
 arch/arm/mach-omap2/gpmc-smsc911x.c             |   14 +++++++-------
 arch/arm/plat-omap/include/plat/gpmc-smsc911x.h |    3 +--
 2 files changed, 8 insertions(+), 9 deletions(-)
Quoted 6 lines

arch/arm/mach-omap2/gpmc-smsc911x.c

Quoted 4 lines
arch/arm/mach-omap2/gpmc-smsc911x.c +0 -0
index d30293a..b45efff 100644

minor suggestion: wont using pr_fmt help to reduce the need to add %s, __func__ for pr_err through out the file?

Quoted 7 lines

I don't understand of what "need" are you talking about. I don't know of any need to add "%s, __func__" with pr_fmt... I've added "%s, __func__" as a meter of choice. IMO, it makes it easier to parse the dmesg output. If anyone objects it, I can remove them,
but I think both pr_fmt and __func__ are nice here and way better then "printk(KERN_*" with embedded "smsc911x".

Allow me to rephrase.
I like the change of printk->pr_err - thanks for doing it. just suggesting a minor improvement

if you add the following line before the #includes #define pr_fmt(fmt) "%s: " fmt, __func__ then

arch/arm/mach-omap2/gpmc-smsc911x.c +2 -2
-               printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
-                               gpmc_cfg->gpio_irq);
+               pr_err("%s: Failed to request IRQ GPIO%d\n", __func__,
+                      gpmc_cfg->gpio_irq);

becomes,

arch/arm/mach-omap2/gpmc-smsc911x.c +1 -2
-               printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
-                               gpmc_cfg->gpio_irq);
+               pr_err("Failed to request IRQ GPIO%d\n", gpmc_cfg->gpio_irq);
Quoted 3 lines

Both give you exactly the output you would like to see (which I personally prefer as well), but the second could be lesser lines of code change ;)

Ahh, now I understand, that can be useful indeed.
I'll send a v2...

Thanks

Signature · 2 lines
Regards,
Igor.
#6 lore raw

PATCH v2 2/2 arm: omap: gpmc-smsc911x: minor style fixes

replace "printk(KERN_ERR" by "pr_err("
and fix needlessly multi-lined #ifdef

---
v2: added pr_fmt so the pr_*() calls would be cleaner (thanks Nishanth)
Nishanth, this time it does not affect the n-o-l, but it is indeed cleaner

 arch/arm/mach-omap2/gpmc-smsc911x.c             |   14 +++++++-------
 arch/arm/plat-omap/include/plat/gpmc-smsc911x.h |    3 +--
 2 files changed, 8 insertions(+), 9 deletions(-)
arch/arm/mach-omap2/gpmc-smsc911x.c +7 -7
index d30293a..e09374a 100644
@@ -10,6 +10,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#define pr_fmt(fmt) "%s: " fmt, __func__
 
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
@@ -55,7 +56,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 	gpmc_cfg = board_data;
 
 	if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) {
-		printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
+		pr_err("Failed to request GPMC mem region\n");
 		return;
 	}
 
@@ -63,8 +64,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 	gpmc_smsc911x_resources[0].end = cs_mem_base + 0xff;
 
 	if (gpio_request(gpmc_cfg->gpio_irq, "smsc911x irq") < 0) {
-		printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
-				gpmc_cfg->gpio_irq);
+		pr_err("Failed to request IRQ GPIO%d\n", gpmc_cfg->gpio_irq);
 		goto free1;
 	}
 
@@ -74,8 +74,8 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 	if (gpio_is_valid(gpmc_cfg->gpio_reset)) {
 		ret = gpio_request(gpmc_cfg->gpio_reset, "smsc911x reset");
 		if (ret) {
-			printk(KERN_ERR "Failed to request GPIO%d for smsc911x reset\n",
-					gpmc_cfg->gpio_reset);
+			pr_err("Failed to request reset GPIO%d\n",
+			       gpmc_cfg->gpio_reset);
 			goto free2;
 		}
 
@@ -92,7 +92,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 		 gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources),
 		 &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config));
 	if (!pdev) {
-		printk(KERN_ERR "Unable to register smsc911x device\n");
+		pr_err("Unable to register platform device\n");
 		gpio_free(gpmc_cfg->gpio_reset);
 		goto free2;
 	}
@@ -104,5 +104,5 @@ free2:
 free1:
 	gpmc_cs_free(gpmc_cfg->cs);
 
-	printk(KERN_ERR "Could not initialize smsc911x\n");
+	pr_err("Could not initialize smsc911x device\n");
 }
arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +1 -2
index d3f1579..ea6c9c8 100644
@@ -21,8 +21,7 @@ struct omap_smsc911x_platform_data {
 	u32	flags;
 };
 
-#if defined(CONFIG_SMSC911X) || \
-	defined(CONFIG_SMSC911X_MODULE)
+#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 
 extern void gpmc_smsc911x_init(struct omap_smsc911x_platform_data *d);
 
Signature · 1 line
1.7.3.4
#7 lore raw

PATCH v2 2/2 arm: omap: gpmc-smsc911x: minor style fixes

Quoted 5 lines · Igor Grinberg

replace "printk(KERN_ERR" by "pr_err("
and fix needlessly multi-lined #ifdef

Regards,
Nishanth Menon

Quoted 85 lines

---
v2: ? ? added pr_fmt so the pr_*() calls would be cleaner (thanks Nishanth) ? ? ? ?Nishanth, this time it does not affect the n-o-l,
? ? ? ?but it is indeed cleaner

?arch/arm/mach-omap2/gpmc-smsc911x.c ? ? ? ? ? ? | ? 14 +++++++------- ?arch/arm/plat-omap/include/plat/gpmc-smsc911x.h | ? ?3 +-- ?2 files changed, 8 insertions(+), 9 deletions(-)

arch/arm/mach-omap2/gpmc-smsc911x.c +0 -0
index d30293a..e09374a 100644
@@ -10,6 +10,7 @@

?* it under the terms of the GNU General Public License version 2 as ?* published by the Free Software Foundation.
?*/
+#define pr_fmt(fmt) "%s: " fmt, __func__

?#include <linux/kernel.h>
?#include <linux/platform_device.h>

arch/arm/mach-omap2/gpmc-smsc911x.c +5 -6
@@ -55,7 +56,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ?gpmc_cfg = board_data;
 
 ? ? ? ?if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) {
- ? ? ? ? ? ? ? printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
+ ? ? ? ? ? ? ? pr_err("Failed to request GPMC mem region\n");
 ? ? ? ? ? ? ? ?return;
 ? ? ? ?}
 
@@ -63,8 +64,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ?gpmc_smsc911x_resources[0].end = cs_mem_base + 0xff;
 
 ? ? ? ?if (gpio_request(gpmc_cfg->gpio_irq, "smsc911x irq") < 0) {
- ? ? ? ? ? ? ? printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? gpmc_cfg->gpio_irq);
+ ? ? ? ? ? ? ? pr_err("Failed to request IRQ GPIO%d\n", gpmc_cfg->gpio_irq);
 ? ? ? ? ? ? ? ?goto free1;
 ? ? ? ?}
 
@@ -74,8 +74,8 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ?if (gpio_is_valid(gpmc_cfg->gpio_reset)) {
 ? ? ? ? ? ? ? ?ret = gpio_request(gpmc_cfg->gpio_reset, "smsc911x reset");
 ? ? ? ? ? ? ? ?if (ret) {
- ? ? ? ? ? ? ? ? ? ? ? printk(KERN_ERR "Failed to request GPIO%d for smsc911x reset\n",
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? gpmc_cfg->gpio_reset);
+ ? ? ? ? ? ? ? ? ? ? ? pr_err("Failed to request reset GPIO%d\n",
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?gpmc_cfg->gpio_reset);
 ? ? ? ? ? ? ? ? ? ? ? ?goto free2;
 ? ? ? ? ? ? ? ?}
 
@@ -92,7 +92,7 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ? ? ? ? ? gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources),
 ? ? ? ? ? ? ? ? &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config));
 ? ? ? ?if (!pdev) {
- ? ? ? ? ? ? ? printk(KERN_ERR "Unable to register smsc911x device\n");
+ ? ? ? ? ? ? ? pr_err("Unable to register platform device\n");
 ? ? ? ? ? ? ? ?gpio_free(gpmc_cfg->gpio_reset);
 ? ? ? ? ? ? ? ?goto free2;
 ? ? ? ?}
@@ -104,5 +104,5 @@ free2:

?free1:
? ? ? ?gpmc_cs_free(gpmc_cfg->cs);

- ? ? ? printk(KERN_ERR "Could not initialize smsc911x\n");
+ ? ? ? pr_err("Could not initialize smsc911x device\n"); ?}

arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +1 -3
index d3f1579..ea6c9c8 100644
@@ -21,8 +21,7 @@ struct omap_smsc911x_platform_data {
 ? ? ? ?u32 ? ? flags;
 ?};
 
-#if defined(CONFIG_SMSC911X) || \
- ? ? ? defined(CONFIG_SMSC911X_MODULE)
+#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 
 ?extern void gpmc_smsc911x_init(struct omap_smsc911x_platform_data *d);
 
--

1.7.3.4

#9 lore raw

PATCH 1/2 arm: omap: fix bug with multiple smsc911x devices

In reply to Igor Grinberg

Hi Igor,

Quoted 63 lines · Igor Grinberg

kobject (c06a4250): tried to init an initialized object, something is seriously wrong.

introduced by commit 66293989:
(omap: convert boards that use SMSC911x to use gpmc-smsc911x)

fixed by allocating struct platform_device dynamically.

---
This has been boot tested with nfs root on cm-t35, and build tested on all other affected boards.

?arch/arm/mach-omap2/board-cm-t35.c ? ? ? ? ? ? ?| ? ?2 ++
?arch/arm/mach-omap2/board-igep0020.c ? ? ? ? ? ?| ? ?1 +
?arch/arm/mach-omap2/board-ldp.c ? ? ? ? ? ? ? ? | ? ?1 +
?arch/arm/mach-omap2/board-omap3evm.c ? ? ? ? ? ?| ? ?1 +
?arch/arm/mach-omap2/board-omap3logic.c ? ? ? ? ?| ? ?1 +
?arch/arm/mach-omap2/board-omap3stalker.c ? ? ? ?| ? ?1 +
?arch/arm/mach-omap2/board-overo.c ? ? ? ? ? ? ? | ? ?2 ++
?arch/arm/mach-omap2/board-zoom-debugboard.c ? ? | ? ?1 +
?arch/arm/mach-omap2/gpmc-smsc911x.c ? ? ? ? ? ? | ? 16 +++++-----------
?arch/arm/plat-omap/include/plat/gpmc-smsc911x.h | ? ?1 +

?10 files changed, 16 insertions(+), 11 deletions(-)

arch/arm/mach-omap2/board-cm-t35.c +0 -0
index b5772c1..7c70f56 100644
@@ -69,6 +69,7 @@

?#include <plat/gpmc-smsc911x.h>

?static struct omap_smsc911x_platform_data cm_t35_smsc911x_cfg = {
+ ? ? ? .id ? ? ? ? ? ? = 0,
? ? ? ?.cs ? ? ? ? ? ? = CM_T35_SMSC911X_CS,
? ? ? ?.gpio_irq ? ? ? = CM_T35_SMSC911X_GPIO,
? ? ? ?.gpio_reset ? ? = -EINVAL,

arch/arm/mach-omap2/board-cm-t35.c +1 -0
@@ -76,6 +77,7 @@ static struct omap_smsc911x_platform_data cm_t35_smsc911x_cfg = {
 ?};
 
 ?static struct omap_smsc911x_platform_data sb_t35_smsc911x_cfg = {
+ ? ? ? .id ? ? ? ? ? ? = 1,
 ? ? ? ?.cs ? ? ? ? ? ? = SB_T35_SMSC911X_CS,
 ? ? ? ?.gpio_irq ? ? ? = SB_T35_SMSC911X_GPIO,
 ? ? ? ?.gpio_reset ? ? = -EINVAL,
arch/arm/mach-omap2/board-igep0020.c +0 -0
index 5b9bde7..2bf12fb 100644
@@ -195,6 +195,7 @@ static void __init igep2_flash_init(void) {}

?#include <plat/gpmc-smsc911x.h>

?static struct omap_smsc911x_platform_data smsc911x_cfg = {
+ ? ? ? .id ? ? ? ? ? ? = -1,
? ? ? ?.cs ? ? ? ? ? ? = IGEP2_SMSC911X_CS,
? ? ? ?.gpio_irq ? ? ? = IGEP2_SMSC911X_GPIO,
? ? ? ?.gpio_reset ? ? = -EINVAL,

arch/arm/mach-omap2/board-ldp.c +0 -0
index ea9f049..94cfd82 100644

arch/arm/mach-omap2/board-ldp.c static struct spi_board_info ldp_spi_board_info[] __initdata = { · line 221

Quoted 4 lines
arch/arm/mach-omap2/board-ldp.c +1 -0
@@ -218,6 +218,7 @@ static struct spi_board_info ldp_spi_board_info[] __initdata = {
 ?};
 
 ?static struct omap_smsc911x_platform_data smsc911x_cfg = {
+ ? ? ? .id ? ? ? ? ? ? = -1,

I believe you can keep the id field uninitialized, i.e. 0. This applies to other boards with single smsc device as well.

Quoted 127 lines
arch/arm/mach-omap2/board-ldp.c +0 -0
 ? ? ? ?.cs ? ? ? ? ? ? = LDP_SMSC911X_CS,
 ? ? ? ?.gpio_irq ? ? ? = LDP_SMSC911X_GPIO,
 ? ? ? ?.gpio_reset ? ? = -EINVAL,
arch/arm/mach-omap2/board-omap3evm.c +0 -0
index 3fc85c6..fc5c1d8 100644
@@ -104,6 +104,7 @@ static void __init omap3_evm_get_revision(void)

?#include <plat/gpmc-smsc911x.h>

?static struct omap_smsc911x_platform_data smsc911x_cfg = {
+ ? ? ? .id ? ? ? ? ? ? = -1,
? ? ? ?.cs ? ? ? ? ? ? = OMAP3EVM_SMSC911X_CS,
? ? ? ?.gpio_irq ? ? ? = OMAP3EVM_ETHR_GPIO_IRQ,
? ? ? ?.gpio_reset ? ? = -EINVAL,

arch/arm/mach-omap2/board-omap3logic.c +1 -0
index a49e6cf..06248e7 100644
@@ -144,6 +144,7 @@ static void __init board_mmc_init(void)
 ?}
 
 ?static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = {
+ ? ? ? .id ? ? ? ? ? ? = -1,
 ? ? ? ?.cs ? ? ? ? ? ? = OMAP3LOGIC_SMSC911X_CS,
 ? ? ? ?.gpio_irq ? ? ? = -EINVAL,
 ? ? ? ?.gpio_reset ? ? = -EINVAL,
arch/arm/mach-omap2/board-omap3stalker.c +0 -0
index 848016c..ae4eaf5 100644
@@ -64,6 +64,7 @@

?#define OMAP3STALKER_SMC911X_CS ? ? ? ?5

?static struct omap_smsc911x_platform_data smsc911x_cfg = {
+ ? ? ? .id ? ? ? ? ? ? = -1,
? ? ? ?.cs ? ? ? ? ? ? = OMAP3STALKER_SMC911X_CS, ? ? ? ?.gpio_irq ? ? ? = OMAP3STALKER_ETHR_GPIO_IRQ, ? ? ? ?.gpio_reset ? ? = -EINVAL,

arch/arm/mach-omap2/board-overo.c +0 -0
index 4016166..165e1fa 100644
@@ -149,6 +149,7 @@ static inline void __init overo_ads7846_init(void) { return; }

?#include <plat/gpmc-smsc911x.h>

?static struct omap_smsc911x_platform_data smsc911x_cfg = {
+ ? ? ? .id ? ? ? ? ? ? = 0,
? ? ? ?.cs ? ? ? ? ? ? = OVERO_SMSC911X_CS,
? ? ? ?.gpio_irq ? ? ? = OVERO_SMSC911X_GPIO,
? ? ? ?.gpio_reset ? ? = -EINVAL,

arch/arm/mach-omap2/board-overo.c +1 -0
@@ -156,6 +157,7 @@ static struct omap_smsc911x_platform_data smsc911x_cfg = {
 ?};
 
 ?static struct omap_smsc911x_platform_data smsc911x2_cfg = {
+ ? ? ? .id ? ? ? ? ? ? = 1,
 ? ? ? ?.cs ? ? ? ? ? ? = OVERO_SMSC911X2_CS,
 ? ? ? ?.gpio_irq ? ? ? = OVERO_SMSC911X2_GPIO,
 ? ? ? ?.gpio_reset ? ? = -EINVAL,
arch/arm/mach-omap2/board-zoom-debugboard.c +0 -0
index 2ee9ab9..d6f6e93 100644
@@ -28,6 +28,7 @@

?#define ZOOM_ETHR_START ? ? ? ?DEBUG_BASE

?static struct omap_smsc911x_platform_data zoom_smsc911x_cfg = {
+ ? ? ? .id ? ? ? ? ? ? = -1,
? ? ? ?.cs ? ? ? ? ? ? = ZOOM_SMSC911X_CS,
? ? ? ?.gpio_irq ? ? ? = ZOOM_SMSC911X_GPIO,
? ? ? ?.gpio_reset ? ? = -EINVAL,

arch/arm/mach-omap2/gpmc-smsc911x.c +0 -10
index b331f3c..d30293a 100644
@@ -41,16 +41,6 @@ static struct smsc911x_platform_config gpmc_smsc911x_config = {
 ? ? ? ?.flags ? ? ? ? ?= SMSC911X_USE_16BIT,
 ?};
 
-static struct platform_device gpmc_smsc911x_device = {
- ? ? ? .name ? ? ? ? ? = "smsc911x",
- ? ? ? .id ? ? ? ? ? ? = -1,
- ? ? ? .num_resources ?= ARRAY_SIZE(gpmc_smsc911x_resources),
- ? ? ? .resource ? ? ? = gpmc_smsc911x_resources,
- ? ? ? .dev ? ? ? ? ? ?= {
- ? ? ? ? ? ? ? .platform_data = &gpmc_smsc911x_config,
- ? ? ? },
-};
-

?/*
?* Initialize smsc911x device connected to the GPMC. Note that we ?* assume that pin multiplexing is done in the board-*.c file,

arch/arm/mach-omap2/gpmc-smsc911x.c +0 -0
@@ -58,6 +48,7 @@ static struct platform_device gpmc_smsc911x_device = {

?*/
?void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data) ?{
+ ? ? ? struct platform_device *pdev;
? ? ? ?unsigned long cs_mem_base;
? ? ? ?int ret;

arch/arm/mach-omap2/gpmc-smsc911x.c +4 -1
@@ -97,7 +88,10 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 ? ? ? ?if (gpmc_cfg->flags)
 ? ? ? ? ? ? ? ?gpmc_smsc911x_config.flags = gpmc_cfg->flags;
 
- ? ? ? if (platform_device_register(&gpmc_smsc911x_device) < 0) {
+ ? ? ? pdev = platform_device_register_resndata(NULL, "smsc911x", gpmc_cfg->id,
+ ? ? ? ? ? ? ? ?gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources),
+ ? ? ? ? ? ? ? ?&gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config));
+ ? ? ? if (!pdev) {
 ? ? ? ? ? ? ? ?printk(KERN_ERR "Unable to register smsc911x device\n");
 ? ? ? ? ? ? ? ?gpio_free(gpmc_cfg->gpio_reset);
 ? ? ? ? ? ? ? ?goto free2;
arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +0 -0
index 872de0bf..d3f1579 100644
@@ -14,6 +14,7 @@

?#ifndef __ASM_ARCH_OMAP_GPMC_SMSC911X_H__

?struct omap_smsc911x_platform_data {
+ ? ? ? int ? ? id;
? ? ? ?int ? ? cs;
? ? ? ?int ? ? gpio_irq;
? ? ? ?int ? ? gpio_reset;
--
1.7.3.4

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html

--
? ? Sincerely Yours,
? ? ? ? Mike.

#10 lore raw

PATCH v2 1/2 arm: omap: fix bug with multiple smsc911x devices

kobject (c06a4250): tried to init an initialized object, something is seriously wrong.

introduced by commit 66293989:
(omap: convert boards that use SMSC911x to use gpmc-smsc911x)

fixed by allocating struct platform_device dynamically.

---
This has been boot tested with nfs root on cm-t35, and build tested on all other affected boards.

v2: keep the id field uninitialized (0) on boards with
only one smsc911x controller (thanks Mike)

 arch/arm/mach-omap2/board-cm-t35.c              |    2 ++
 arch/arm/mach-omap2/board-overo.c               |    2 ++
 arch/arm/mach-omap2/gpmc-smsc911x.c             |   16 +++++-----------
 arch/arm/plat-omap/include/plat/gpmc-smsc911x.h |    1 +
 4 files changed, 10 insertions(+), 11 deletions(-)
arch/arm/mach-omap2/board-cm-t35.c +2 -0
index b5772c1..7c70f56 100644
@@ -69,6 +69,7 @@
 #include <plat/gpmc-smsc911x.h>
 
 static struct omap_smsc911x_platform_data cm_t35_smsc911x_cfg = {
+	.id		= 0,
 	.cs             = CM_T35_SMSC911X_CS,
 	.gpio_irq       = CM_T35_SMSC911X_GPIO,
 	.gpio_reset     = -EINVAL,
@@ -76,6 +77,7 @@ static struct omap_smsc911x_platform_data cm_t35_smsc911x_cfg = {
 };
 
 static struct omap_smsc911x_platform_data sb_t35_smsc911x_cfg = {
+	.id		= 1,
 	.cs             = SB_T35_SMSC911X_CS,
 	.gpio_irq       = SB_T35_SMSC911X_GPIO,
 	.gpio_reset     = -EINVAL,
arch/arm/mach-omap2/board-overo.c +2 -0
index 4016166..165e1fa 100644
@@ -149,6 +149,7 @@ static inline void __init overo_ads7846_init(void) { return; }
 #include <plat/gpmc-smsc911x.h>
 
 static struct omap_smsc911x_platform_data smsc911x_cfg = {
+	.id		= 0,
 	.cs             = OVERO_SMSC911X_CS,
 	.gpio_irq       = OVERO_SMSC911X_GPIO,
 	.gpio_reset     = -EINVAL,
@@ -156,6 +157,7 @@ static struct omap_smsc911x_platform_data smsc911x_cfg = {
 };
 
 static struct omap_smsc911x_platform_data smsc911x2_cfg = {
+	.id		= 1,
 	.cs             = OVERO_SMSC911X2_CS,
 	.gpio_irq       = OVERO_SMSC911X2_GPIO,
 	.gpio_reset     = -EINVAL,
arch/arm/mach-omap2/gpmc-smsc911x.c +5 -11
index b331f3c..d30293a 100644
@@ -41,16 +41,6 @@ static struct smsc911x_platform_config gpmc_smsc911x_config = {
 	.flags		= SMSC911X_USE_16BIT,
 };
 
-static struct platform_device gpmc_smsc911x_device = {
-	.name		= "smsc911x",
-	.id		= -1,
-	.num_resources	= ARRAY_SIZE(gpmc_smsc911x_resources),
-	.resource	= gpmc_smsc911x_resources,
-	.dev		= {
-		.platform_data = &gpmc_smsc911x_config,
-	},
-};
-
 /*
  * Initialize smsc911x device connected to the GPMC. Note that we
  * assume that pin multiplexing is done in the board-*.c file,
@@ -58,6 +48,7 @@ static struct platform_device gpmc_smsc911x_device = {
  */
 void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 {
+	struct platform_device *pdev;
 	unsigned long cs_mem_base;
 	int ret;
 
@@ -97,7 +88,10 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 	if (gpmc_cfg->flags)
 		gpmc_smsc911x_config.flags = gpmc_cfg->flags;
 
-	if (platform_device_register(&gpmc_smsc911x_device) < 0) {
+	pdev = platform_device_register_resndata(NULL, "smsc911x", gpmc_cfg->id,
+		 gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources),
+		 &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config));
+	if (!pdev) {
 		printk(KERN_ERR "Unable to register smsc911x device\n");
 		gpio_free(gpmc_cfg->gpio_reset);
 		goto free2;
arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +1 -0
index 872de0bf..d3f1579 100644
@@ -14,6 +14,7 @@
 #ifndef __ASM_ARCH_OMAP_GPMC_SMSC911X_H__
 
 struct omap_smsc911x_platform_data {
+	int	id;
 	int	cs;
 	int	gpio_irq;
 	int	gpio_reset;
Signature · 1 line
1.7.3.4
#11 lore raw

PATCH v2 1/2 arm: omap: fix bug with multiple smsc911x devices

ping!

Tony, there are already people who need that bug fix.

Quoted 116 lines · Igor Grinberg

kobject (c06a4250): tried to init an initialized object, something is seriously wrong.

introduced by commit 66293989:
(omap: convert boards that use SMSC911x to use gpmc-smsc911x)

fixed by allocating struct platform_device dynamically.

---
This has been boot tested with nfs root on cm-t35, and build tested on all other affected boards.

v2: keep the id field uninitialized (0) on boards with
only one smsc911x controller (thanks Mike)

 arch/arm/mach-omap2/board-cm-t35.c              |    2 ++
 arch/arm/mach-omap2/board-overo.c               |    2 ++
 arch/arm/mach-omap2/gpmc-smsc911x.c             |   16 +++++-----------
 arch/arm/plat-omap/include/plat/gpmc-smsc911x.h |    1 +
 4 files changed, 10 insertions(+), 11 deletions(-)
arch/arm/mach-omap2/board-cm-t35.c +2 -0
index b5772c1..7c70f56 100644
@@ -69,6 +69,7 @@
 #include <plat/gpmc-smsc911x.h>
 
 static struct omap_smsc911x_platform_data cm_t35_smsc911x_cfg = {
+	.id		= 0,
 	.cs             = CM_T35_SMSC911X_CS,
 	.gpio_irq       = CM_T35_SMSC911X_GPIO,
 	.gpio_reset     = -EINVAL,
@@ -76,6 +77,7 @@ static struct omap_smsc911x_platform_data cm_t35_smsc911x_cfg = {
 };
 
 static struct omap_smsc911x_platform_data sb_t35_smsc911x_cfg = {
+	.id		= 1,
 	.cs             = SB_T35_SMSC911X_CS,
 	.gpio_irq       = SB_T35_SMSC911X_GPIO,
 	.gpio_reset     = -EINVAL,
arch/arm/mach-omap2/board-overo.c +2 -0
index 4016166..165e1fa 100644
@@ -149,6 +149,7 @@ static inline void __init overo_ads7846_init(void) { return; }
 #include <plat/gpmc-smsc911x.h>
 
 static struct omap_smsc911x_platform_data smsc911x_cfg = {
+	.id		= 0,
 	.cs             = OVERO_SMSC911X_CS,
 	.gpio_irq       = OVERO_SMSC911X_GPIO,
 	.gpio_reset     = -EINVAL,
@@ -156,6 +157,7 @@ static struct omap_smsc911x_platform_data smsc911x_cfg = {
 };
 
 static struct omap_smsc911x_platform_data smsc911x2_cfg = {
+	.id		= 1,
 	.cs             = OVERO_SMSC911X2_CS,
 	.gpio_irq       = OVERO_SMSC911X2_GPIO,
 	.gpio_reset     = -EINVAL,
arch/arm/mach-omap2/gpmc-smsc911x.c +5 -11
index b331f3c..d30293a 100644
@@ -41,16 +41,6 @@ static struct smsc911x_platform_config gpmc_smsc911x_config = {
 	.flags		= SMSC911X_USE_16BIT,
 };
 
-static struct platform_device gpmc_smsc911x_device = {
-	.name		= "smsc911x",
-	.id		= -1,
-	.num_resources	= ARRAY_SIZE(gpmc_smsc911x_resources),
-	.resource	= gpmc_smsc911x_resources,
-	.dev		= {
-		.platform_data = &gpmc_smsc911x_config,
-	},
-};
-
 /*
  * Initialize smsc911x device connected to the GPMC. Note that we
  * assume that pin multiplexing is done in the board-*.c file,
@@ -58,6 +48,7 @@ static struct platform_device gpmc_smsc911x_device = {
  */
 void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 {
+	struct platform_device *pdev;
 	unsigned long cs_mem_base;
 	int ret;
 
@@ -97,7 +88,10 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 	if (gpmc_cfg->flags)
 		gpmc_smsc911x_config.flags = gpmc_cfg->flags;
 
-	if (platform_device_register(&gpmc_smsc911x_device) < 0) {
+	pdev = platform_device_register_resndata(NULL, "smsc911x", gpmc_cfg->id,
+		 gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources),
+		 &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config));
+	if (!pdev) {
 		printk(KERN_ERR "Unable to register smsc911x device\n");
 		gpio_free(gpmc_cfg->gpio_reset);
 		goto free2;
arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +1 -0
index 872de0bf..d3f1579 100644
@@ -14,6 +14,7 @@
 #ifndef __ASM_ARCH_OMAP_GPMC_SMSC911X_H__
 
 struct omap_smsc911x_platform_data {
+	int	id;
 	int	cs;
 	int	gpio_irq;
 	int	gpio_reset;
Signature · 2 lines
Regards,
Igor.
maintainer
#12 lore raw

PATCH v2 1/2 arm: omap: fix bug with multiple smsc911x devices

Quoted 8 lines · Igor Grinberg
Quoted 8 lines

kobject (c06a4250): tried to init an initialized object, something is seriously wrong.

introduced by commit 66293989:
(omap: convert boards that use SMSC911x to use gpmc-smsc911x)

fixed by allocating struct platform_device dynamically.

Thanks, I'll merge this into Mike's original patch in devel-cleanup branch for the next merge window.

Updated patch below.

Regards,

Tony

From: Mike Rapoport <[email protected]>
Date: Sat, 16 Apr 2011 22:29:30 +0000
Subject: [PATCH] omap: convert boards that use SMSC911x to use gpmc-smsc911x

Convert boards that use SMSC911x to use gpmc-smsc911x. Also allocate struct platform_device dynamically.

[tony at atomide.com: folded in a fix from Igor Grindberg]
arch/arm/mach-omap2/board-cm-t35.c +13 -71
index 02a12b4..7c70f56 100644
@@ -66,86 +66,28 @@
 
 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 #include <linux/smsc911x.h>
+#include <plat/gpmc-smsc911x.h>
 
-static struct smsc911x_platform_config cm_t35_smsc911x_config = {
-	.irq_polarity	= SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
-	.irq_type	= SMSC911X_IRQ_TYPE_OPEN_DRAIN,
-	.flags		= SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
-	.phy_interface	= PHY_INTERFACE_MODE_MII,
-};
-
-static struct resource cm_t35_smsc911x_resources[] = {
-	{
-		.flags	= IORESOURCE_MEM,
-	},
-	{
-		.start	= OMAP_GPIO_IRQ(CM_T35_SMSC911X_GPIO),
-		.end	= OMAP_GPIO_IRQ(CM_T35_SMSC911X_GPIO),
-		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
-	},
-};
-
-static struct platform_device cm_t35_smsc911x_device = {
-	.name		= "smsc911x",
+static struct omap_smsc911x_platform_data cm_t35_smsc911x_cfg = {
 	.id		= 0,
-	.num_resources	= ARRAY_SIZE(cm_t35_smsc911x_resources),
-	.resource	= cm_t35_smsc911x_resources,
-	.dev		= {
-		.platform_data = &cm_t35_smsc911x_config,
-	},
-};
-
-static struct resource sb_t35_smsc911x_resources[] = {
-	{
-		.flags	= IORESOURCE_MEM,
-	},
-	{
-		.start	= OMAP_GPIO_IRQ(SB_T35_SMSC911X_GPIO),
-		.end	= OMAP_GPIO_IRQ(SB_T35_SMSC911X_GPIO),
-		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
-	},
+	.cs             = CM_T35_SMSC911X_CS,
+	.gpio_irq       = CM_T35_SMSC911X_GPIO,
+	.gpio_reset     = -EINVAL,
+	.flags		= SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
 };
 
-static struct platform_device sb_t35_smsc911x_device = {
-	.name		= "smsc911x",
+static struct omap_smsc911x_platform_data sb_t35_smsc911x_cfg = {
 	.id		= 1,
-	.num_resources	= ARRAY_SIZE(sb_t35_smsc911x_resources),
-	.resource	= sb_t35_smsc911x_resources,
-	.dev		= {
-		.platform_data = &cm_t35_smsc911x_config,
-	},
+	.cs             = SB_T35_SMSC911X_CS,
+	.gpio_irq       = SB_T35_SMSC911X_GPIO,
+	.gpio_reset     = -EINVAL,
+	.flags		= SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
 };
 
-static void __init cm_t35_init_smsc911x(struct platform_device *dev,
-					int cs, int irq_gpio)
-{
-	unsigned long cs_mem_base;
-
-	if (gpmc_cs_request(cs, SZ_16M, &cs_mem_base) < 0) {
-		pr_err("CM-T35: Failed request for GPMC mem for smsc911x\n");
-		return;
-	}
-
-	dev->resource[0].start = cs_mem_base + 0x0;
-	dev->resource[0].end   = cs_mem_base + 0xff;
-
-	if ((gpio_request(irq_gpio, "ETH IRQ") == 0) &&
-	    (gpio_direction_input(irq_gpio) == 0)) {
-		gpio_export(irq_gpio, 0);
-	} else {
-		pr_err("CM-T35: could not obtain gpio for SMSC911X IRQ\n");
-		return;
-	}
-
-	platform_device_register(dev);
-}
-
 static void __init cm_t35_init_ethernet(void)
 {
-	cm_t35_init_smsc911x(&cm_t35_smsc911x_device,
-			     CM_T35_SMSC911X_CS, CM_T35_SMSC911X_GPIO);
-	cm_t35_init_smsc911x(&sb_t35_smsc911x_device,
-			     SB_T35_SMSC911X_CS, SB_T35_SMSC911X_GPIO);
+	gpmc_smsc911x_init(&cm_t35_smsc911x_cfg);
+	gpmc_smsc911x_init(&sb_t35_smsc911x_cfg);
 }
 #else
 static inline void __init cm_t35_init_ethernet(void) { return; }
arch/arm/mach-omap2/board-igep0020.c +7 -46

64 lines not on this page · raw message

arch/arm/mach-omap2/board-ldp.c +9 -56

91 lines not on this page · raw message

arch/arm/mach-omap2/board-omap3evm.c +11 -60

93 lines not on this page · raw message

arch/arm/mach-omap2/board-omap3stalker.c +7 -41

73 lines not on this page · raw message

arch/arm/mach-omap2/board-overo.c +14 -92

120 lines not on this page · raw message

arch/arm/mach-omap2/board-zoom-debugboard.c +6 -50

79 lines not on this page · raw message

arch/arm/mach-omap2/gpmc-smsc911x.c +5 -11
index b331f3c..d30293a 100644
@@ -41,16 +41,6 @@ static struct smsc911x_platform_config gpmc_smsc911x_config = {
 	.flags		= SMSC911X_USE_16BIT,
 };
 
-static struct platform_device gpmc_smsc911x_device = {
-	.name		= "smsc911x",
-	.id		= -1,
-	.num_resources	= ARRAY_SIZE(gpmc_smsc911x_resources),
-	.resource	= gpmc_smsc911x_resources,
-	.dev		= {
-		.platform_data = &gpmc_smsc911x_config,
-	},
-};
-
 /*
  * Initialize smsc911x device connected to the GPMC. Note that we
  * assume that pin multiplexing is done in the board-*.c file,
@@ -58,6 +48,7 @@ static struct platform_device gpmc_smsc911x_device = {
  */
 void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 {
+	struct platform_device *pdev;
 	unsigned long cs_mem_base;
 	int ret;
 
@@ -97,7 +88,10 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
 	if (gpmc_cfg->flags)
 		gpmc_smsc911x_config.flags = gpmc_cfg->flags;
 
-	if (platform_device_register(&gpmc_smsc911x_device) < 0) {
+	pdev = platform_device_register_resndata(NULL, "smsc911x", gpmc_cfg->id,
+		 gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources),
+		 &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config));
+	if (!pdev) {
 		printk(KERN_ERR "Unable to register smsc911x device\n");
 		gpio_free(gpmc_cfg->gpio_reset);
 		goto free2;
arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +1 -0
index 872de0b..d3f1579 100644
@@ -14,6 +14,7 @@
 #ifndef __ASM_ARCH_OMAP_GPMC_SMSC911X_H__
 
 struct omap_smsc911x_platform_data {
+	int	id;
 	int	cs;
 	int	gpio_irq;
 	int	gpio_reset;