diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2011-04-30 08:26:40 -0400 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2011-05-12 12:39:52 -0400 |
commit | 897044e99e437e908eef566d910692830546c2d9 (patch) | |
tree | 0c626cc26dc115392f0138cb7e626d04a7983ae7 /drivers/video | |
parent | e1d01789017cf327d63f7748025317763253960b (diff) |
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>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/omap2/omapfb/omapfb-main.c | 95 |
1 files changed, 61 insertions, 34 deletions
diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c index 9a5b4bc81c80..505bc12a3031 100644 --- a/drivers/video/omap2/omapfb/omapfb-main.c +++ b/drivers/video/omap2/omapfb/omapfb-main.c | |||
@@ -1996,9 +1996,9 @@ static int omapfb_create_framebuffers(struct omapfb2_device *fbdev) | |||
1996 | static int omapfb_mode_to_timings(const char *mode_str, | 1996 | static int omapfb_mode_to_timings(const char *mode_str, |
1997 | struct omap_video_timings *timings, u8 *bpp) | 1997 | struct omap_video_timings *timings, u8 *bpp) |
1998 | { | 1998 | { |
1999 | struct fb_info fbi; | 1999 | struct fb_info *fbi; |
2000 | struct fb_var_screeninfo var; | 2000 | struct fb_var_screeninfo *var; |
2001 | struct fb_ops fbops; | 2001 | struct fb_ops *fbops; |
2002 | int r; | 2002 | int r; |
2003 | 2003 | ||
2004 | #ifdef CONFIG_OMAP2_DSS_VENC | 2004 | #ifdef CONFIG_OMAP2_DSS_VENC |
@@ -2016,39 +2016,66 @@ static int omapfb_mode_to_timings(const char *mode_str, | |||
2016 | /* this is quite a hack, but I wanted to use the modedb and for | 2016 | /* this is quite a hack, but I wanted to use the modedb and for |
2017 | * that we need fb_info and var, so we create dummy ones */ | 2017 | * that we need fb_info and var, so we create dummy ones */ |
2018 | 2018 | ||
2019 | memset(&fbi, 0, sizeof(fbi)); | 2019 | *bpp = 0; |
2020 | memset(&var, 0, sizeof(var)); | 2020 | fbi = NULL; |
2021 | memset(&fbops, 0, sizeof(fbops)); | 2021 | var = NULL; |
2022 | fbi.fbops = &fbops; | 2022 | fbops = NULL; |
2023 | |||
2024 | r = fb_find_mode(&var, &fbi, mode_str, NULL, 0, NULL, 24); | ||
2025 | |||
2026 | if (r != 0) { | ||
2027 | timings->pixel_clock = PICOS2KHZ(var.pixclock); | ||
2028 | timings->hbp = var.left_margin; | ||
2029 | timings->hfp = var.right_margin; | ||
2030 | timings->vbp = var.upper_margin; | ||
2031 | timings->vfp = var.lower_margin; | ||
2032 | timings->hsw = var.hsync_len; | ||
2033 | timings->vsw = var.vsync_len; | ||
2034 | timings->x_res = var.xres; | ||
2035 | timings->y_res = var.yres; | ||
2036 | |||
2037 | switch (var.bits_per_pixel) { | ||
2038 | case 16: | ||
2039 | *bpp = 16; | ||
2040 | break; | ||
2041 | case 24: | ||
2042 | case 32: | ||
2043 | default: | ||
2044 | *bpp = 24; | ||
2045 | break; | ||
2046 | } | ||
2047 | 2023 | ||
2048 | return 0; | 2024 | fbi = kzalloc(sizeof(*fbi), GFP_KERNEL); |
2049 | } else { | 2025 | if (fbi == NULL) { |
2050 | return -EINVAL; | 2026 | r = -ENOMEM; |
2027 | goto err; | ||
2028 | } | ||
2029 | |||
2030 | var = kzalloc(sizeof(*var), GFP_KERNEL); | ||
2031 | if (var == NULL) { | ||
2032 | r = -ENOMEM; | ||
2033 | goto err; | ||
2034 | } | ||
2035 | |||
2036 | fbops = kzalloc(sizeof(*fbops), GFP_KERNEL); | ||
2037 | if (fbops == NULL) { | ||
2038 | r = -ENOMEM; | ||
2039 | goto err; | ||
2040 | } | ||
2041 | |||
2042 | fbi->fbops = fbops; | ||
2043 | |||
2044 | r = fb_find_mode(var, fbi, mode_str, NULL, 0, NULL, 24); | ||
2045 | if (r == 0) { | ||
2046 | r = -EINVAL; | ||
2047 | goto err; | ||
2051 | } | 2048 | } |
2049 | |||
2050 | timings->pixel_clock = PICOS2KHZ(var->pixclock); | ||
2051 | timings->hbp = var->left_margin; | ||
2052 | timings->hfp = var->right_margin; | ||
2053 | timings->vbp = var->upper_margin; | ||
2054 | timings->vfp = var->lower_margin; | ||
2055 | timings->hsw = var->hsync_len; | ||
2056 | timings->vsw = var->vsync_len; | ||
2057 | timings->x_res = var->xres; | ||
2058 | timings->y_res = var->yres; | ||
2059 | |||
2060 | switch (var->bits_per_pixel) { | ||
2061 | case 16: | ||
2062 | *bpp = 16; | ||
2063 | break; | ||
2064 | case 24: | ||
2065 | case 32: | ||
2066 | default: | ||
2067 | *bpp = 24; | ||
2068 | break; | ||
2069 | } | ||
2070 | |||
2071 | r = 0; | ||
2072 | |||
2073 | err: | ||
2074 | kfree(fbi); | ||
2075 | kfree(var); | ||
2076 | kfree(fbops); | ||
2077 | |||
2078 | return r; | ||
2052 | } | 2079 | } |
2053 | 2080 | ||
2054 | static int omapfb_set_def_mode(struct omapfb2_device *fbdev, | 2081 | static int omapfb_set_def_mode(struct omapfb2_device *fbdev, |