diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2012-10-15 05:48:11 -0400 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2012-10-18 06:11:10 -0400 |
commit | 78e7f256b207aba4bc0bcd9ba55e472dab87afc8 (patch) | |
tree | 981be01ae89d6635baf711c701c99eae485f0e92 | |
parent | 7a992d3ebdd752eb0bf9d7e64788c509d586549d (diff) |
OMAPDSS: DSI: fix dsi_get_dsidev_from_id()
If dsi_get_dsidev_from_id() is called with a DSI module id that does not
exist on the board, the function will crash as omap_dss_get_output()
will return NULL.
This happens on omap3 boards when dumping DSI clocks, as the dumping
code will try to get the dsidev for DSI modules 0 and 1, but omap3 only
has DSI module 0.
Also clean up the id -> output mapping, so that if the function is
called with invalid module ID it will return NULL.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Archit Taneja <archit@ti.com>
-rw-r--r-- | drivers/video/omap2/dss/dsi.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c index af07ec6a83bd..7d0db2bf2fc6 100644 --- a/drivers/video/omap2/dss/dsi.c +++ b/drivers/video/omap2/dss/dsi.c | |||
@@ -364,11 +364,20 @@ struct platform_device *dsi_get_dsidev_from_id(int module) | |||
364 | struct omap_dss_output *out; | 364 | struct omap_dss_output *out; |
365 | enum omap_dss_output_id id; | 365 | enum omap_dss_output_id id; |
366 | 366 | ||
367 | id = module == 0 ? OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2; | 367 | switch (module) { |
368 | case 0: | ||
369 | id = OMAP_DSS_OUTPUT_DSI1; | ||
370 | break; | ||
371 | case 1: | ||
372 | id = OMAP_DSS_OUTPUT_DSI2; | ||
373 | break; | ||
374 | default: | ||
375 | return NULL; | ||
376 | } | ||
368 | 377 | ||
369 | out = omap_dss_get_output(id); | 378 | out = omap_dss_get_output(id); |
370 | 379 | ||
371 | return out->pdev; | 380 | return out ? out->pdev : NULL; |
372 | } | 381 | } |
373 | 382 | ||
374 | static inline void dsi_write_reg(struct platform_device *dsidev, | 383 | static inline void dsi_write_reg(struct platform_device *dsidev, |