summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2015-05-11 08:28:52 +0200
committerStefan Agner <stefan.agner@toradex.com>2015-05-11 08:28:52 +0200
commita800d84c63fce033e3c1ca02e11f60c63850641e (patch)
tree06719ff6af7a63865629e5a0dc41d8e205cb917f
parent3974fc382adcc18c49228506bf256a7eaa211b06 (diff)
video: dcu: fixup memory correct even without framebuffer
When there is no framebuffer allocated, e.g. no video environment variable or an error during initialization, the framebuffer location ends up to be NULL, in which case the fixup function calculates a bogus memory size. Use the framebuffer size to make sure that memory size is calculated right in any case.
-rw-r--r--drivers/video/fsl_dcu_fb.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/video/fsl_dcu_fb.c b/drivers/video/fsl_dcu_fb.c
index 4ee823e1d3..e7e385a2ed 100644
--- a/drivers/video/fsl_dcu_fb.c
+++ b/drivers/video/fsl_dcu_fb.c
@@ -307,8 +307,10 @@ int fsl_dcu_init(unsigned int xres, unsigned int yres,
info.screen_size =
info.var.xres * info.var.yres * (info.var.bits_per_pixel / 8);
- if (info.screen_size > CONFIG_FSL_DCU_MAX_FB_SIZE)
+ if (info.screen_size > CONFIG_FSL_DCU_MAX_FB_SIZE) {
+ info.screen_size = 0;
return -ENOMEM;
+ }
/* Reserve framebuffer at the end of memory */
gd->fb_base = gd->bd->bi_dram[0].start +
@@ -444,7 +446,7 @@ int fsl_dcu_fixedfb_setup(void *blob)
int ret;
start = gd->bd->bi_dram[0].start;
- size = gd->fb_base - gd->bd->bi_dram[0].start;
+ size = gd->bd->bi_dram[0].size - info.screen_size;
/*
* Align size on section size (1 MiB). The Linux kernel would crash