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/board-omap4panda.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/board-omap4panda.c')
-rw-r--r-- | arch/arm/mach-omap2/board-omap4panda.c | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c index 1b782ba5343..c148472a79b 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, |