From patchwork Wed Oct 22 16:45:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 5135771 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 22CB29F349 for ; Wed, 22 Oct 2014 16:46:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3605020109 for ; Wed, 22 Oct 2014 16:46:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95AC8201F4 for ; Wed, 22 Oct 2014 16:46:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754132AbaJVQqS (ORCPT ); Wed, 22 Oct 2014 12:46:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11800 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754097AbaJVQqM (ORCPT ); Wed, 22 Oct 2014 12:46:12 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9MGjPph005270 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 22 Oct 2014 12:45:25 -0400 Received: from shalem.localdomain.com (vpn1-7-162.ams2.redhat.com [10.36.7.162]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9MGjCnT014356; Wed, 22 Oct 2014 12:45:22 -0400 From: Hans de Goede To: Tomi Valkeinen Cc: Stephen Warren , Jean-Christophe Plagniol-Villard , Grant Likely , Rob Herring , Luc Verhaegen , Maxime Ripard , Mike Turquette , David Herrmann , Geert Uytterhoeven , linux-fbdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree , linux-sunxi@googlegroups.com, Hans de Goede Subject: [PATCH v4 3/5] simplefb: formalize pseudo palette handling Date: Wed, 22 Oct 2014 18:45:09 +0200 Message-Id: <1413996311-4287-4-git-send-email-hdegoede@redhat.com> In-Reply-To: <1413996311-4287-1-git-send-email-hdegoede@redhat.com> References: <1413996311-4287-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Luc Verhaegen Signed-off-by: Luc Verhaegen Acked-by: Stephen Warren [hdegoede@redhat.com: drop unnecessary void * cast] Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede Acked-by: Geert Uytterhoeven Reviewed-by: Maxime Ripard Reviewed-by: David Herrmann Acked-by: Grant Likely --- drivers/video/fbdev/simplefb.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c index 210f3a0..ec112c1 100644 --- a/drivers/video/fbdev/simplefb.c +++ b/drivers/video/fbdev/simplefb.c @@ -41,6 +41,8 @@ static struct fb_var_screeninfo simplefb_var = { .vmode = FB_VMODE_NONINTERLACED, }; +#define PSEUDO_PALETTE_SIZE 16 + static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info) { @@ -50,7 +52,7 @@ static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u32 cb = blue >> (16 - info->var.blue.length); u32 value; - if (regno >= 16) + if (regno >= PSEUDO_PALETTE_SIZE) return -EINVAL; value = (cr << info->var.red.offset) | @@ -163,11 +165,16 @@ static int simplefb_parse_pd(struct platform_device *pdev, return 0; } +struct simplefb_par { + u32 palette[PSEUDO_PALETTE_SIZE]; +}; + static int simplefb_probe(struct platform_device *pdev) { int ret; struct simplefb_params params; struct fb_info *info; + struct simplefb_par *par; struct resource *mem; if (fb_get_options("simplefb", NULL)) @@ -188,11 +195,13 @@ static int simplefb_probe(struct platform_device *pdev) return -EINVAL; } - info = framebuffer_alloc(sizeof(u32) * 16, &pdev->dev); + info = framebuffer_alloc(sizeof(struct simplefb_par), &pdev->dev); if (!info) return -ENOMEM; platform_set_drvdata(pdev, info); + par = info->par; + info->fix = simplefb_fix; info->fix.smem_start = mem->start; info->fix.smem_len = resource_size(mem); @@ -225,7 +234,7 @@ static int simplefb_probe(struct platform_device *pdev) framebuffer_release(info); return -ENODEV; } - info->pseudo_palette = (void *)(info + 1); + info->pseudo_palette = par->palette; dev_info(&pdev->dev, "framebuffer at 0x%lx, 0x%x bytes, mapped to 0x%p\n", info->fix.smem_start, info->fix.smem_len,