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 | |
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')
-rw-r--r-- | arch/arm/mach-omap2/board-4430sdp.c | 44 | ||||
-rw-r--r-- | arch/arm/mach-omap2/board-omap4panda.c | 49 | ||||
-rw-r--r-- | arch/arm/mach-omap2/common.h | 3 | ||||
-rw-r--r-- | arch/arm/mach-omap2/omap4-common.c | 58 |
4 files changed, 61 insertions, 93 deletions
diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c index 130ab00c09a2..6dc184841892 100644 --- a/arch/arm/mach-omap2/board-4430sdp.c +++ b/arch/arm/mach-omap2/board-4430sdp.c | |||
@@ -489,50 +489,6 @@ static struct platform_device omap_vwlan_device = { | |||
489 | }, | 489 | }, |
490 | }; | 490 | }; |
491 | 491 | ||
492 | static int omap4_twl6030_hsmmc_late_init(struct device *dev) | ||
493 | { | ||
494 | int irq = 0; | ||
495 | struct platform_device *pdev = container_of(dev, | ||
496 | struct platform_device, dev); | ||
497 | struct omap_mmc_platform_data *pdata = dev->platform_data; | ||
498 | |||
499 | /* Setting MMC1 Card detect Irq */ | ||
500 | if (pdev->id == 0) { | ||
501 | irq = twl6030_mmc_card_detect_config(); | ||
502 | if (irq < 0) { | ||
503 | pr_err("Failed configuring MMC1 card detect\n"); | ||
504 | return irq; | ||
505 | } | ||
506 | pdata->slots[0].card_detect_irq = irq; | ||
507 | pdata->slots[0].card_detect = twl6030_mmc_card_detect; | ||
508 | } | ||
509 | return 0; | ||
510 | } | ||
511 | |||
512 | static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev) | ||
513 | { | ||
514 | struct omap_mmc_platform_data *pdata; | ||
515 | |||
516 | /* dev can be null if CONFIG_MMC_OMAP_HS is not set */ | ||
517 | if (!dev) { | ||
518 | pr_err("Failed %s\n", __func__); | ||
519 | return; | ||
520 | } | ||
521 | pdata = dev->platform_data; | ||
522 | pdata->init = omap4_twl6030_hsmmc_late_init; | ||
523 | } | ||
524 | |||
525 | static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers) | ||
526 | { | ||
527 | struct omap2_hsmmc_info *c; | ||
528 | |||
529 | omap_hsmmc_init(controllers); | ||
530 | for (c = controllers; c->mmc; c++) | ||
531 | omap4_twl6030_hsmmc_set_late_init(&c->pdev->dev); | ||
532 | |||
533 | return 0; | ||
534 | } | ||
535 | |||
536 | static struct regulator_init_data sdp4430_vaux1 = { | 492 | static struct regulator_init_data sdp4430_vaux1 = { |
537 | .constraints = { | 493 | .constraints = { |
538 | .min_uV = 1000000, | 494 | .min_uV = 1000000, |
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c index 1b782ba53433..c148472a79b4 100644 --- a/arch/arm/mach-omap2/board-omap4panda.c +++ b/arch/arm/mach-omap2/board-omap4panda.c | |||
@@ -236,55 +236,6 @@ struct wl12xx_platform_data omap_panda_wlan_data __initdata = { | |||
236 | .board_ref_clock = 2, | 236 | .board_ref_clock = 2, |
237 | }; | 237 | }; |
238 | 238 | ||
239 | static int omap4_twl6030_hsmmc_late_init(struct device *dev) | ||
240 | { | ||
241 | int irq = 0; | ||
242 | struct platform_device *pdev = container_of(dev, | ||
243 | struct platform_device, dev); | ||
244 | struct omap_mmc_platform_data *pdata = dev->platform_data; | ||
245 | |||
246 | if (!pdata) { | ||
247 | dev_err(dev, "%s: NULL platform data\n", __func__); | ||
248 | return -EINVAL; | ||
249 | } | ||
250 | /* Setting MMC1 Card detect Irq */ | ||
251 | if (pdev->id == 0) { | ||
252 | irq = twl6030_mmc_card_detect_config(); | ||
253 | if (irq < 0) { | ||
254 | dev_err(dev, "%s: Error card detect config(%d)\n", | ||
255 | __func__, irq); | ||
256 | return irq; | ||
257 | } | ||
258 | pdata->slots[0].card_detect = twl6030_mmc_card_detect; | ||
259 | } | ||
260 | return 0; | ||
261 | } | ||
262 | |||
263 | static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev) | ||
264 | { | ||
265 | struct omap_mmc_platform_data *pdata; | ||
266 | |||
267 | /* dev can be null if CONFIG_MMC_OMAP_HS is not set */ | ||
268 | if (!dev) { | ||
269 | pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n"); | ||
270 | return; | ||
271 | } | ||
272 | pdata = dev->platform_data; | ||
273 | |||
274 | pdata->init = omap4_twl6030_hsmmc_late_init; | ||
275 | } | ||
276 | |||
277 | static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers) | ||
278 | { | ||
279 | struct omap2_hsmmc_info *c; | ||
280 | |||
281 | omap_hsmmc_init(controllers); | ||
282 | for (c = controllers; c->mmc; c++) | ||
283 | omap4_twl6030_hsmmc_set_late_init(&c->pdev->dev); | ||
284 | |||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | static struct twl6040_codec_data twl6040_codec = { | 239 | static struct twl6040_codec_data twl6040_codec = { |
289 | /* single-step ramp for headset and handsfree */ | 240 | /* single-step ramp for headset and handsfree */ |
290 | .hs_left_step = 0x0f, | 241 | .hs_left_step = 0x0f, |
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h index 57da7f406e28..c09ca63b8ac8 100644 --- a/arch/arm/mach-omap2/common.h +++ b/arch/arm/mach-omap2/common.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #ifndef __ASSEMBLER__ | 27 | #ifndef __ASSEMBLER__ |
28 | 28 | ||
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/i2c/twl.h> | ||
30 | #include <plat/common.h> | 31 | #include <plat/common.h> |
31 | #include <asm/proc-fns.h> | 32 | #include <asm/proc-fns.h> |
32 | 33 | ||
@@ -254,6 +255,8 @@ static inline u32 omap4_mpuss_read_prev_context_state(void) | |||
254 | struct omap_sdrc_params; | 255 | struct omap_sdrc_params; |
255 | extern void omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0, | 256 | extern void omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0, |
256 | struct omap_sdrc_params *sdrc_cs1); | 257 | struct omap_sdrc_params *sdrc_cs1); |
258 | struct omap2_hsmmc_info; | ||
259 | extern int omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers); | ||
257 | 260 | ||
258 | #endif /* __ASSEMBLER__ */ | 261 | #endif /* __ASSEMBLER__ */ |
259 | #endif /* __ARCH_ARM_MACH_OMAP2PLUS_COMMON_H */ | 262 | #endif /* __ARCH_ARM_MACH_OMAP2PLUS_COMMON_H */ |
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 | ||