diff options
-rw-r--r-- | drivers/base/platform.c | 1 | ||||
-rw-r--r-- | drivers/mfd/mfd-core.c | 16 | ||||
-rw-r--r-- | include/linux/mfd/core.h | 13 | ||||
-rw-r--r-- | include/linux/platform_device.h | 5 |
4 files changed, 31 insertions, 4 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index f051cfff18af..6c3a2bdc527a 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -149,6 +149,7 @@ static void platform_device_release(struct device *dev) | |||
149 | 149 | ||
150 | of_device_node_put(&pa->pdev.dev); | 150 | of_device_node_put(&pa->pdev.dev); |
151 | kfree(pa->pdev.dev.platform_data); | 151 | kfree(pa->pdev.dev.platform_data); |
152 | kfree(pa->pdev.mfd_cell); | ||
152 | kfree(pa->pdev.resource); | 153 | kfree(pa->pdev.resource); |
153 | kfree(pa); | 154 | kfree(pa); |
154 | } | 155 | } |
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index d01574d98870..f4c8c844b913 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c | |||
@@ -55,6 +55,19 @@ int mfd_cell_disable(struct platform_device *pdev) | |||
55 | } | 55 | } |
56 | EXPORT_SYMBOL(mfd_cell_disable); | 56 | EXPORT_SYMBOL(mfd_cell_disable); |
57 | 57 | ||
58 | static int mfd_platform_add_cell(struct platform_device *pdev, | ||
59 | const struct mfd_cell *cell) | ||
60 | { | ||
61 | if (!cell) | ||
62 | return 0; | ||
63 | |||
64 | pdev->mfd_cell = kmemdup(cell, sizeof(*cell), GFP_KERNEL); | ||
65 | if (!pdev->mfd_cell) | ||
66 | return -ENOMEM; | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | |||
58 | static int mfd_add_device(struct device *parent, int id, | 71 | static int mfd_add_device(struct device *parent, int id, |
59 | const struct mfd_cell *cell, | 72 | const struct mfd_cell *cell, |
60 | struct resource *mem_base, | 73 | struct resource *mem_base, |
@@ -75,7 +88,7 @@ static int mfd_add_device(struct device *parent, int id, | |||
75 | 88 | ||
76 | pdev->dev.parent = parent; | 89 | pdev->dev.parent = parent; |
77 | 90 | ||
78 | ret = platform_device_add_data(pdev, cell, sizeof(*cell)); | 91 | ret = mfd_platform_add_cell(pdev, cell); |
79 | if (ret) | 92 | if (ret) |
80 | goto fail_res; | 93 | goto fail_res; |
81 | 94 | ||
@@ -123,7 +136,6 @@ static int mfd_add_device(struct device *parent, int id, | |||
123 | 136 | ||
124 | return 0; | 137 | return 0; |
125 | 138 | ||
126 | /* platform_device_del(pdev); */ | ||
127 | fail_res: | 139 | fail_res: |
128 | kfree(res); | 140 | kfree(res); |
129 | fail_device: | 141 | fail_device: |
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index ad1b19aa6508..aef23309a742 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h | |||
@@ -86,16 +86,25 @@ extern int mfd_clone_cell(const char *cell, const char **clones, | |||
86 | */ | 86 | */ |
87 | static inline const struct mfd_cell *mfd_get_cell(struct platform_device *pdev) | 87 | static inline const struct mfd_cell *mfd_get_cell(struct platform_device *pdev) |
88 | { | 88 | { |
89 | return pdev->dev.platform_data; | 89 | return pdev->mfd_cell; |
90 | } | 90 | } |
91 | 91 | ||
92 | /* | 92 | /* |
93 | * Given a platform device that's been created by mfd_add_devices(), fetch | 93 | * Given a platform device that's been created by mfd_add_devices(), fetch |
94 | * the .mfd_data entry from the mfd_cell that created it. | 94 | * the .mfd_data entry from the mfd_cell that created it. |
95 | * Otherwise just return the platform_data pointer. | ||
96 | * This maintains compatibility with platform drivers whose devices aren't | ||
97 | * created by the mfd layer, and expect platform_data to contain what would've | ||
98 | * otherwise been in mfd_data. | ||
95 | */ | 99 | */ |
96 | static inline void *mfd_get_data(struct platform_device *pdev) | 100 | static inline void *mfd_get_data(struct platform_device *pdev) |
97 | { | 101 | { |
98 | return mfd_get_cell(pdev)->mfd_data; | 102 | const struct mfd_cell *cell = mfd_get_cell(pdev); |
103 | |||
104 | if (cell) | ||
105 | return cell->mfd_data; | ||
106 | else | ||
107 | return pdev->dev.platform_data; | ||
99 | } | 108 | } |
100 | 109 | ||
101 | extern int mfd_add_devices(struct device *parent, int id, | 110 | extern int mfd_add_devices(struct device *parent, int id, |
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index d96db9825708..744942c95fec 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h | |||
@@ -14,6 +14,8 @@ | |||
14 | #include <linux/device.h> | 14 | #include <linux/device.h> |
15 | #include <linux/mod_devicetable.h> | 15 | #include <linux/mod_devicetable.h> |
16 | 16 | ||
17 | struct mfd_cell; | ||
18 | |||
17 | struct platform_device { | 19 | struct platform_device { |
18 | const char * name; | 20 | const char * name; |
19 | int id; | 21 | int id; |
@@ -23,6 +25,9 @@ struct platform_device { | |||
23 | 25 | ||
24 | const struct platform_device_id *id_entry; | 26 | const struct platform_device_id *id_entry; |
25 | 27 | ||
28 | /* MFD cell pointer */ | ||
29 | struct mfd_cell *mfd_cell; | ||
30 | |||
26 | /* arch specific additions */ | 31 | /* arch specific additions */ |
27 | struct pdev_archdata archdata; | 32 | struct pdev_archdata archdata; |
28 | }; | 33 | }; |