diff options
author | Ben Dooks <ben-linux@fluff.org> | 2010-06-09 23:57:15 -0400 |
---|---|---|
committer | Kukjin Kim <kgene.kim@samsung.com> | 2010-08-05 05:32:49 -0400 |
commit | 3911dab8ad582fd4db5e79eda5320c37c3dfb9bb (patch) | |
tree | c2a80e4b4814512d289f4e39fb489a4958067d39 | |
parent | 5db2bc8a114b866f351a510dab6945ab20567055 (diff) |
ARM: SAMSUNG: Add helper to clone and set platform data
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>
[kgene.kim@samsung.com: This is for building test]
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
-rw-r--r-- | arch/arm/plat-samsung/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/plat-samsung/include/plat/devs.h | 12 | ||||
-rw-r--r-- | arch/arm/plat-samsung/platformdata.c | 37 |
3 files changed, 51 insertions, 0 deletions
diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile index b1d82cc5e716..228c2add1e2e 100644 --- a/arch/arm/plat-samsung/Makefile +++ b/arch/arm/plat-samsung/Makefile | |||
@@ -30,6 +30,8 @@ obj-$(CONFIG_S3C_ADC) += adc.o | |||
30 | 30 | ||
31 | # devices | 31 | # devices |
32 | 32 | ||
33 | obj-y += platformdata.o | ||
34 | |||
33 | obj-$(CONFIG_S3C_DEV_HSMMC) += dev-hsmmc.o | 35 | obj-$(CONFIG_S3C_DEV_HSMMC) += dev-hsmmc.o |
34 | obj-$(CONFIG_S3C_DEV_HSMMC1) += dev-hsmmc1.o | 36 | obj-$(CONFIG_S3C_DEV_HSMMC1) += dev-hsmmc1.o |
35 | obj-$(CONFIG_S3C_DEV_HSMMC2) += dev-hsmmc2.o | 37 | 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 e6144e4b9118..676099999de4 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; | |||
108 | extern struct platform_device s3c_device_ac97; | 108 | extern struct platform_device s3c_device_ac97; |
109 | 109 | ||
110 | #endif | 110 | #endif |
111 | |||
112 | /** | ||
113 | * s3c_set_platdata() - helper for setting platform data | ||
114 | * @pd: The default platform data for this device. | ||
115 | * @pdsize: The size of the platform data. | ||
116 | * @pdev: Pointer to the device to fill in. | ||
117 | * | ||
118 | * This helper replaces a number of calls that copy and then set the | ||
119 | * platform data of the device. | ||
120 | */ | ||
121 | extern void *s3c_set_platdata(void *pd, size_t pdsize, | ||
122 | 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 000000000000..7cf2e1e3b20f --- /dev/null +++ b/arch/arm/plat-samsung/platformdata.c | |||
@@ -0,0 +1,37 @@ | |||
1 | /* linux/arch/arm/plat-samsung/platformdata.c | ||
2 | * | ||
3 | * Copyright 2010 Ben Dooks <ben-linux <at> fluff.org> | ||
4 | * | ||
5 | * Helper for platform data setting | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/string.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | |||
16 | #include <plat/devs.h> | ||
17 | |||
18 | void __init *s3c_set_platdata(void *pd, size_t pdsize, | ||
19 | struct platform_device *pdev) | ||
20 | { | ||
21 | void *npd; | ||
22 | |||
23 | if (!pd) { | ||
24 | /* too early to use dev_name(), may not be registered */ | ||
25 | printk(KERN_ERR "%s: no platform data supplied\n", pdev->name); | ||
26 | return NULL; | ||
27 | } | ||
28 | |||
29 | npd = kmemdup(pd, pdsize, GFP_KERNEL); | ||
30 | if (!npd) { | ||
31 | printk(KERN_ERR "%s: cannot clone platform data\n", pdev->name); | ||
32 | return NULL; | ||
33 | } | ||
34 | |||
35 | pdev->dev.platform_data = npd; | ||
36 | return npd; | ||
37 | } | ||