From patchwork Tue Jan 22 13:39:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 2018761 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 701D2DF2EB for ; Tue, 22 Jan 2013 13:42:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751748Ab3AVNlr (ORCPT ); Tue, 22 Jan 2013 08:41:47 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:42821 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752670Ab3AVNkX (ORCPT ); Tue, 22 Jan 2013 08:40:23 -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 r0MDe4Hc004800; Tue, 22 Jan 2013 07:40:04 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0MDe4Mx029947; Tue, 22 Jan 2013 07:40:04 -0600 Received: from dlelxv22.itg.ti.com (172.17.1.197) by dfle72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.1.323.3; Tue, 22 Jan 2013 07:40:03 -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 r0MDdvaV030563; Tue, 22 Jan 2013 07:40:02 -0600 From: Peter Ujfalusi To: Richard Purdie CC: Grant Likely , Rob Landley , Thierry Reding , Florian Tobias Schandinat , Andrew Morton , , , , Subject: [PATCH 2/4] pwm_backlight: Validate dft_brightness in main probe function Date: Tue, 22 Jan 2013 14:39:54 +0100 Message-ID: <1358861996-27194-3-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 Move the dft_brightness validity check from the DT parsing function to the main probe. In this way we can validate it in case we are booting with or without DT. Signed-off-by: Peter Ujfalusi --- drivers/video/backlight/pwm_bl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index f0d6854..2a81c24 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -135,12 +135,6 @@ static int pwm_backlight_parse_dt(struct device *dev, if (ret < 0) return ret; - if (value >= data->max_brightness) { - dev_warn(dev, "invalid default brightness level: %u, using %u\n", - value, data->max_brightness - 1); - value = data->max_brightness - 1; - } - data->dft_brightness = value; } @@ -249,6 +243,12 @@ static int pwm_backlight_probe(struct platform_device *pdev) goto err_alloc; } + if (data->dft_brightness > data->max_brightness) { + dev_warn(&pdev->dev, + "invalid default brightness level: %u, using %u\n", + data->dft_brightness, data->max_brightness); + data->dft_brightness = data->max_brightness; + } bl->props.brightness = data->dft_brightness; backlight_update_status(bl);