diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2010-06-15 05:31:02 -0400 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2010-06-30 03:00:03 -0400 |
commit | 253ff1fa6f8d24d46ef1b5aa68f6293b883f03d8 (patch) | |
tree | da40d69b0cb4357bab9c0a108609420db9c0f220 | |
parent | 9f72ffedc8409b9c9cbe17a9f66c2982baa4ff52 (diff) |
ARM: imx: new helper function imx_add_platform_device
This should be a globally available function, see
http://thread.gmane.org/gmane.linux.kernel/998881/focus=998882
Until this hits mainline create a similar function available for imx
platforms only.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
-rw-r--r-- | arch/arm/plat-mxc/devices.c | 33 | ||||
-rw-r--r-- | arch/arm/plat-mxc/include/mach/devices-common.h | 15 |
2 files changed, 48 insertions, 0 deletions
diff --git a/arch/arm/plat-mxc/devices.c b/arch/arm/plat-mxc/devices.c index 56f2fb5cc456..735776d84956 100644 --- a/arch/arm/plat-mxc/devices.c +++ b/arch/arm/plat-mxc/devices.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/err.h> | ||
21 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
22 | #include <mach/common.h> | 23 | #include <mach/common.h> |
23 | 24 | ||
@@ -35,3 +36,35 @@ int __init mxc_register_device(struct platform_device *pdev, void *data) | |||
35 | return ret; | 36 | return ret; |
36 | } | 37 | } |
37 | 38 | ||
39 | struct platform_device *__init imx_add_platform_device(const char *name, int id, | ||
40 | const struct resource *res, unsigned int num_resources, | ||
41 | const void *data, size_t size_data) | ||
42 | { | ||
43 | int ret = -ENOMEM; | ||
44 | struct platform_device *pdev; | ||
45 | |||
46 | pdev = platform_device_alloc(name, id); | ||
47 | if (!pdev) | ||
48 | goto err; | ||
49 | |||
50 | if (res) { | ||
51 | ret = platform_device_add_resources(pdev, res, num_resources); | ||
52 | if (ret) | ||
53 | goto err; | ||
54 | } | ||
55 | |||
56 | if (data) { | ||
57 | ret = platform_device_add_data(pdev, data, size_data); | ||
58 | if (ret) | ||
59 | goto err; | ||
60 | } | ||
61 | |||
62 | ret = platform_device_add(pdev); | ||
63 | if (ret) { | ||
64 | err: | ||
65 | platform_device_put(pdev); | ||
66 | return ERR_PTR(ret); | ||
67 | } | ||
68 | |||
69 | return pdev; | ||
70 | } | ||
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h new file mode 100644 index 000000000000..849d8ff7b17d --- /dev/null +++ b/arch/arm/plat-mxc/include/mach/devices-common.h | |||
@@ -0,0 +1,15 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009-2010 Pengutronix | ||
3 | * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it under | ||
6 | * the terms of the GNU General Public License version 2 as published by the | ||
7 | * Free Software Foundation. | ||
8 | */ | ||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/platform_device.h> | ||
11 | #include <linux/init.h> | ||
12 | |||
13 | struct platform_device *imx_add_platform_device(const char *name, int id, | ||
14 | const struct resource *res, unsigned int num_resources, | ||
15 | const void *data, size_t size_data); | ||