Re: [PATCH v2 1/2] arm: omap: fix bug with multiple smsc911x devices
ping! Tony, there are already people who need that bug fix. On 04/24/11 11:27, Igor Grinberg wrote: 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. Signed-off-by: Igor Grinberg grinb...@compulab.co.il --- 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(-) diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c index b5772c1..7c70f56 100644 --- a/arch/arm/mach-omap2/board-cm-t35.c +++ b/arch/arm/mach-omap2/board-cm-t35.c @@ -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, diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c index 4016166..165e1fa 100644 --- a/arch/arm/mach-omap2/board-overo.c +++ b/arch/arm/mach-omap2/board-overo.c @@ -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, diff --git a/arch/arm/mach-omap2/gpmc-smsc911x.c b/arch/arm/mach-omap2/gpmc-smsc911x.c index b331f3c..d30293a 100644 --- a/arch/arm/mach-omap2/gpmc-smsc911x.c +++ b/arch/arm/mach-omap2/gpmc-smsc911x.c @@ -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; diff --git a/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h b/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h index 872de0bf..d3f1579 100644 --- a/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +++ b/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h @@ -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; -- Regards, Igor. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/2] arm: omap: fix bug with multiple smsc911x devices
* Igor Grinberg grinb...@compulab.co.il [110502 23:23]: 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 m...@compulab.co.il Date: Sat, 16 Apr 2011 22:29:30 + 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. Signed-off-by: Mike Rapoport m...@compulab.co.il Signed-off-by: Igor Grinberg grinb...@compulab.co.il [t...@atomide.com: folded in a fix from Igor Grindberg] Signed-off-by: Tony Lindgren t...@atomide.com diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c index 02a12b4..7c70f56 100644 --- a/arch/arm/mach-omap2/board-cm-t35.c +++ b/arch/arm/mach-omap2/board-cm-t35.c @@ -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; } diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c index 34cf982..5b9bde7 100644 --- a/arch/arm/mach-omap2/board-igep0020.c +++ b/arch/arm/mach-omap2/board-igep0020.c @@ -192,57 +192,18 @@ static void __init igep2_flash_init(void) {}
[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. Signed-off-by: Igor Grinberg grinb...@compulab.co.il --- 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(-) diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c index b5772c1..7c70f56 100644 --- a/arch/arm/mach-omap2/board-cm-t35.c +++ b/arch/arm/mach-omap2/board-cm-t35.c @@ -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, diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c index 4016166..165e1fa 100644 --- a/arch/arm/mach-omap2/board-overo.c +++ b/arch/arm/mach-omap2/board-overo.c @@ -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, diff --git a/arch/arm/mach-omap2/gpmc-smsc911x.c b/arch/arm/mach-omap2/gpmc-smsc911x.c index b331f3c..d30293a 100644 --- a/arch/arm/mach-omap2/gpmc-smsc911x.c +++ b/arch/arm/mach-omap2/gpmc-smsc911x.c @@ -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; diff --git a/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h b/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h index 872de0bf..d3f1579 100644 --- a/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h +++ b/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h @@ -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 -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html