Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10912893rwr; Fri, 12 May 2023 15:14:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6s5/pZUI/oqB0iGPq87Eo0Av4FYlnLN0W1aq3oVMP/aYYHztMdvvg+ntP3uqWK/cQgSA5s X-Received: by 2002:a17:90b:1e0c:b0:23b:3699:b8a9 with SMTP id pg12-20020a17090b1e0c00b0023b3699b8a9mr26233033pjb.17.1683929695320; Fri, 12 May 2023 15:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683929695; cv=none; d=google.com; s=arc-20160816; b=QBSyBUbONORUfa8zmawfHqBnpfgaC06lnD/lFA5S+NhedPvrCdhoULfmpSPRZvTKrM AJWvxCSGU9KPKnY5c4dcQZyV1XCoFLcNGtLUAV9/QOezFXx10q5XDgNK7L0Dxo0vbjmB cgVyMx77a0SXP/PP8ClIYZQznuYmyIdyaeItC6rnIuhp2SP3H/kdpPW4i2f86zh5zsdb m4hxagLVyXER+nuWPVSCz6DnOMEHgQ89NyLw/2dqTEyNJLVrdENkprYhmg+qJyYgPvXf wjPbooWJw6femdC8U71wDBB+TfQwIKvdsfJfUkzILZ58fCxZ/Ycu7SsP9api4W8O3dLu WTjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=pwTZNtrI+YiOy4giDbSjOeuRPc624jlpa4MZRhVR2oc=; b=uxgex1OgGGUNFq0KPW1uZFwSISTatjtB26PnFKjTYLaL3JDTZlSlnt2TGcb6Y/ilIP AdegM2uk1/g6SF3wIA8Ppr38nd3ZVyBvpU89RgsbQgGOCjrwXrYnlUGrefG0h0ShqbhO iyUyJQ/tpnP8fALB5COpFH+pLv5zEGcvktBmhsafjckN2N49Q7ozy2BCXP4HGqHWlFh/ fvBXHwxi9G7DvtKptFyPzwE56h1+VMa0L2IXjfEAYom4iNz0mVAaPfywh4GptOgAOn3I mU3rvjHp44GqU5/njx5oN+vqrsEyi4jyDcn3hIl5OnBG3JsUmvx6hWs7UIpqHT6zQ8P4 /jsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kali.org header.s=google header.b=NOUXQkex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kali.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lw17-20020a17090b181100b002505b83307dsi16639764pjb.171.2023.05.12.15.14.43; Fri, 12 May 2023 15:14:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kali.org header.s=google header.b=NOUXQkex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kali.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239874AbjELWFe (ORCPT + 99 others); Fri, 12 May 2023 18:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238617AbjELWFd (ORCPT ); Fri, 12 May 2023 18:05:33 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C57D21BD8 for ; Fri, 12 May 2023 15:05:31 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-96aae59bbd6so213325866b.3 for ; Fri, 12 May 2023 15:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kali.org; s=google; t=1683929130; x=1686521130; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pwTZNtrI+YiOy4giDbSjOeuRPc624jlpa4MZRhVR2oc=; b=NOUXQkexeahKAlXM0a2wPcqC1kMBChCsFbOiTkWCx0Gtll9MJrvr9cIyD+eQcCnnox uPKuJcnqQd6I6gzjOh0ZJrSOlPMmN8rkhYwdMsq50zSnrPRtTLzfqoZPY5g3XNxVRHUK 0M2kiFNZGTh6PHpeY75y/23/w7Ct6mRH0CwvnQie7spUJ6u5jXTRBJtk4m/8Z0NM8xxR kvDGVvE3Vl7+XFT/o8lYadhEquOLrGLxfIDEf7vfEuN8epxZhW7JaeLvm2U92ebPyv9f mC4oYEAJN2Q/nqynAaiXOvPXQv2nFXqxPEQPW5l+mhOX9lSjmHB50Hb2zLpxjHhykJpf IJAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683929130; x=1686521130; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pwTZNtrI+YiOy4giDbSjOeuRPc624jlpa4MZRhVR2oc=; b=IQt3ofIeqpg9d1qwbtjQWY4tYEsIRWSwDdpgpSZ44MOmR2gsN82e/e/KlwXzJj5xIv zhDzkd3tHC1D5sBcuMT/q7PxHA7SQJtug0uF/yPEY12j32k94KlU7U51IIzz/sLNADIi yihvKnTYlFSPn2b03Ns0TgNz3ScUUv6v/mFb3uhs8+tTk6uz5sqLroEB155TQdOEy32w 5i2KR5/FDUkKjQgqZ2meZEG5AxA2hMdb4WFiS9GH9ItNZ2OKnNYoOtKRdMN3jj5RxkWt HYr7T72/rOV1EIywlC1X1eWbk5sGiayf0kPzFrbP7AEuf/75yeK0lYQPkXeY6r7cu9zW On/w== X-Gm-Message-State: AC+VfDzn2hNII+xgN3yLRHsGOvPJUVfbcPh10FkRwInE+x/HAajdPGQ4 YDMw1gQEeIv19394u1BDSHaDrAqWL1yI9ttWSEg2CA== X-Received: by 2002:a17:907:84a:b0:94e:bc04:c6f6 with SMTP id ww10-20020a170907084a00b0094ebc04c6f6mr22229644ejb.9.1683929130319; Fri, 12 May 2023 15:05:30 -0700 (PDT) MIME-Version: 1.0 References: <20230512165524.3367443-1-quic_bjorande@quicinc.com> In-Reply-To: <20230512165524.3367443-1-quic_bjorande@quicinc.com> From: Steev Klimaszewski Date: Fri, 12 May 2023 17:05:19 -0500 Message-ID: Subject: Re: [PATCH] leds: qcom-lpg: Fix PWM period limits To: Bjorn Andersson Cc: Pavel Machek , Lee Jones , Anjelique Melendez , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Luca Weiss , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 12, 2023 at 11:55=E2=80=AFAM Bjorn Andersson wrote: > > The introduction of high resolution PWM support moved the parenthesis of > the divisions in the calculation of min and max period. The result in > both divisions is in most cases truncation to 0, which limits the period > to the range of [0, 0]. > > Both numerators (and denominators) are within 64 bits, so the whole > expression can be put directly into the div64_u64, instead of doing it > partially. > > Fixes: b00d2ed37617 ("leds: rgb: leds-qcom-lpg: Add support for high reso= lution PWM") > Signed-off-by: Bjorn Andersson > --- > > This fixes the regression in v6.4-rc1. > > drivers/leds/rgb/leds-qcom-lpg.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qco= m-lpg.c > index c9cea797a697..7287fadc00df 100644 > --- a/drivers/leds/rgb/leds-qcom-lpg.c > +++ b/drivers/leds/rgb/leds-qcom-lpg.c > @@ -312,14 +312,14 @@ static int lpg_calc_freq(struct lpg_channel *chan, = uint64_t period) > max_res =3D LPG_RESOLUTION_9BIT; > } > > - min_period =3D (u64)NSEC_PER_SEC * > - div64_u64((1 << pwm_resolution_arr[0]), clk_rate_= arr[clk_len - 1]); > + min_period =3D div64_u64((u64)NSEC_PER_SEC * (1 << pwm_resolution= _arr[0]), > + clk_rate_arr[clk_len - 1]); > if (period <=3D min_period) > return -EINVAL; > > /* Limit period to largest possible value, to avoid overflows */ > - max_period =3D (u64)NSEC_PER_SEC * max_res * LPG_MAX_PREDIV * > - div64_u64((1 << LPG_MAX_M), 1024); > + max_period =3D div64_u64((u64)NSEC_PER_SEC * max_res * LPG_MAX_PR= EDIV * (1 << LPG_MAX_M), > + 1024); > if (period > max_period) > period =3D max_period; > > -- > 2.25.1 > Thank you! Without this fix, the display never activates on the Thinkpad X13s Tested on the Lenovo Thinkpad X13s Tested-by: Steev Klimaszewski