From patchwork Sun Sep 28 12:43:36 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: 4991701 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6D33ABEEA7 for ; Sun, 28 Sep 2014 12:44:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9620620251 for ; Sun, 28 Sep 2014 12:44:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B727F20256 for ; Sun, 28 Sep 2014 12:44:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753903AbaI1MoT (ORCPT ); Sun, 28 Sep 2014 08:44:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53913 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753926AbaI1MoR (ORCPT ); Sun, 28 Sep 2014 08:44:17 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8SChj7F027831 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 28 Sep 2014 08:43:46 -0400 Received: from shalem.localdomain.com (vpn1-4-237.ams2.redhat.com [10.36.4.237]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8SChdal014107; Sun, 28 Sep 2014 08:43:43 -0400 From: Hans de Goede To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen , Grant Likely , Rob Herring Cc: Luc Verhaegen , Maxime Ripard , Mike Turquette , linux-fbdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree , linux-sunxi@googlegroups.com, Hans de Goede Subject: [PATCH 2/4] simplefb: formalize pseudo palette handling Date: Sun, 28 Sep 2014 14:43:36 +0200 Message-Id: <1411908218-20947-2-git-send-email-hdegoede@redhat.com> In-Reply-To: <1411908218-20947-1-git-send-email-hdegoede@redhat.com> References: <1411908218-20947-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.5 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 [hdegoede@redhat.com: drop unnecessary void * cast] Signed-off-by: Hans de Goede --- 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,