diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2010-11-02 06:56:54 -0400 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2010-11-17 04:01:21 -0500 |
commit | 6332c1071811a1d588cfc93330d87a57a7460a1b (patch) | |
tree | b9e5a427bd583dc2cca240b190152d1a06ebd99a /arch | |
parent | e08300043ee4e2df10be551b76e126d6c02f26cc (diff) |
ARM: imx: allow specifying a dma mask when creating a platform device
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/plat-mxc/devices.c | 23 | ||||
-rw-r--r-- | arch/arm/plat-mxc/include/mach/devices-common.h | 14 |
2 files changed, 33 insertions, 4 deletions
diff --git a/arch/arm/plat-mxc/devices.c b/arch/arm/plat-mxc/devices.c index 735776d84956..e9bcefe79a43 100644 --- a/arch/arm/plat-mxc/devices.c +++ b/arch/arm/plat-mxc/devices.c | |||
@@ -17,6 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/slab.h> | ||
20 | #include <linux/init.h> | 21 | #include <linux/init.h> |
21 | #include <linux/err.h> | 22 | #include <linux/err.h> |
22 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
@@ -36,9 +37,10 @@ int __init mxc_register_device(struct platform_device *pdev, void *data) | |||
36 | return ret; | 37 | return ret; |
37 | } | 38 | } |
38 | 39 | ||
39 | struct platform_device *__init imx_add_platform_device(const char *name, int id, | 40 | struct platform_device *__init imx_add_platform_device_dmamask( |
41 | const char *name, int id, | ||
40 | const struct resource *res, unsigned int num_resources, | 42 | const struct resource *res, unsigned int num_resources, |
41 | const void *data, size_t size_data) | 43 | const void *data, size_t size_data, u64 dmamask) |
42 | { | 44 | { |
43 | int ret = -ENOMEM; | 45 | int ret = -ENOMEM; |
44 | struct platform_device *pdev; | 46 | struct platform_device *pdev; |
@@ -47,6 +49,23 @@ struct platform_device *__init imx_add_platform_device(const char *name, int id, | |||
47 | if (!pdev) | 49 | if (!pdev) |
48 | goto err; | 50 | goto err; |
49 | 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 | |||
50 | if (res) { | 69 | if (res) { |
51 | ret = platform_device_add_resources(pdev, res, num_resources); | 70 | ret = platform_device_add_resources(pdev, res, num_resources); |
52 | if (ret) | 71 | if (ret) |
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h index 4eb45fa53ac5..a5e97b8b3b79 100644 --- a/arch/arm/plat-mxc/include/mach/devices-common.h +++ b/arch/arm/plat-mxc/include/mach/devices-common.h | |||
@@ -10,9 +10,19 @@ | |||
10 | #include <linux/platform_device.h> | 10 | #include <linux/platform_device.h> |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | 12 | ||
13 | struct platform_device *imx_add_platform_device(const char *name, int id, | 13 | struct platform_device *imx_add_platform_device_dmamask( |
14 | const char *name, int id, | ||
14 | const struct resource *res, unsigned int num_resources, | 15 | const struct resource *res, unsigned int num_resources, |
15 | const void *data, size_t size_data); | 16 | const void *data, size_t size_data, u64 dmamask); |
17 | |||
18 | static inline struct platform_device *imx_add_platform_device( | ||
19 | const char *name, int id, | ||
20 | const struct resource *res, unsigned int num_resources, | ||
21 | const void *data, size_t size_data) | ||
22 | { | ||
23 | return imx_add_platform_device_dmamask( | ||
24 | name, id, res, num_resources, data, size_data, 0); | ||
25 | } | ||
16 | 26 | ||
17 | #include <linux/fec.h> | 27 | #include <linux/fec.h> |
18 | struct imx_fec_data { | 28 | struct imx_fec_data { |