From patchwork Thu Jul 19 16:19:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 10534907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E5A5F600D0 for ; Thu, 19 Jul 2018 16:19:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ED7A29E69 for ; Thu, 19 Jul 2018 16:19:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8130429E80; Thu, 19 Jul 2018 16:19:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AE8129E69 for ; Thu, 19 Jul 2018 16:19:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731699AbeGSRDi (ORCPT ); Thu, 19 Jul 2018 13:03:38 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:40213 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731690AbeGSRDh (ORCPT ); Thu, 19 Jul 2018 13:03:37 -0400 Received: by mail-wm0-f66.google.com with SMTP id z13-v6so7001762wma.5 for ; Thu, 19 Jul 2018 09:19:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mtoEkUenwKXEVaYbLXYNYms73QdfgGVwiTkvGMMXbUc=; b=h7HCB+TimIpmhToaMwJaEFFBzqR+qNrE9o1oaW0duPE1abrV7PPQPZ6duGld4DAnke FSDCW+uiu/Gg0rxhhYxKBN0L1bCrk4qvROu6rRJwh82SE6tAoAj/dL/aeHfkaebJoK4U xpMckLeth5OMVrl60O0VGUoTh2YpM4CX+I8og= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mtoEkUenwKXEVaYbLXYNYms73QdfgGVwiTkvGMMXbUc=; b=YNwHT2BA7rGoA+wYvD1JI51lJba+ZhdVHyNnk+1EzICoIevO2dYU770kVyT3sJB0Uk iDVHFJBlMucI1u9xzgwvVwDpkq6plFz/7JV6/mi7qjfhL5k4nDD2NDJVrwKcuyRe8K7X KszsxYb67K1ro8pxR1zuLWp/0eXpJpachyowvEqBePPGymeML4XpPXaVIyXYj4NwPg01 +P9r0ZHJUVtVphPmHPRTHzD2VQmuJgckwqAHK705umem5QUi5j7CeESSup2WXUuzxJhG HjeRmh+PKI3BKdeFNCTMjtwjHpNSzAYJtPTLEsTZAtgTGpAuUXTJjpqj1uKer+duKKuC 4v+Q== X-Gm-Message-State: AOUpUlEcnZHXBiKyLzZvzqvYaJ5zW2WFwcftcH0iPMn7c0KQRYaLqhKo Id1uD4zfhtIjc3xw1SiKktH3JA== X-Google-Smtp-Source: AAOMgpfIqTeUDtC/mnpNFU20vWnw+LXi5Tc8gDdWQ9ZjGdUjz1URvCU7vRVr/4wiH79C2QDo++mI8Q== X-Received: by 2002:a1c:90e:: with SMTP id 14-v6mr4753800wmj.130.1532017182509; Thu, 19 Jul 2018 09:19:42 -0700 (PDT) Received: from wychelm.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id r125-v6sm9610361wmb.27.2018.07.19.09.19.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Jul 2018 09:19:41 -0700 (PDT) From: Daniel Thompson To: Lee Jones , Daniel Thompson , Jingoo Han Cc: Thierry Reding , Bartlomiej Zolnierkiewicz , Marcel Ziswiler , linux-pwm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH v2] backlight: pwm_bl: Fix uninitialized variable Date: Thu, 19 Jul 2018 17:19:23 +0100 Message-Id: <20180719161923.21510-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180716210241.9457-1-daniel.thompson@linaro.org> References: <20180716210241.9457-1-daniel.thompson@linaro.org> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, if the DT does not define num-interpolated-steps then num_steps is undefined and the interpolation code will deploy randomly. Fix this. Additionally fix a small grammar error that was identified and tighten up return code checking of DT properties, both of which came up during review of this patch. Fixes: 573fe6d1c25c ("backlight: pwm_bl: Linear interpolation between brightness-levels") Reported-by: Marcel Ziswiler Signed-off-by: Daniel Thompson Tested-by: Marcel Ziswiler --- Notes: v2: - Simplify SoB chain (with Marcel's permission) - Separate complex if statement and make other similar calls use same return code checking approach - Tidy up comment formatting and fix pre-existing grammar error drivers/video/backlight/pwm_bl.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 9ee4c1b735b2..f7799f62fea0 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -284,30 +284,29 @@ static int pwm_backlight_parse_dt(struct device *dev, ret = of_property_read_u32_array(node, "brightness-levels", data->levels, data->max_brightness); - if (ret < 0) + if (!ret) return ret; ret = of_property_read_u32(node, "default-brightness-level", &value); - if (ret < 0) + if (!ret) return ret; data->dft_brightness = value; /* * This property is optional, if is set enables linear - * interpolation between each of the values of brightness levels - * and creates a new pre-computed table. + * interpolation between each of the values of brightness + * levels and creates a new pre-computed table. */ - of_property_read_u32(node, "num-interpolated-steps", - &num_steps); - - /* - * Make sure that there is at least two entries in the - * brightness-levels table, otherwise we can't interpolate - * between two points. - */ - if (num_steps) { + ret = of_property_read_u32(node, "num-interpolated-steps", + &num_steps); + if (!ret || num_steps) { + /* + * Make sure that there are at least two entries in + * the brightness-levels table, otherwise we can't + * interpolate between two points. + */ if (data->max_brightness < 2) { dev_err(dev, "can't interpolate\n"); return -EINVAL;