From patchwork Fri Mar 22 14:14:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 2320461 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 9B1CEDFE82 for ; Fri, 22 Mar 2013 14:14:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754309Ab3CVOO4 (ORCPT ); Fri, 22 Mar 2013 10:14:56 -0400 Received: from gloria.sntech.de ([95.129.55.99]:40346 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753733Ab3CVOOz (ORCPT ); Fri, 22 Mar 2013 10:14:55 -0400 Received: from 146-52-57-5-dynip.superkabel.de ([146.52.57.5] helo=marty.localnet) by gloria.sntech.de with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1UJ2kA-00081J-MV; Fri, 22 Mar 2013 15:14:54 +0100 From: Heiko =?utf-8?q?St=C3=BCbner?= To: Florian Tobias Schandinat Subject: [PATCH 4/9] AUO-K190x: make memory check in check_var more flexible Date: Fri, 22 Mar 2013 15:14:52 +0100 User-Agent: KMail/1.13.7 (Linux/3.2.0-3-686-pae; KDE/4.8.4; i686; ; ) Cc: Tomi Valkeinen , "linux-fbdev" References: <201303221512.28604.heiko@sntech.de> In-Reply-To: <201303221512.28604.heiko@sntech.de> MIME-Version: 1.0 Message-Id: <201303221514.53235.heiko@sntech.de> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use only information from the new var to calculate the amount of memory needed. Signed-off-by: Heiko Stübner --- drivers/video/auo_k190x.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/video/auo_k190x.c b/drivers/video/auo_k190x.c index 954b781..9cd9b7e 100644 --- a/drivers/video/auo_k190x.c +++ b/drivers/video/auo_k190x.c @@ -375,6 +375,9 @@ static void auok190xfb_imageblit(struct fb_info *info, static int auok190xfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { + struct device *dev = info->device; + int size; + if (info->var.xres != var->xres || info->var.yres != var->yres || info->var.xres_virtual != var->xres_virtual || info->var.yres_virtual != var->yres_virtual) { @@ -387,9 +390,10 @@ static int auok190xfb_check_var(struct fb_var_screeninfo *var, * Memory limit */ - if ((info->fix.line_length * var->yres_virtual) > info->fix.smem_len) { - pr_info("%s: Memory Limit requested yres_virtual = %u\n", - __func__, var->yres_virtual); + size = var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8; + if (size > info->fix.smem_len) { + dev_err(dev, "Memory limit exceeded, requested %dK\n", + size >> 10); return -ENOMEM; }