Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3721433imm; Sat, 25 Aug 2018 01:07:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY2alhRvrbeBPwfiOJVj4TAVE1klBezEzmDZhXTkchljiFcYNd75Ju4P9z+htkznwBiOaQ8 X-Received: by 2002:a65:5c83:: with SMTP id a3-v6mr4968045pgt.164.1535184433101; Sat, 25 Aug 2018 01:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535184433; cv=none; d=google.com; s=arc-20160816; b=halih9DyqnGv3DvJ9dYCa+ADvFqT20TdlNUF/cGsidQbImrJw0MOnEnTIB99UQl9VS 1kx34AKo5avIs+TLKmB7lQjaxVl38OtdfmB+xp/ocmbI/wiJh4x1jpsACdl20T/BrLOh ytSmhBB5E6c5G717slRRPFjQBqLVzfOXkd+rdlp3GTvMOCyssGYXS7s36y3E8IT4WMsZ n/GyMUK0V+uttIdol7So481zxkTHhrR0pbumEw8bFQl0OPDY9HGtb2ZTdBSxWDH0BQOI X610naMukS1K3TqKSxO4ABiVHa0irGq3SG7qpB7yqkPPn+A567pXcJm0NL3q8P5svG0S NNwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=pafKO23HVIzg64hSoH9a2oKk2roCo6q6bvHZ2raQeNM=; b=SlkDei4avj5aAO+JA+qyNxeRyX3vCa7ibnJJ77fEOpq8GGaU+/wJfKbZd3sqna6AvQ IMgolBA4lKZf5WGa8BqiGHFkSlccvh3Y/giJnmvOEQjc46/ro3S/QtDs43gvcGazY7Ik i8JSB8yf/9e9lNgRLVHNqD/YfXi7QVPgZkCPiWVhjsyrCC1PSTSv0/mDMLULZNnj06dz a/PuGuVnFtgELMbXLt6Fr5DqKW7dlXzmzWn1axDA4IWBYPqqIfN3MeiFFLcNWtJxGtoz 8JpOX05KaYeVVmaRPvqKelWm9EBNKMBq9QBKp1hFeA/6xifjvFYaXtEDf9YBKCO2cquZ ipSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k130-v6si10065377pfc.282.2018.08.25.01.06.55; Sat, 25 Aug 2018 01:07:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727027AbeHYLm2 (ORCPT + 99 others); Sat, 25 Aug 2018 07:42:28 -0400 Received: from smtp06.smtpout.orange.fr ([80.12.242.128]:29851 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726412AbeHYLm2 (ORCPT ); Sat, 25 Aug 2018 07:42:28 -0400 Received: from belgarion ([90.89.234.36]) by mwinf5d41 with ME id TL4B1y0020nnJME03L4BRP; Sat, 25 Aug 2018 10:04:17 +0200 X-ME-Helo: belgarion X-ME-Auth: amFyem1pay5yb2JlcnRAb3JhbmdlLmZy X-ME-Date: Sat, 25 Aug 2018 10:04:17 +0200 X-ME-IP: 90.89.234.36 From: Robert Jarzmik To: Enric Balletbo i Serra Cc: linux-kernel@vger.kernel.org, daniel.thompson@linaro.org, lee.jones@linaro.org, kernel@collabora.com, heiko@sntech.de, linux-pwm@vger.kernel.org, linux-fbdev@vger.kernel.org, Thierry Reding , Bartlomiej Zolnierkiewicz , dri-devel@lists.freedesktop.org, Jingoo Han Subject: Re: [PATCH] backlight: pwm_bl: Fix brightness levels for non-DT case. References: <20180824155402.2822-1-enric.balletbo@collabora.com> X-URL: http://belgarath.falguerolles.org/ Date: Sat, 25 Aug 2018 10:04:10 +0200 In-Reply-To: <20180824155402.2822-1-enric.balletbo@collabora.com> (Enric Balletbo i. Serra's message of "Fri, 24 Aug 2018 17:54:02 +0200") Message-ID: <87h8ji98jp.fsf@belgarion.home> User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enric Balletbo i Serra writes: > Commit '88ba95bedb79 ("backlight: pwm_bl: Compute brightness of LED > linearly to human eye")' allows the possibility to compute a default > brightness table when there isn't the brightness-levels property in the > DT. Unfortunately the changes made broke the pwm backlight for the > non-DT boards. > > Usually, the non-DT boards don't pass the brightness levels via platform > data, instead, they set the max_brightness in their platform data and the > driver calculates the level without a table. The ofending patch assumed > that when there is no brightness levels table we should create one, but this > is clearly wrong for the non-DT case. > > After this patch the code handles the DT and the non-DT case taking in > consideration also if max_brightness is set or not. The default table is > only created when neither, brightness-levels and max_brightness, are > set. > > The patch also fixes another issue found by Robert. Before this patch > looks like a division by 0 was possible when state.period returned 0 by > pwm_get_state(). This is because pwm_get_state() was called before > pwm_apply_args() so state.period was not initialized. The patch moves > the pwm_apply_args() call before any call to pwm_get_state(). > > Fixes: '88ba95bedb79 ("backlight: pwm_bl: Compute brightness of LED linearly to human eye")' > Reported-by: Robert Jarzmik > Signed-off-by: Enric Balletbo i Serra Tested-by: Robert Jarzmik Cheers. -- Robert