Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp351662imw; Thu, 14 Jul 2022 02:31:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v2f55dsf3XqxTsVR0E+yUahPHNF0mLSRKmKXESGyVvEn4S69ORrhfqxVLervtD6RsCT/yg X-Received: by 2002:a05:6402:28c4:b0:43a:cdde:e047 with SMTP id ef4-20020a05640228c400b0043acddee047mr10856213edb.368.1657791094891; Thu, 14 Jul 2022 02:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657791094; cv=none; d=google.com; s=arc-20160816; b=Dk0mjhT4OjWaPf+neJIl5RDTvu2j2AIci4Lixv6b5HY1mLyUKJNc6+Xg9KufHk/9Ph 8ZshTR2JsoPDGbxxn8LHWUg9mUMKHzEkJFGvJ+VqwG9+Uf3rFRkoPgu3CS5owaM4v8uM lIeIEdU9GSeaoTkkUZ3a8tqC77moeB/Nxyn+qyf2F49skj1jAoUoTyf4OnZdYEnO8Xho BWIiL8AgaBJYcea7/2g5X6vx5lPdiQCGmkrF23w3xRL0FTB9kjiY+FQIs1K+M6+l4Ww4 uvqAOlQPmDQfacLbRIF9RaxqZU4g6Qeq66MPpExxVx7bVtDHsdzOcwtuNWAmF03oHAkM C26w== 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=eoEUqCQ0HzWcRS/EEisE9qpbq5xcTJ7+l4FqGraIDiM=; b=YTzcu/ityji7OPkMO/yKOI1SBCR0BM2ufAAYl7D2sWfx4EOXyqGOeF0l9RKuVFLDOC Q7QLKQaKuBureC6jjTcEupWWiNkAThy9UE0w/PDN2AED9C2PrdE3Ttuy+yhVMWpdbmms woGycTOelvYd9/b0PMp8YFZPEUWdvO5jh2PPnLufnMNxeI0NWxuqRFZdE8EiFDzBQIgH Rqyu2Z93+f5uSu2bMva3PowlZQB/R5ha2WV9Ob9Bu9rbiRq0TZSJu8bortm/aY9jdA57 KYtrlJWClev74m3GLJ+QYlonLIocN4TETnjwrSDgr45g8DcDTfbz/uu2GFRnU4aLvs74 8CnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ld+ADuIc; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u3-20020a1709060b0300b00726be208896si909722ejg.973.2022.07.14.02.31.10; Thu, 14 Jul 2022 02:31:34 -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=@gmail.com header.s=20210112 header.b=Ld+ADuIc; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238050AbiGNJ2t (ORCPT + 99 others); Thu, 14 Jul 2022 05:28:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231220AbiGNJ20 (ORCPT ); Thu, 14 Jul 2022 05:28:26 -0400 Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A3022C666; Thu, 14 Jul 2022 02:27:45 -0700 (PDT) Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-31d7db3e6e5so10752277b3.11; Thu, 14 Jul 2022 02:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=eoEUqCQ0HzWcRS/EEisE9qpbq5xcTJ7+l4FqGraIDiM=; b=Ld+ADuIcLOILCqHSVmutQbx0yNCzFYK+d1CfgjosNRjzv4la0za1LrNxPVbXKyGrBU plEeNvs9LuKtBpdK2m8TdIf5+YpouBnaZ9Vsy9DWCZQPgh7oBlkDpas1TKNSR2vAuZ/m ORq+hpDzjNbMh57lvUku8daA4iIIz1ZvXj/KjuJUO8f4GYx3HxMDS3SJKg0sxPO5bA1n KdTdyIG7yt7UXNPxNXnsFgVEMla/Hw7WsDWj9pGpxJIEBu4dM2YsIkBZZHbP1tv7Iw1s /UceXFWGcqnbfJelCGnMi9F2w99ZJ8EasltdyIOX+aD94fVjhuHVUAYCDxWNBrPm1xlZ NyrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=eoEUqCQ0HzWcRS/EEisE9qpbq5xcTJ7+l4FqGraIDiM=; b=E4tvnZILOXCcRDzTvq7MkhVAeunrJYCn7/BCiAjX3twkqYrczkm7nwD/MzgagOv4VY wyLIbtIebU8BMG0vP9au76ByBj5i4J6pNx0y+aiKOk2H1LM4YOWqKNYv12WF+97pOgtO zdBK7d4kbHke0DviCwLC5p1oJluSENyZazKdt6l45qSDGpbM6W6pPPx0wcRSjEhhGSuF JUyd8W4pZNXrh3rkTYhzGw4BifxUw1pqzuwHgu+wAQQF1VUGTV/31i6FT1yKq5yBdEfc I60wxm8XjdzUr5hkIuv0eGEa6qOLAxt6TEnD6h/cMXZNZcUaad3AVYIE66Hf2gV7sjrd JM5A== X-Gm-Message-State: AJIora+W4OO7HknhU7CFgQWzvIiFWG6i7HJWfFCYB1OFvfBOCXUeYFIf lduDnzWFV5B4tUJypqeSRtwqPVGUfmwvtLJ5Do0= X-Received: by 2002:a81:72c4:0:b0:31c:b309:c4e8 with SMTP id n187-20020a8172c4000000b0031cb309c4e8mr8841348ywc.520.1657790864413; Thu, 14 Jul 2022 02:27:44 -0700 (PDT) MIME-Version: 1.0 References: <20220704053901.728-1-peterwu.pub@gmail.com> <20220704053901.728-14-peterwu.pub@gmail.com> In-Reply-To: From: Andy Shevchenko Date: Thu, 14 Jul 2022 11:27:07 +0200 Message-ID: Subject: Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support To: ChiaEn Wu Cc: Lee Jones , Daniel Thompson , Jingoo Han , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Matthias Brugger , Sebastian Reichel , Chunfeng Yun , Greg Kroah-Hartman , Jonathan Cameron , Lars-Peter Clausen , Liam Girdwood , Mark Brown , Guenter Roeck , "Krogerus, Heikki" , Helge Deller , ChiaEn Wu , Alice Chen , cy_huang , dri-devel , Linux LED Subsystem , devicetree , linux-arm Mailing List , "moderated list:ARM/Mediatek SoC support" , Linux Kernel Mailing List , Linux PM , USB , linux-iio , "open list:FRAMEBUFFER LAYER" , szuni chen 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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Thu, Jul 14, 2022 at 9:13 AM ChiaEn Wu wrote: > Andy Shevchenko =E6=96=BC 2022=E5=B9=B47=E6= =9C=8813=E6=97=A5 =E9=80=B1=E4=B8=89 =E6=99=9A=E4=B8=8A8:07=E5=AF=AB=E9=81= =93=EF=BC=9A > > On Wed, Jul 13, 2022 at 12:53 PM ChiaEn Wu wrot= e: > > > Andy Shevchenko =E6=96=BC 2022=E5=B9=B47= =E6=9C=885=E6=97=A5 =E9=80=B1=E4=BA=8C =E6=B8=85=E6=99=A85:14=E5=AF=AB=E9= =81=93=EF=BC=9A > > > > On Mon, Jul 4, 2022 at 7:43 AM ChiaEn Wu wr= ote: Please, once again, remove unneeded context when replying! ^^^^^^^ ... > > > > > + prop_val =3D (ilog2(roundup_pow_of_two(prop_val))= + 1) >> 1; > > > > > > > > Isn't something closer to get_order() or fls()? > > > > > > I will revise it to "(get_order(prop_va * PAGE_SIZE) + 1) / 2" and > > > this change is meet your expectations?? > > > > Nope. Try again. What about fls()? > > I have tried two methods so far, as follows > ------------------------------------------------------------- > /* > * prop_val =3D 1 --> 1 steps --> b'00 > * prop_val =3D 2 ~ 4 --> 4 steps --> b'01 > * prop_val =3D 5 ~ 16 --> 16 steps --> b'10 > * prop_val =3D 17 ~ 64 --> 64 steps --> b'11 > */ So, for 1 --> 0, for 2 --> 1, for 5 --> 2, and for 17 --> 3. Now, consider x - 1: 0 ( 0 ) --> 0 1 (2^0) --> 1 4 (2^2) --> 2 16 (2^4) --> 3 64 (2^6) --> ? (but let's consider that the range has been checked already) Since we take the lower limit, it means ffs(): y =3D (ffs(x - 1) + 1) / 2; Does it work for you? > // 1. use fls() and ffs() combination > prop_val =3D ffs(prop_val) =3D=3D fls(prop_val) ? fls(prop_val) >> 1 : > (fls(prop_val) + 1) >> 1; > > // 2. use one line for-loop, but without fls() > for (i =3D --prop_val, prop_val =3D 0; i >> 2 * prop_val !=3D 0; prop_val= ++); > ------------------------------------------------------------- > Do these changes meet your expectations?? No, this is ugly. Yes, I understand that a bit arithmetics is hard... --=20 With Best Regards, Andy Shevchenko