diff options
author | Balaji T K <balajitk@ti.com> | 2012-04-25 07:57:46 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2012-05-08 20:16:24 -0400 |
commit | 1ee47b0ae83e3cae2f9362113b3935898fdb3ea9 (patch) | |
tree | 3ef26910e99261d1f9fbf25b0926fcf708bd3372 /arch/arm/mach-omap2/omap4-common.c | |
parent | e54bdc187efcc029dd723128fe1fc518f7387d53 (diff) |
ARM: OMAP4: hsmmc: check for null pointer
platform_device pdev can be NULL if CONFIG_MMC_OMAP_HS is not set.
Add check for NULL pointer. while at it move the duplicated functions
to omap4-common.c
Fixes the following boot crash seen with omap4sdp and omap4panda
when MMC is disabled.
Unable to handle kernel NULL pointer dereference at virtual address 0000008c
pgd = c0004000
[0000008c] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
Modules linked in:
CPU: 0 Not tainted (3.4.0-rc1-05971-ga4dfa82 #4)
PC is at omap_4430sdp_init+0x184/0x410
LR is at device_add+0x1a0/0x664
Signed-off-by: Balaji T K <balajitk@ti.com>
Reported-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/omap4-common.c')
-rw-r--r-- | arch/arm/mach-omap2/omap4-common.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/omap4-common.c b/arch/arm/mach-omap2/omap4-common.c index 70de277f5c15..a8161e5f3204 100644 --- a/arch/arm/mach-omap2/omap4-common.c +++ b/arch/arm/mach-omap2/omap4-common.c | |||
@@ -25,11 +25,13 @@ | |||
25 | #include <plat/irqs.h> | 25 | #include <plat/irqs.h> |
26 | #include <plat/sram.h> | 26 | #include <plat/sram.h> |
27 | #include <plat/omap-secure.h> | 27 | #include <plat/omap-secure.h> |
28 | #include <plat/mmc.h> | ||
28 | 29 | ||
29 | #include <mach/hardware.h> | 30 | #include <mach/hardware.h> |
30 | #include <mach/omap-wakeupgen.h> | 31 | #include <mach/omap-wakeupgen.h> |
31 | 32 | ||
32 | #include "common.h" | 33 | #include "common.h" |
34 | #include "hsmmc.h" | ||
33 | #include "omap4-sar-layout.h" | 35 | #include "omap4-sar-layout.h" |
34 | #include <linux/export.h> | 36 | #include <linux/export.h> |
35 | 37 | ||
@@ -207,3 +209,59 @@ static int __init omap4_sar_ram_init(void) | |||
207 | return 0; | 209 | return 0; |
208 | } | 210 | } |
209 | early_initcall(omap4_sar_ram_init); | 211 | early_initcall(omap4_sar_ram_init); |
212 | |||
213 | #if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE) | ||
214 | static int omap4_twl6030_hsmmc_late_init(struct device *dev) | ||
215 | { | ||
216 | int irq = 0; | ||
217 | struct platform_device *pdev = container_of(dev, | ||
218 | struct platform_device, dev); | ||
219 | struct omap_mmc_platform_data *pdata = dev->platform_data; | ||
220 | |||
221 | /* Setting MMC1 Card detect Irq */ | ||
222 | if (pdev->id == 0) { | ||
223 | irq = twl6030_mmc_card_detect_config(); | ||
224 | if (irq < 0) { | ||
225 | dev_err(dev, "%s: Error card detect config(%d)\n", | ||
226 | __func__, irq); | ||
227 | return irq; | ||
228 | } | ||
229 | pdata->slots[0].card_detect_irq = irq; | ||
230 | pdata->slots[0].card_detect = twl6030_mmc_card_detect; | ||
231 | } | ||
232 | return 0; | ||
233 | } | ||
234 | |||
235 | static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev) | ||
236 | { | ||
237 | struct omap_mmc_platform_data *pdata; | ||
238 | |||
239 | /* dev can be null if CONFIG_MMC_OMAP_HS is not set */ | ||
240 | if (!dev) { | ||
241 | pr_err("Failed %s\n", __func__); | ||
242 | return; | ||
243 | } | ||
244 | pdata = dev->platform_data; | ||
245 | pdata->init = omap4_twl6030_hsmmc_late_init; | ||
246 | } | ||
247 | |||
248 | int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers) | ||
249 | { | ||
250 | struct omap2_hsmmc_info *c; | ||
251 | |||
252 | omap_hsmmc_init(controllers); | ||
253 | for (c = controllers; c->mmc; c++) { | ||
254 | /* pdev can be null if CONFIG_MMC_OMAP_HS is not set */ | ||
255 | if (!c->pdev) | ||
256 | continue; | ||
257 | omap4_twl6030_hsmmc_set_late_init(&c->pdev->dev); | ||
258 | } | ||
259 | |||
260 | return 0; | ||
261 | } | ||
262 | #else | ||
263 | int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers) | ||
264 | { | ||
265 | return 0; | ||
266 | } | ||
267 | #endif | ||