From patchwork Tue Jan 22 13:39:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 2018741 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 2B86FDF2EB for ; Tue, 22 Jan 2013 13:41:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752752Ab3AVNkY (ORCPT ); Tue, 22 Jan 2013 08:40:24 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:42816 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752265Ab3AVNkV (ORCPT ); Tue, 22 Jan 2013 08:40:21 -0500 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r0MDe2jO004792; Tue, 22 Jan 2013 07:40:02 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0MDe2pJ029781; Tue, 22 Jan 2013 07:40:02 -0600 Received: from dlelxv22.itg.ti.com (172.17.1.197) by dfle73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.1.323.3; Tue, 22 Jan 2013 07:40:01 -0600 Received: from barack.emea.dhcp.ti.com (barack.emea.dhcp.ti.com [137.167.125.64]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0MDdvaU030563; Tue, 22 Jan 2013 07:40:00 -0600 From: Peter Ujfalusi To: Richard Purdie CC: Grant Likely , Rob Landley , Thierry Reding , Florian Tobias Schandinat , Andrew Morton , , , , Subject: [PATCH 1/4] pwm_backlight: Fix PWM levels support in non DT case Date: Tue, 22 Jan 2013 14:39:53 +0100 Message-ID: <1358861996-27194-2-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.8.1.1 In-Reply-To: <1358861996-27194-1-git-send-email-peter.ujfalusi@ti.com> References: <1358861996-27194-1-git-send-email-peter.ujfalusi@ti.com> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org It is expected that board files would have: static unsigned int bl_levels[] = { 0, 50, 100, 150, 200, 250, }; static struct platform_pwm_backlight_data bl_data = { .levels = bl_levels, .max_brightness = ARRAY_SIZE(bl_levels), .dft_brightness = 4, .pwm_period_ns = 7812500, }; In this case the max_brightness would be out of range in the levels array. Decrement the received max_brightness in every case (DT or non DT) when the levels has been provided. Signed-off-by: Peter Ujfalusi --- drivers/video/backlight/pwm_bl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 069983c..f0d6854 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -142,7 +142,6 @@ static int pwm_backlight_parse_dt(struct device *dev, } data->dft_brightness = value; - data->max_brightness--; } /* @@ -202,6 +201,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) } if (data->levels) { + data->max_brightness--; max = data->levels[data->max_brightness]; pb->levels = data->levels; } else