aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2011-08-25 05:16:01 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-08-26 14:31:10 -0400
commit0e392412f334c80baedb30a29796a256b0d5e629 (patch)
treeb3f7cc11022a2629db545d07de329fc8478eaa21 /arch/arm
parent01dcc60a7cb8cd5193676554b94a90d349bdfd15 (diff)
ARM: mxc: convert device creation to use platform_device_register_full
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/plat-mxc/devices.c53
-rw-r--r--arch/arm/plat-mxc/include/mach/devices-common.h16
2 files changed, 14 insertions, 55 deletions
diff --git a/arch/arm/plat-mxc/devices.c b/arch/arm/plat-mxc/devices.c
index 0d6ed31bdbf2..a34b2ae895f2 100644
--- a/arch/arm/plat-mxc/devices.c
+++ b/arch/arm/plat-mxc/devices.c
@@ -37,59 +37,6 @@ int __init mxc_register_device(struct platform_device *pdev, void *data)
37 return ret; 37 return ret;
38} 38}
39 39
40struct platform_device *__init imx_add_platform_device_dmamask(
41 const char *name, int id,
42 const struct resource *res, unsigned int num_resources,
43 const void *data, size_t size_data, u64 dmamask)
44{
45 int ret = -ENOMEM;
46 struct platform_device *pdev;
47
48 pdev = platform_device_alloc(name, id);
49 if (!pdev)
50 goto err;
51
52 if (dmamask) {
53 /*
54 * This memory isn't freed when the device is put,
55 * I don't have a nice idea for that though. Conceptually
56 * dma_mask in struct device should not be a pointer.
57 * See http://thread.gmane.org/gmane.linux.kernel.pci/9081
58 */
59 pdev->dev.dma_mask =
60 kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
61 if (!pdev->dev.dma_mask)
62 /* ret is still -ENOMEM; */
63 goto err;
64
65 *pdev->dev.dma_mask = dmamask;
66 pdev->dev.coherent_dma_mask = dmamask;
67 }
68
69 if (res) {
70 ret = platform_device_add_resources(pdev, res, num_resources);
71 if (ret)
72 goto err;
73 }
74
75 if (data) {
76 ret = platform_device_add_data(pdev, data, size_data);
77 if (ret)
78 goto err;
79 }
80
81 ret = platform_device_add(pdev);
82 if (ret) {
83err:
84 if (dmamask)
85 kfree(pdev->dev.dma_mask);
86 platform_device_put(pdev);
87 return ERR_PTR(ret);
88 }
89
90 return pdev;
91}
92
93struct device mxc_aips_bus = { 40struct device mxc_aips_bus = {
94 .init_name = "mxc_aips", 41 .init_name = "mxc_aips",
95 .parent = &platform_bus, 42 .parent = &platform_bus,
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index 524538aabc4b..543525d76a60 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -14,10 +14,22 @@
14extern struct device mxc_aips_bus; 14extern struct device mxc_aips_bus;
15extern struct device mxc_ahb_bus; 15extern struct device mxc_ahb_bus;
16 16
17struct platform_device *imx_add_platform_device_dmamask( 17static inline struct platform_device *imx_add_platform_device_dmamask(
18 const char *name, int id, 18 const char *name, int id,
19 const struct resource *res, unsigned int num_resources, 19 const struct resource *res, unsigned int num_resources,
20 const void *data, size_t size_data, u64 dmamask); 20 const void *data, size_t size_data, u64 dmamask)
21{
22 struct platform_device_info pdevinfo = {
23 .name = name,
24 .id = id,
25 .res = res,
26 .num_res = num_resources,
27 .data = data,
28 .size_data = size_data,
29 .dma_mask = dmamask,
30 };
31 return platform_device_register_full(&pdevinfo);
32}
21 33
22static inline struct platform_device *imx_add_platform_device( 34static inline struct platform_device *imx_add_platform_device(
23 const char *name, int id, 35 const char *name, int id,