OMAP: DSS2: OMAPFB: Reduce stack usage
omapfb_mode_to_timings() had struct fb_info, struct fb_var and struct fb_ops allocated from stack. This caused the stack usage grow quite high. Use kzalloc to allocate the structs instead. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
This commit is contained in:
parent
e1d0178901
commit
897044e99e
|
@ -1996,9 +1996,9 @@ static int omapfb_create_framebuffers(struct omapfb2_device *fbdev)
|
||||||
static int omapfb_mode_to_timings(const char *mode_str,
|
static int omapfb_mode_to_timings(const char *mode_str,
|
||||||
struct omap_video_timings *timings, u8 *bpp)
|
struct omap_video_timings *timings, u8 *bpp)
|
||||||
{
|
{
|
||||||
struct fb_info fbi;
|
struct fb_info *fbi;
|
||||||
struct fb_var_screeninfo var;
|
struct fb_var_screeninfo *var;
|
||||||
struct fb_ops fbops;
|
struct fb_ops *fbops;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
#ifdef CONFIG_OMAP2_DSS_VENC
|
#ifdef CONFIG_OMAP2_DSS_VENC
|
||||||
|
@ -2016,39 +2016,66 @@ static int omapfb_mode_to_timings(const char *mode_str,
|
||||||
/* this is quite a hack, but I wanted to use the modedb and for
|
/* this is quite a hack, but I wanted to use the modedb and for
|
||||||
* that we need fb_info and var, so we create dummy ones */
|
* that we need fb_info and var, so we create dummy ones */
|
||||||
|
|
||||||
memset(&fbi, 0, sizeof(fbi));
|
*bpp = 0;
|
||||||
memset(&var, 0, sizeof(var));
|
fbi = NULL;
|
||||||
memset(&fbops, 0, sizeof(fbops));
|
var = NULL;
|
||||||
fbi.fbops = &fbops;
|
fbops = NULL;
|
||||||
|
|
||||||
r = fb_find_mode(&var, &fbi, mode_str, NULL, 0, NULL, 24);
|
fbi = kzalloc(sizeof(*fbi), GFP_KERNEL);
|
||||||
|
if (fbi == NULL) {
|
||||||
if (r != 0) {
|
r = -ENOMEM;
|
||||||
timings->pixel_clock = PICOS2KHZ(var.pixclock);
|
goto err;
|
||||||
timings->hbp = var.left_margin;
|
|
||||||
timings->hfp = var.right_margin;
|
|
||||||
timings->vbp = var.upper_margin;
|
|
||||||
timings->vfp = var.lower_margin;
|
|
||||||
timings->hsw = var.hsync_len;
|
|
||||||
timings->vsw = var.vsync_len;
|
|
||||||
timings->x_res = var.xres;
|
|
||||||
timings->y_res = var.yres;
|
|
||||||
|
|
||||||
switch (var.bits_per_pixel) {
|
|
||||||
case 16:
|
|
||||||
*bpp = 16;
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
case 32:
|
|
||||||
default:
|
|
||||||
*bpp = 24;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var = kzalloc(sizeof(*var), GFP_KERNEL);
|
||||||
|
if (var == NULL) {
|
||||||
|
r = -ENOMEM;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
fbops = kzalloc(sizeof(*fbops), GFP_KERNEL);
|
||||||
|
if (fbops == NULL) {
|
||||||
|
r = -ENOMEM;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
fbi->fbops = fbops;
|
||||||
|
|
||||||
|
r = fb_find_mode(var, fbi, mode_str, NULL, 0, NULL, 24);
|
||||||
|
if (r == 0) {
|
||||||
|
r = -EINVAL;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
timings->pixel_clock = PICOS2KHZ(var->pixclock);
|
||||||
|
timings->hbp = var->left_margin;
|
||||||
|
timings->hfp = var->right_margin;
|
||||||
|
timings->vbp = var->upper_margin;
|
||||||
|
timings->vfp = var->lower_margin;
|
||||||
|
timings->hsw = var->hsync_len;
|
||||||
|
timings->vsw = var->vsync_len;
|
||||||
|
timings->x_res = var->xres;
|
||||||
|
timings->y_res = var->yres;
|
||||||
|
|
||||||
|
switch (var->bits_per_pixel) {
|
||||||
|
case 16:
|
||||||
|
*bpp = 16;
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
case 32:
|
||||||
|
default:
|
||||||
|
*bpp = 24;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = 0;
|
||||||
|
|
||||||
|
err:
|
||||||
|
kfree(fbi);
|
||||||
|
kfree(var);
|
||||||
|
kfree(fbops);
|
||||||
|
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int omapfb_set_def_mode(struct omapfb2_device *fbdev,
|
static int omapfb_set_def_mode(struct omapfb2_device *fbdev,
|
||||||
|
|
Loading…
Reference in New Issue