From patchwork Tue Jan 22 13:39:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 2018721 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id F02E340E35 for ; Tue, 22 Jan 2013 13:41:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753295Ab3AVNks (ORCPT ); Tue, 22 Jan 2013 08:40:48 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:33719 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753079Ab3AVNk2 (ORCPT ); Tue, 22 Jan 2013 08:40:28 -0500 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r0MDe6md003544; Tue, 22 Jan 2013 07:40:06 -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 r0MDe65l030017; Tue, 22 Jan 2013 07:40:06 -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:05 -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 r0MDdvaW030563; Tue, 22 Jan 2013 07:40:04 -0600 From: Peter Ujfalusi To: Richard Purdie CC: Grant Likely , Rob Landley , Thierry Reding , Florian Tobias Schandinat , Andrew Morton , , , , Subject: [PATCH 3/4] pwm_backlight: Refactor the DT parsing code Date: Tue, 22 Jan 2013 14:39:55 +0100 Message-ID: <1358861996-27194-4-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 In preparation to support the whole range of the PWM device in a similar way it is possible when we boot in legacy mode (non DT mode). Signed-off-by: Peter Ujfalusi --- drivers/video/backlight/pwm_bl.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 2a81c24..df2d115 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -100,7 +100,7 @@ static int pwm_backlight_parse_dt(struct device *dev, { struct device_node *node = dev->of_node; struct property *prop; - int length; + int num_levels = 0; u32 value; int ret; @@ -110,26 +110,27 @@ static int pwm_backlight_parse_dt(struct device *dev, memset(data, 0, sizeof(*data)); /* determine the number of brightness levels */ - prop = of_find_property(node, "brightness-levels", &length); + prop = of_find_property(node, "brightness-levels", &num_levels); if (!prop) return -EINVAL; - data->max_brightness = length / sizeof(u32); + num_levels /= sizeof(u32); /* read brightness levels from DT property */ - if (data->max_brightness > 0) { - size_t size = sizeof(*data->levels) * data->max_brightness; + if (num_levels > 0) { + size_t size = sizeof(*data->levels) * num_levels; data->levels = devm_kzalloc(dev, size, GFP_KERNEL); if (!data->levels) return -ENOMEM; ret = of_property_read_u32_array(node, "brightness-levels", - data->levels, - data->max_brightness); + data->levels, num_levels); if (ret < 0) return ret; + data->max_brightness = num_levels; + ret = of_property_read_u32(node, "default-brightness-level", &value); if (ret < 0)