linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Samsung device updates
@ 2010-05-28  6:19 Ben Dooks
  2010-05-28  6:19 ` [PATCH 1/9] ARM: SAMSUNG: Default s3c_device_i2c1 Ben Dooks
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Ben Dooks @ 2010-05-28  6:19 UTC (permalink / raw)
  To: linux-arm-kernel

Cleanups of the i2c device system, and helper code for setting platform
data.

Note, not run-tested yet, only buildtested across all defconfigs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/9] ARM: SAMSUNG: Default s3c_device_i2c1
  2010-05-28  6:19 Samsung device updates Ben Dooks
@ 2010-05-28  6:19 ` Ben Dooks
  2010-05-28  6:19 ` [PATCH 2/9] ARM: SAMSUNG: Remove s3c_i2c1_setname() calls for s3c2440-i2c Ben Dooks
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2010-05-28  6:19 UTC (permalink / raw)
  To: linux-arm-kernel

There are no current SoCs where i2c1 is anything other than an s3c2440-i2c
implementation, so change the device's name to be s3c2440-i2c so we can
go and eliminate the calls in the cpu-init which set the name.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
 arch/arm/plat-samsung/dev-i2c1.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-samsung/dev-i2c1.c b/arch/arm/plat-samsung/dev-i2c1.c
index 858ee2a..f97905f 100644
--- a/arch/arm/plat-samsung/dev-i2c1.c
+++ b/arch/arm/plat-samsung/dev-i2c1.c
@@ -38,7 +38,8 @@ static struct resource s3c_i2c_resource[] = {
 };
 
 struct platform_device s3c_device_i2c1 = {
-	.name		  = "s3c2410-i2c",
+	/* default to s3c2440-i2c as no SoC with >1 I2C is s3c2410 style */
+	.name		  = "s3c2440-i2c",
 	.id		  = 1,
 	.num_resources	  = ARRAY_SIZE(s3c_i2c_resource),
 	.resource	  = s3c_i2c_resource,
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/9] ARM: SAMSUNG: Remove s3c_i2c1_setname() calls for s3c2440-i2c
  2010-05-28  6:19 Samsung device updates Ben Dooks
  2010-05-28  6:19 ` [PATCH 1/9] ARM: SAMSUNG: Default s3c_device_i2c1 Ben Dooks
@ 2010-05-28  6:19 ` Ben Dooks
  2010-05-28  6:19 ` [PATCH 3/9] ARM: SAMSUNG: Default s3c_device_i2c2 to s3c2440-i2c Ben Dooks
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2010-05-28  6:19 UTC (permalink / raw)
  To: linux-arm-kernel

Now we've defaulted the s3c_device_i2c1's name to s3c2440-i2c, remove
all the s3c_i2c1_setname("s3c2440-i2c") as they are no longer needed.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
 arch/arm/mach-s3c2416/s3c2416.c |    1 -
 arch/arm/mach-s3c64xx/s3c6410.c |    1 -
 arch/arm/mach-s5pc100/cpu.c     |    1 -
 arch/arm/mach-s5pv210/cpu.c     |    1 -
 4 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-s3c2416/s3c2416.c b/arch/arm/mach-s3c2416/s3c2416.c
index 35dabcc..4213f79 100644
--- a/arch/arm/mach-s3c2416/s3c2416.c
+++ b/arch/arm/mach-s3c2416/s3c2416.c
@@ -88,7 +88,6 @@ int __init s3c2416_init(void)
 
 	/* the i2c devices are directly compatible with s3c2440 */
 	s3c_i2c0_setname("s3c2440-i2c");
-	s3c_i2c1_setname("s3c2440-i2c");
 
 	s3c_device_fb.name = "s3c2443-fb";
 
diff --git a/arch/arm/mach-s3c64xx/s3c6410.c b/arch/arm/mach-s3c64xx/s3c6410.c
index 014401c..b5fc100 100644
--- a/arch/arm/mach-s3c64xx/s3c6410.c
+++ b/arch/arm/mach-s3c64xx/s3c6410.c
@@ -52,7 +52,6 @@ void __init s3c6410_map_io(void)
 
 	/* the i2c devices are directly compatible with s3c2440 */
 	s3c_i2c0_setname("s3c2440-i2c");
-	s3c_i2c1_setname("s3c2440-i2c");
 
 	s3c_device_adc.name	= "s3c64xx-adc";
 	s3c_device_nand.name = "s3c6400-nand";
diff --git a/arch/arm/mach-s5pc100/cpu.c b/arch/arm/mach-s5pc100/cpu.c
index 7b5bdbc..f020aeb 100644
--- a/arch/arm/mach-s5pc100/cpu.c
+++ b/arch/arm/mach-s5pc100/cpu.c
@@ -89,7 +89,6 @@ void __init s5pc100_map_io(void)
 
 	/* the i2c devices are directly compatible with s3c2440 */
 	s3c_i2c0_setname("s3c2440-i2c");
-	s3c_i2c1_setname("s3c2440-i2c");
 
 	s3c_onenand_setname("s5pc100-onenand");
 }
diff --git a/arch/arm/mach-s5pv210/cpu.c b/arch/arm/mach-s5pv210/cpu.c
index 411a4a9..987fe1d 100644
--- a/arch/arm/mach-s5pv210/cpu.c
+++ b/arch/arm/mach-s5pv210/cpu.c
@@ -89,7 +89,6 @@ void __init s5pv210_map_io(void)
 
 	/* the i2c devices are directly compatible with s3c2440 */
 	s3c_i2c0_setname("s3c2440-i2c");
-	s3c_i2c1_setname("s3c2440-i2c");
 	s3c_i2c2_setname("s3c2440-i2c");
 }
 
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/9] ARM: SAMSUNG: Default s3c_device_i2c2 to s3c2440-i2c
  2010-05-28  6:19 Samsung device updates Ben Dooks
  2010-05-28  6:19 ` [PATCH 1/9] ARM: SAMSUNG: Default s3c_device_i2c1 Ben Dooks
  2010-05-28  6:19 ` [PATCH 2/9] ARM: SAMSUNG: Remove s3c_i2c1_setname() calls for s3c2440-i2c Ben Dooks
@ 2010-05-28  6:19 ` Ben Dooks
  2010-05-28  6:19 ` [PATCH 4/9] ARM: SAMSUNG: Default s3c_device_i2c0 " Ben Dooks
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2010-05-28  6:19 UTC (permalink / raw)
  To: linux-arm-kernel

There are no current SoCs where i2c2 is anything other than a s3c2440-i2c
implementation (see also e4c5cb3796155eb4f15f7f0b1b7ea705f87743a7) so
change the device's name to s3c2440-i2c by default so we can eliminate
the calls that set the name.

Also remove the singler user of this, the s5pv210.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
 arch/arm/mach-s5pv210/cpu.c      |    1 -
 arch/arm/plat-samsung/dev-i2c2.c |    3 ++-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-s5pv210/cpu.c b/arch/arm/mach-s5pv210/cpu.c
index 987fe1d..8a64ef3 100644
--- a/arch/arm/mach-s5pv210/cpu.c
+++ b/arch/arm/mach-s5pv210/cpu.c
@@ -89,7 +89,6 @@ void __init s5pv210_map_io(void)
 
 	/* the i2c devices are directly compatible with s3c2440 */
 	s3c_i2c0_setname("s3c2440-i2c");
-	s3c_i2c2_setname("s3c2440-i2c");
 }
 
 void __init s5pv210_init_clocks(int xtal)
diff --git a/arch/arm/plat-samsung/dev-i2c2.c b/arch/arm/plat-samsung/dev-i2c2.c
index 07036de..ab2b3d5 100644
--- a/arch/arm/plat-samsung/dev-i2c2.c
+++ b/arch/arm/plat-samsung/dev-i2c2.c
@@ -39,7 +39,8 @@ static struct resource s3c_i2c_resource[] = {
 };
 
 struct platform_device s3c_device_i2c2 = {
-	.name		  = "s3c2410-i2c",
+	/* default to s3c2440-i2c as no SoC with >1 I2C is s3c2410 style */
+	.name		  = "s3c2440-i2c",
 	.id		  = 2,
 	.num_resources	  = ARRAY_SIZE(s3c_i2c_resource),
 	.resource	  = s3c_i2c_resource,
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/9] ARM: SAMSUNG: Default s3c_device_i2c0 to s3c2440-i2c
  2010-05-28  6:19 Samsung device updates Ben Dooks
                   ` (2 preceding siblings ...)
  2010-05-28  6:19 ` [PATCH 3/9] ARM: SAMSUNG: Default s3c_device_i2c2 to s3c2440-i2c Ben Dooks
@ 2010-05-28  6:19 ` Ben Dooks
  2010-05-28  6:19 ` [PATCH 5/9] ARM: SAMSUNG: Eliminate s3c2440-i2c renames Ben Dooks
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2010-05-28  6:19 UTC (permalink / raw)
  To: linux-arm-kernel

The bulk of the SoCs implement the s3c2440-i2c variant of this
block, so change the default name to s3c2440-i2c and rename the
cases where it is s3c2410.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
 arch/arm/mach-s3c2410/s3c2410.c  |    3 +++
 arch/arm/mach-s3c2412/s3c2412.c  |    3 +++
 arch/arm/plat-samsung/dev-i2c0.c |    3 ++-
 3 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-s3c2410/s3c2410.c b/arch/arm/mach-s3c2410/s3c2410.c
index adc90a3..a4f23e7 100644
--- a/arch/arm/mach-s3c2410/s3c2410.c
+++ b/arch/arm/mach-s3c2410/s3c2410.c
@@ -40,6 +40,7 @@
 #include <plat/devs.h>
 #include <plat/clock.h>
 #include <plat/pll.h>
+#include <plat/iic-core.h>
 
 #include <plat/gpio-core.h>
 #include <plat/gpio-cfg.h>
@@ -70,6 +71,8 @@ void __init s3c2410_init_uarts(struct s3c2410_uartcfg *cfg, int no)
 
 void __init s3c2410_map_io(void)
 {
+	s3c_i2c0_setname("s3c2410-i2c");
+
 	s3c24xx_gpiocfg_default.set_pull = s3c_gpio_setpull_1up;
 	s3c24xx_gpiocfg_default.get_pull = s3c_gpio_getpull_1up;
 
diff --git a/arch/arm/mach-s3c2412/s3c2412.c b/arch/arm/mach-s3c2412/s3c2412.c
index bef39f7..d16d72b 100644
--- a/arch/arm/mach-s3c2412/s3c2412.c
+++ b/arch/arm/mach-s3c2412/s3c2412.c
@@ -46,6 +46,7 @@
 #include <mach/regs-s3c2412.h>
 
 #include <plat/s3c2412.h>
+#include <plat/iic-core.h>
 #include <plat/cpu.h>
 #include <plat/devs.h>
 #include <plat/clock.h>
@@ -94,6 +95,8 @@ void __init s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no)
 	s3c_device_lcd.name  = "s3c2412-lcd";
 	s3c_device_nand.name = "s3c2412-nand";
 
+	s3c_i2c0_setname("s3c2410-i2c");
+
 	/* alter IRQ of SDI controller */
 
 	s3c_device_sdi.resource[1].start = IRQ_S3C2412_SDI;
diff --git a/arch/arm/plat-samsung/dev-i2c0.c b/arch/arm/plat-samsung/dev-i2c0.c
index 3a601c1..1ec1ef9 100644
--- a/arch/arm/plat-samsung/dev-i2c0.c
+++ b/arch/arm/plat-samsung/dev-i2c0.c
@@ -38,7 +38,8 @@ static struct resource s3c_i2c_resource[] = {
 };
 
 struct platform_device s3c_device_i2c0 = {
-	.name		  = "s3c2410-i2c",
+	/* default to s3c2440-i2c, most common implementation */
+	.name		  = "s3c2440-i2c",
 #ifdef CONFIG_S3C_DEV_I2C1
 	.id		  = 0,
 #else
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/9] ARM: SAMSUNG: Eliminate s3c2440-i2c renames
  2010-05-28  6:19 Samsung device updates Ben Dooks
                   ` (3 preceding siblings ...)
  2010-05-28  6:19 ` [PATCH 4/9] ARM: SAMSUNG: Default s3c_device_i2c0 " Ben Dooks
@ 2010-05-28  6:19 ` Ben Dooks
  2010-05-28  6:19 ` [PATCH 6/9] ARM: SAMSUNG: Add helper to clone and set platform data Ben Dooks
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2010-05-28  6:19 UTC (permalink / raw)
  To: linux-arm-kernel

Commit 0445af6624016110d1b448e0089261548ba29ee3 set the default
name to s3c2440-i2c, so we no longer need to do anything about
renaming it. Remove all the call sites and the header that was
included to get it.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
 arch/arm/mach-s3c2412/s3c2412.c |    2 +-
 arch/arm/mach-s3c2416/s3c2416.c |    5 -----
 arch/arm/mach-s3c64xx/s3c6400.c |    4 ----
 arch/arm/mach-s3c64xx/s3c6410.c |    4 ----
 arch/arm/mach-s5pc100/cpu.c     |    4 ----
 arch/arm/mach-s5pv210/cpu.c     |    4 ----
 6 files changed, 1 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-s3c2412/s3c2412.c b/arch/arm/mach-s3c2412/s3c2412.c
index d16d72b..5a76774 100644
--- a/arch/arm/mach-s3c2412/s3c2412.c
+++ b/arch/arm/mach-s3c2412/s3c2412.c
@@ -46,9 +46,9 @@
 #include <mach/regs-s3c2412.h>
 
 #include <plat/s3c2412.h>
-#include <plat/iic-core.h>
 #include <plat/cpu.h>
 #include <plat/devs.h>
+#include <plat/iic-core.h>
 #include <plat/clock.h>
 #include <plat/pm.h>
 #include <plat/pll.h>
diff --git a/arch/arm/mach-s3c2416/s3c2416.c b/arch/arm/mach-s3c2416/s3c2416.c
index 4213f79..6e41cf5 100644
--- a/arch/arm/mach-s3c2416/s3c2416.c
+++ b/arch/arm/mach-s3c2416/s3c2416.c
@@ -54,8 +54,6 @@
 #include <plat/devs.h>
 #include <plat/cpu.h>
 
-#include <plat/iic-core.h>
-
 static struct map_desc s3c2416_iodesc[] __initdata = {
 	IODESC_ENT(WATCHDOG),
 	IODESC_ENT(CLKPWR),
@@ -86,9 +84,6 @@ int __init s3c2416_init(void)
 	s3c_device_wdt.resource[1].start = IRQ_S3C2443_WDT;
 	s3c_device_wdt.resource[1].end   = IRQ_S3C2443_WDT;
 
-	/* the i2c devices are directly compatible with s3c2440 */
-	s3c_i2c0_setname("s3c2440-i2c");
-
 	s3c_device_fb.name = "s3c2443-fb";
 
 	return sysdev_register(&s3c2416_sysdev);
diff --git a/arch/arm/mach-s3c64xx/s3c6400.c b/arch/arm/mach-s3c64xx/s3c6400.c
index 5e93fe3..9e056b4 100644
--- a/arch/arm/mach-s3c64xx/s3c6400.c
+++ b/arch/arm/mach-s3c64xx/s3c6400.c
@@ -36,7 +36,6 @@
 #include <plat/devs.h>
 #include <plat/clock.h>
 #include <plat/sdhci.h>
-#include <plat/iic-core.h>
 #include <plat/onenand-core.h>
 #include <mach/s3c6400.h>
 
@@ -48,9 +47,6 @@ void __init s3c6400_map_io(void)
 	s3c6400_default_sdhci1();
 	s3c6400_default_sdhci2();
 
-	/* the i2c devices are directly compatible with s3c2440 */
-	s3c_i2c0_setname("s3c2440-i2c");
-
 	s3c_device_nand.name = "s3c6400-nand";
 
 	s3c_onenand_setname("s3c6400-onenand");
diff --git a/arch/arm/mach-s3c64xx/s3c6410.c b/arch/arm/mach-s3c64xx/s3c6410.c
index b5fc100..2afba13 100644
--- a/arch/arm/mach-s3c64xx/s3c6410.c
+++ b/arch/arm/mach-s3c64xx/s3c6410.c
@@ -37,7 +37,6 @@
 #include <plat/devs.h>
 #include <plat/clock.h>
 #include <plat/sdhci.h>
-#include <plat/iic-core.h>
 #include <plat/adc.h>
 #include <plat/onenand-core.h>
 #include <mach/s3c6400.h>
@@ -50,9 +49,6 @@ void __init s3c6410_map_io(void)
 	s3c6410_default_sdhci1();
 	s3c6410_default_sdhci2();
 
-	/* the i2c devices are directly compatible with s3c2440 */
-	s3c_i2c0_setname("s3c2440-i2c");
-
 	s3c_device_adc.name	= "s3c64xx-adc";
 	s3c_device_nand.name = "s3c6400-nand";
 	s3c_onenand_setname("s3c6410-onenand");
diff --git a/arch/arm/mach-s5pc100/cpu.c b/arch/arm/mach-s5pc100/cpu.c
index f020aeb..521a677 100644
--- a/arch/arm/mach-s5pc100/cpu.c
+++ b/arch/arm/mach-s5pc100/cpu.c
@@ -38,7 +38,6 @@
 #include <plat/cpu.h>
 #include <plat/devs.h>
 #include <plat/clock.h>
-#include <plat/iic-core.h>
 #include <plat/sdhci.h>
 #include <plat/onenand-core.h>
 
@@ -87,9 +86,6 @@ void __init s5pc100_map_io(void)
 	s5pc100_default_sdhci1();
 	s5pc100_default_sdhci2();
 
-	/* the i2c devices are directly compatible with s3c2440 */
-	s3c_i2c0_setname("s3c2440-i2c");
-
 	s3c_onenand_setname("s5pc100-onenand");
 }
 
diff --git a/arch/arm/mach-s5pv210/cpu.c b/arch/arm/mach-s5pv210/cpu.c
index 8a64ef3..b14b64d 100644
--- a/arch/arm/mach-s5pv210/cpu.c
+++ b/arch/arm/mach-s5pv210/cpu.c
@@ -32,7 +32,6 @@
 #include <plat/devs.h>
 #include <plat/clock.h>
 #include <plat/s5pv210.h>
-#include <plat/iic-core.h>
 #include <plat/sdhci.h>
 
 /* Initial IO mappings */
@@ -86,9 +85,6 @@ void __init s5pv210_map_io(void)
 	s5pv210_default_sdhci0();
 	s5pv210_default_sdhci1();
 	s5pv210_default_sdhci2();
-
-	/* the i2c devices are directly compatible with s3c2440 */
-	s3c_i2c0_setname("s3c2440-i2c");
 }
 
 void __init s5pv210_init_clocks(int xtal)
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/9] ARM: SAMSUNG: Add helper to clone and set platform data
  2010-05-28  6:19 Samsung device updates Ben Dooks
                   ` (4 preceding siblings ...)
  2010-05-28  6:19 ` [PATCH 5/9] ARM: SAMSUNG: Eliminate s3c2440-i2c renames Ben Dooks
@ 2010-05-28  6:19 ` Ben Dooks
  2010-05-28  6:19 ` [PATCH 7/9] ARM: SAMSUNG: Use s3c_set_platdata() helper Ben Dooks
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2010-05-28  6:19 UTC (permalink / raw)
  To: linux-arm-kernel

Add a helper to clone the platform data via kmemdup() and set it into
the specified device and report any problems via printk().

This is intended to replace a number of sites in the Samsung kernel
where the same thing is being repeated in specific platform setting
code. See next patches for replacements.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
 arch/arm/plat-samsung/Makefile            |    2 +
 arch/arm/plat-samsung/include/plat/devs.h |   12 +++++++++
 arch/arm/plat-samsung/platformdata.c      |   37 +++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-samsung/platformdata.c

diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile
index b1d82cc..228c2ad 100644
--- a/arch/arm/plat-samsung/Makefile
+++ b/arch/arm/plat-samsung/Makefile
@@ -30,6 +30,8 @@ obj-$(CONFIG_S3C_ADC)	+= adc.o
 
 # devices
 
+obj-y				+= platformdata.o
+
 obj-$(CONFIG_S3C_DEV_HSMMC)	+= dev-hsmmc.o
 obj-$(CONFIG_S3C_DEV_HSMMC1)	+= dev-hsmmc1.o
 obj-$(CONFIG_S3C_DEV_HSMMC2)	+= dev-hsmmc2.o
diff --git a/arch/arm/plat-samsung/include/plat/devs.h b/arch/arm/plat-samsung/include/plat/devs.h
index e6144e4..6760999 100644
--- a/arch/arm/plat-samsung/include/plat/devs.h
+++ b/arch/arm/plat-samsung/include/plat/devs.h
@@ -108,3 +108,15 @@ extern struct platform_device s3c_device_camif;
 extern struct platform_device s3c_device_ac97;
 
 #endif
+
+/**
+ * s3c_set_platdata() - helper for setting platform data
+ * @pd: The default platform data for this device.
+ * @pdsize: The size of the platform data.
+ * @pdev: Pointer to the device to fill in.
+ *
+ * This helper replaces a number of calls that copy and then set the
+ * platform data of the device.
+ */
+extern void *s3c_set_platdata(void *pd, size_t pdsize,
+			      struct platform_device *pdev);
diff --git a/arch/arm/plat-samsung/platformdata.c b/arch/arm/plat-samsung/platformdata.c
new file mode 100644
index 0000000..4a05efb
--- /dev/null
+++ b/arch/arm/plat-samsung/platformdata.c
@@ -0,0 +1,37 @@
+/* linux/arch/arm/plat-samsung/platformdata.c
+ *
+ * Copyright 2010 Ben Dooks <ben-linux@fluff.org>
+ *
+ * Helper for platform data setting
+ *
+ * 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.
+*/
+
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/platform_device.h>
+
+#include <plat/devs.h>
+
+void __init *s3c_set_platdata(void *pd, size_t pdsize,
+			      struct platform_device *pdev)
+{
+	void *npd;
+
+	if (!pd) {
+		/* too early to use dev_name(), may not be registered */
+		printk(KERN_ERR "%s: no platform data supplied\n", pdev->name);
+		return NULL;
+	}
+
+	npd = kmemdup(pd, pdsize, GFP_KERNEL);
+	if (!npd) {
+		printk(KERN_ERR "%s: cannot clone platform data\n", pdev->name);
+		return NULL;
+	}
+
+	pdev->dev.platform_data = npd;
+	return npd;
+}
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/9] ARM: SAMSUNG: Use s3c_set_platdata() helper
  2010-05-28  6:19 Samsung device updates Ben Dooks
                   ` (5 preceding siblings ...)
  2010-05-28  6:19 ` [PATCH 6/9] ARM: SAMSUNG: Add helper to clone and set platform data Ben Dooks
@ 2010-05-28  6:19 ` Ben Dooks
  2010-05-28  6:19 ` [PATCH 8/9] ARM: S3C24XX: " Ben Dooks
  2010-05-28  6:19 ` [PATCH 9/9] ARM: S3C64XX: " Ben Dooks
  8 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2010-05-28  6:19 UTC (permalink / raw)
  To: linux-arm-kernel

Commit f8b5ea089d5a447a8933a6540ceeccbcb78f9e53 added a helper
to copy and set platform data, so let's replace the various sites
in the Samsung support where this is happening.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
 arch/arm/plat-samsung/dev-fb.c      |   13 +------------
 arch/arm/plat-samsung/dev-hwmon.c   |   13 +------------
 arch/arm/plat-samsung/dev-i2c0.c    |   12 ++++--------
 arch/arm/plat-samsung/dev-i2c1.c    |   12 ++++--------
 arch/arm/plat-samsung/dev-onenand.c |    8 ++------
 arch/arm/plat-samsung/dev-ts.c      |   14 ++------------
 arch/arm/plat-samsung/dev-usb.c     |   12 +++---------
 7 files changed, 17 insertions(+), 67 deletions(-)

diff --git a/arch/arm/plat-samsung/dev-fb.c b/arch/arm/plat-samsung/dev-fb.c
index bf60204..f63190c 100644
--- a/arch/arm/plat-samsung/dev-fb.c
+++ b/arch/arm/plat-samsung/dev-fb.c
@@ -58,16 +58,5 @@ struct platform_device s3c_device_fb = {
 
 void __init s3c_fb_set_platdata(struct s3c_fb_platdata *pd)
 {
-	struct s3c_fb_platdata *npd;
-
-	if (!pd) {
-		printk(KERN_ERR "%s: no platform data\n", __func__);
-		return;
-	}
-
-	npd = kmemdup(pd, sizeof(struct s3c_fb_platdata), GFP_KERNEL);
-	if (!npd)
-		printk(KERN_ERR "%s: no memory for platform data\n", __func__);
-
-	s3c_device_fb.dev.platform_data = npd;
+	s3c_set_platdata(pd, sizeof(struct s3c_fb_platdata), &s3c_device_fb);
 }
diff --git a/arch/arm/plat-samsung/dev-hwmon.c b/arch/arm/plat-samsung/dev-hwmon.c
index b3ffb95..580f580 100644
--- a/arch/arm/plat-samsung/dev-hwmon.c
+++ b/arch/arm/plat-samsung/dev-hwmon.c
@@ -27,16 +27,5 @@ struct platform_device s3c_device_hwmon = {
 
 void __init s3c_hwmon_set_platdata(struct s3c_hwmon_pdata *pd)
 {
-	struct s3c_hwmon_pdata *npd;
-
-	if (!pd) {
-		printk(KERN_ERR "%s: no platform data\n", __func__);
-		return;
-	}
-
-	npd = kmemdup(pd, sizeof(struct s3c_hwmon_pdata), GFP_KERNEL);
-	if (!npd)
-		printk(KERN_ERR "%s: no memory for platform data\n", __func__);
-
-	s3c_device_hwmon.dev.platform_data = npd;
+	s3c_set_platdata(pd, sizeof(struct s3c_hwmon_pdata), &s3c_device_hwmon);
 }
diff --git a/arch/arm/plat-samsung/dev-i2c0.c b/arch/arm/plat-samsung/dev-i2c0.c
index 1ec1ef9..6256c0d 100644
--- a/arch/arm/plat-samsung/dev-i2c0.c
+++ b/arch/arm/plat-samsung/dev-i2c0.c
@@ -58,16 +58,12 @@ static struct s3c2410_platform_i2c default_i2c_data0 __initdata = {
 
 void __init s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *pd)
 {
-	struct s3c2410_platform_i2c *npd;
-
 	if (!pd)
 		pd = &default_i2c_data0;
 
-	npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
-	if (!npd)
-		printk(KERN_ERR "%s: no memory for platform data\n", __func__);
-	else if (!npd->cfg_gpio)
-		npd->cfg_gpio = s3c_i2c0_cfg_gpio;
+	if (!pd->cfg_gpio)
+		pd->cfg_gpio = s3c_i2c0_cfg_gpio;
 
-	s3c_device_i2c0.dev.platform_data = npd;
+	s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
+			 &s3c_device_i2c0);
 }
diff --git a/arch/arm/plat-samsung/dev-i2c1.c b/arch/arm/plat-samsung/dev-i2c1.c
index f97905f..cb63223 100644
--- a/arch/arm/plat-samsung/dev-i2c1.c
+++ b/arch/arm/plat-samsung/dev-i2c1.c
@@ -55,16 +55,12 @@ static struct s3c2410_platform_i2c default_i2c_data1 __initdata = {
 
 void __init s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *pd)
 {
-	struct s3c2410_platform_i2c *npd;
-
 	if (!pd)
 		pd = &default_i2c_data1;
 
-	npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
-	if (!npd)
-		printk(KERN_ERR "%s: no memory for platform data\n", __func__);
-	else if (!npd->cfg_gpio)
-		npd->cfg_gpio = s3c_i2c1_cfg_gpio;
+	if (!pd->cfg_gpio)
+		pd->cfg_gpio = s3c_i2c1_cfg_gpio;
 
-	s3c_device_i2c1.dev.platform_data = npd;
+	s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
+			 &s3c_device_i2c1);
 }
diff --git a/arch/arm/plat-samsung/dev-onenand.c b/arch/arm/plat-samsung/dev-onenand.c
index 45ec732..a16e878 100644
--- a/arch/arm/plat-samsung/dev-onenand.c
+++ b/arch/arm/plat-samsung/dev-onenand.c
@@ -46,10 +46,6 @@ struct platform_device s3c_device_onenand = {
 
 void s3c_onenand_set_platdata(struct onenand_platform_data *pdata)
 {
-	struct onenand_platform_data *pd;
-
-	pd = kmemdup(pdata, sizeof(struct onenand_platform_data), GFP_KERNEL);
-	if (!pd)
-		printk(KERN_ERR "%s: no memory for platform data\n", __func__);
-	s3c_device_onenand.dev.platform_data = pd;
+	s3c_set_platdata(pdata, sizeof(struct onenand_platform_data),
+			 &s3c_device_onenand);
 }
diff --git a/arch/arm/plat-samsung/dev-ts.c b/arch/arm/plat-samsung/dev-ts.c
index 236ef84..db0432d 100644
--- a/arch/arm/plat-samsung/dev-ts.c
+++ b/arch/arm/plat-samsung/dev-ts.c
@@ -45,17 +45,7 @@ struct platform_device s3c_device_ts = {
 
 void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *pd)
 {
-	struct s3c2410_ts_mach_info *npd;
-
-	if (!pd) {
-		printk(KERN_ERR "%s: no platform data\n", __func__);
-		return;
-	}
-
-	npd = kmemdup(pd, sizeof(struct s3c2410_ts_mach_info), GFP_KERNEL);
-	if (!npd)
-		printk(KERN_ERR "%s: no memory for platform data\n", __func__);
-
-	s3c_device_ts.dev.platform_data = npd;
+	s3c_set_platdata(pd, sizeof(struct s3c2410_ts_mach_info),
+			 &s3c_device_ts);
 }
 EXPORT_SYMBOL(s3c24xx_ts_set_platdata);
diff --git a/arch/arm/plat-samsung/dev-usb.c b/arch/arm/plat-samsung/dev-usb.c
index 0e0a3bf..591c53c 100644
--- a/arch/arm/plat-samsung/dev-usb.c
+++ b/arch/arm/plat-samsung/dev-usb.c
@@ -52,19 +52,13 @@ EXPORT_SYMBOL(s3c_device_ohci);
 
 /**
  * s3c_ohci_set_platdata - initialise OHCI device platform data
- * @info: The platform data.
+ * @pd: The platform data.
  *
  * This call copies the @info passed in and sets the device .platform_data
  * field to that copy. The @info is copied so that the original can be marked
  * __initdata.
  */
-void __init s3c_ohci_set_platdata(struct s3c2410_hcd_info *info)
+void __init s3c_ohci_set_platdata(struct s3c2410_hcd_info *pd)
 {
-	struct s3c2410_hcd_info *npd;
-
-	npd = kmemdup(info, sizeof(struct s3c2410_hcd_info), GFP_KERNEL);
-	if (!npd)
-		printk(KERN_ERR "%s: no memory for platform data\n", __func__);
-
-	s3c_device_ohci.dev.platform_data = npd;
+	s3c_set_platdata(pd, sizeof(struct s3c2410_hcd_info), &s3c_device_ohci);
 }
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 8/9] ARM: S3C24XX: Use s3c_set_platdata() helper
  2010-05-28  6:19 Samsung device updates Ben Dooks
                   ` (6 preceding siblings ...)
  2010-05-28  6:19 ` [PATCH 7/9] ARM: SAMSUNG: Use s3c_set_platdata() helper Ben Dooks
@ 2010-05-28  6:19 ` Ben Dooks
  2010-05-28  6:19 ` [PATCH 9/9] ARM: S3C64XX: " Ben Dooks
  8 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2010-05-28  6:19 UTC (permalink / raw)
  To: linux-arm-kernel

Commit f8b5ea089d5a447a8933a6540ceeccbcb78f9e53 added a helper
to copy and set platform data, so let's replace the various sites
in the Samsung support where this is happening.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
 arch/arm/plat-s3c24xx/devs.c |   23 ++++-------------------
 1 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/arch/arm/plat-s3c24xx/devs.c b/arch/arm/plat-s3c24xx/devs.c
index 452e184..028c8bd 100644
--- a/arch/arm/plat-s3c24xx/devs.c
+++ b/arch/arm/plat-s3c24xx/devs.c
@@ -149,9 +149,8 @@ void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
 {
 	struct s3c2410fb_mach_info *npd;
 
-	npd = kmemdup(pd, sizeof(*npd), GFP_KERNEL);
+	npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_lcd);
 	if (npd) {
-		s3c_device_lcd.dev.platform_data = npd;
 		npd->displays = kmemdup(pd->displays,
 			sizeof(struct s3c2410fb_display) * npd->num_displays,
 			GFP_KERNEL);
@@ -223,15 +222,7 @@ EXPORT_SYMBOL(s3c_device_usbgadget);
 
 void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd)
 {
-	struct s3c2410_udc_mach_info *npd;
-
-	npd = kmalloc(sizeof(*npd), GFP_KERNEL);
-	if (npd) {
-		memcpy(npd, pd, sizeof(*npd));
-		s3c_device_usbgadget.dev.platform_data = npd;
-	} else {
-		printk(KERN_ERR "no memory for udc platform data\n");
-	}
+	s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usbgadget);
 }
 
 /* IIS */
@@ -341,15 +332,9 @@ struct platform_device s3c_device_sdi = {
 
 EXPORT_SYMBOL(s3c_device_sdi);
 
-void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata)
+void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pd)
 {
-	struct s3c24xx_mci_pdata *npd;
-
-	npd = kmemdup(pdata, sizeof(struct s3c24xx_mci_pdata), GFP_KERNEL);
-	if (!npd)
-		printk(KERN_ERR "%s: no memory to copy pdata", __func__);
-
-	s3c_device_sdi.dev.platform_data = npd;
+	s3c_set_platdata(pd, sizeof(struct s3c24xx_mci_pdata), &s3c_device_sdi);
 }
 
 
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 9/9] ARM: S3C64XX: Use s3c_set_platdata() helper
  2010-05-28  6:19 Samsung device updates Ben Dooks
                   ` (7 preceding siblings ...)
  2010-05-28  6:19 ` [PATCH 8/9] ARM: S3C24XX: " Ben Dooks
@ 2010-05-28  6:19 ` Ben Dooks
  8 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2010-05-28  6:19 UTC (permalink / raw)
  To: linux-arm-kernel

Commit f8b5ea089d5a447a8933a6540ceeccbcb78f9e53 added a helper
to copy and set platform data, so let's replace the various sites
in the Samsung support where this is happening.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
 arch/arm/mach-s3c64xx/dev-onenand1.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/dev-onenand1.c b/arch/arm/mach-s3c64xx/dev-onenand1.c
index 92ffd5b..c902a1d 100644
--- a/arch/arm/mach-s3c64xx/dev-onenand1.c
+++ b/arch/arm/mach-s3c64xx/dev-onenand1.c
@@ -46,10 +46,6 @@ struct platform_device s3c64xx_device_onenand1 = {
 
 void s3c64xx_onenand1_set_platdata(struct onenand_platform_data *pdata)
 {
-	struct onenand_platform_data *pd;
-
-	pd = kmemdup(pdata, sizeof(struct onenand_platform_data), GFP_KERNEL);
-	if (!pd)
-		printk(KERN_ERR "%s: no memory for platform data\n", __func__);
-	s3c64xx_device_onenand1.dev.platform_data = pd;
+	s3c_set_platdata(pd, sizeof(struct onenand_platform_data),
+			 &s3c64xx_device_onenand1);
 }
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-05-28  6:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-28  6:19 Samsung device updates Ben Dooks
2010-05-28  6:19 ` [PATCH 1/9] ARM: SAMSUNG: Default s3c_device_i2c1 Ben Dooks
2010-05-28  6:19 ` [PATCH 2/9] ARM: SAMSUNG: Remove s3c_i2c1_setname() calls for s3c2440-i2c Ben Dooks
2010-05-28  6:19 ` [PATCH 3/9] ARM: SAMSUNG: Default s3c_device_i2c2 to s3c2440-i2c Ben Dooks
2010-05-28  6:19 ` [PATCH 4/9] ARM: SAMSUNG: Default s3c_device_i2c0 " Ben Dooks
2010-05-28  6:19 ` [PATCH 5/9] ARM: SAMSUNG: Eliminate s3c2440-i2c renames Ben Dooks
2010-05-28  6:19 ` [PATCH 6/9] ARM: SAMSUNG: Add helper to clone and set platform data Ben Dooks
2010-05-28  6:19 ` [PATCH 7/9] ARM: SAMSUNG: Use s3c_set_platdata() helper Ben Dooks
2010-05-28  6:19 ` [PATCH 8/9] ARM: S3C24XX: " Ben Dooks
2010-05-28  6:19 ` [PATCH 9/9] ARM: S3C64XX: " Ben Dooks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).