From patchwork Tue May 10 16:24:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 774892 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4AGOkgQ001464 for ; Tue, 10 May 2011 16:24:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932995Ab1EJQYp (ORCPT ); Tue, 10 May 2011 12:24:45 -0400 Received: from na3sys009aog115.obsmtp.com ([74.125.149.238]:49329 "EHLO na3sys009aog115.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932986Ab1EJQYo (ORCPT ); Tue, 10 May 2011 12:24:44 -0400 Received: from mail-ew0-f49.google.com ([209.85.215.49]) (using TLSv1) by na3sys009aob115.postini.com ([74.125.148.12]) with SMTP ID DSNKTclmyzaMA8463uIZASP/XMAx+I5KOIPN@postini.com; Tue, 10 May 2011 09:24:44 PDT Received: by mail-ew0-f49.google.com with SMTP id 3so2140134ewy.8 for ; Tue, 10 May 2011 09:24:43 -0700 (PDT) Received: by 10.213.26.82 with SMTP id d18mr2952486ebc.123.1305044682772; Tue, 10 May 2011 09:24:42 -0700 (PDT) Received: from localhost.localdomain (a62-248-131-233.elisa-laajakaista.fi [62.248.131.233]) by mx.google.com with ESMTPS id s1sm4430927ees.17.2011.05.10.09.24.40 (version=SSLv3 cipher=OTHER); Tue, 10 May 2011 09:24:41 -0700 (PDT) From: Tomi Valkeinen To: linux-omap@vger.kernel.org, linux-fbdev@vger.kernel.org Cc: Tomi Valkeinen Subject: [PATCH 8/8] OMAP: DSS2: OMAPFB: Reduce stack usage Date: Tue, 10 May 2011 19:24:16 +0300 Message-Id: <1305044656-31512-9-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1305044656-31512-1-git-send-email-tomi.valkeinen@ti.com> References: <1305044656-31512-1-git-send-email-tomi.valkeinen@ti.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 10 May 2011 16:24:46 +0000 (UTC) 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 --- drivers/video/omap2/omapfb/omapfb-main.c | 49 +++++++++++++++++------------- 1 files changed, 28 insertions(+), 21 deletions(-) diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c index 30c958b..ae3e2be 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) static int omapfb_mode_to_timings(const char *mode_str, struct omap_video_timings *timings, u8 *bpp) { - struct fb_info fbi; - struct fb_var_screeninfo var; - struct fb_ops fbops; + struct fb_info *fbi; + struct fb_var_screeninfo *var; + struct fb_ops *fbops; int r; #ifdef CONFIG_OMAP2_DSS_VENC @@ -2016,25 +2016,25 @@ static int omapfb_mode_to_timings(const char *mode_str, /* 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 */ - memset(&fbi, 0, sizeof(fbi)); - memset(&var, 0, sizeof(var)); - memset(&fbops, 0, sizeof(fbops)); - fbi.fbops = &fbops; + fbi = kzalloc(sizeof(*fbi), GFP_KERNEL); + var = kzalloc(sizeof(*var), GFP_KERNEL); + fbops = kzalloc(sizeof(*fbops), GFP_KERNEL); + fbi->fbops = fbops; - r = fb_find_mode(&var, &fbi, mode_str, NULL, 0, NULL, 24); + r = fb_find_mode(var, fbi, mode_str, NULL, 0, NULL, 24); if (r != 0) { - 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) { + 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; @@ -2045,10 +2045,17 @@ static int omapfb_mode_to_timings(const char *mode_str, break; } - return 0; + r = 0; } else { - return -EINVAL; + *bpp = 0; + r = -EINVAL; } + + kfree(fbi); + kfree(var); + kfree(fbops); + + return r; } static int omapfb_set_def_mode(struct omapfb2_device *fbdev,