From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030439AbdAIM7w (ORCPT ); Mon, 9 Jan 2017 07:59:52 -0500 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:41477 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030291AbdAIM7t (ORCPT ); Mon, 9 Jan 2017 07:59:49 -0500 Date: Mon, 9 Jan 2017 13:59:42 +0100 From: Sascha Hauer To: Martin Kaiser Cc: b.zolnierkie@samsung.com, kernel@pengutronix.de, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] video: imxfb: always allocate 256 entries for the color map Message-ID: <20170109125942.tk6iutwdnzzxysix@pengutronix.de> References: <1483395604-6931-1-git-send-email-martin@kaiser.cx> <1483395842-9675-1-git-send-email-martin@kaiser.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1483395842-9675-1-git-send-email-martin@kaiser.cx> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 13:58:51 up 17 days, 21:17, 30 users, load average: 0.05, 0.02, 0.00 User-Agent: Mutt/1.6.2-neo (2016-06-11) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 02, 2017 at 11:24:02PM +0100, Martin Kaiser wrote: > The current code calculates the number of color map entries as > 1 << info->var.bits_per_pixel. For 32bpp modes, 1 << 32 is 0 when > written to an int variable. As a consequence, the subsequent copying > of the default (non-empty) color map into our newly allocated color map > fails and imxfb's probe function returns an error. > > On both imx1 and imx21 platforms, the color map is used only for modes > with <= 8bpp. By allocating 256 entries for the color map, we're on the > safe side. > > Signed-off-by: Martin Kaiser Acked-by: Sascha Hauer Sascha > --- > Re-sending: corrected a typo in the LKML address, sorry for that. > > drivers/video/fbdev/imxfb.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c > index fe0c4ee..1b0faad 100644 > --- a/drivers/video/fbdev/imxfb.c > +++ b/drivers/video/fbdev/imxfb.c > @@ -985,7 +985,11 @@ static int imxfb_probe(struct platform_device *pdev) > */ > imxfb_check_var(&info->var, info); > > - ret = fb_alloc_cmap(&info->cmap, 1 << info->var.bits_per_pixel, 0); > + /* > + * For modes > 8bpp, the color map is bypassed. > + * Therefore, 256 entries are enough. > + */ > + ret = fb_alloc_cmap(&info->cmap, 256, 0); > if (ret < 0) > goto failed_cmap; > > -- > 1.7.10.4 > > > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |