Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp410635imw; Thu, 14 Jul 2022 03:55:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ud/9SSiGAANfoCeRZOy2dTGn7fOq4u+0Ys5S8nWb3qxb/2ouVmjGc8dLeKKHv+5p7NGGd/ X-Received: by 2002:a05:6402:3881:b0:43a:691f:8e3b with SMTP id fd1-20020a056402388100b0043a691f8e3bmr11309751edb.217.1657796122211; Thu, 14 Jul 2022 03:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657796122; cv=none; d=google.com; s=arc-20160816; b=b+4EvcgTGloEJUdqsUsbMFgiFzMnW7CbzRL4S6zFVNGFvCCGcY6x4n+CqkuJrChwrS CTKG1R7Cnwm6u5TdNBItLQyZKjuJEAO7bKrC7qkxK4y2usZJdpc4fbaA6SKDe6BAVzh6 RQgIEr7TPJSIiEtuyXF9qEdqU0v/5X9D8Tvc3lxhO2Psqz1jr9LUBERta+VjHnWM6J7p nPDtz62rbLIehzDJr60kOYsFgQ93/IPNHcNGoILIu2WmVnWfyKFpOdFZ6pRjRosGIWNV gmoZDQ6p84VcQ3ve94B3kIdL964PSBFMmPqYsoIkQksuTI1XYGRN5Z374VTovU2l6WaM H/Ew== 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=DAB/V2thJrX7oNWAiw69xQ9s2yER1z6zgaPEDVTbARY=; b=SlER8anutEVMgSCacoewdXgztbmMfWhem04QlQl7RSR94qPk6mA+/oFuAfWAJ5l1Mb 6s3gXnTgNtIpHRyB+N9YJXc61Sazkd0c65j26sr2HnDR7zM9+dJl9WR9ZbyY4wpC7Ivg MNYFlbAdC8jaYCuO7r6370JKauu0p5cikRPI5RbY+cMxRvDWTHfazdy3rYnVR7ZnqO3q o+nawmXpzX4+AQrrrPnmtTuAErPdrfkhMiZAlwYXznwUM8xYHMAYVTJbieI1d6cKvjMc mKw2EXyfwuL4BKx0AJhAy+5DMr0A4By3Z68kdrnUlSRt8Wa0F8m2B8RbhYYL1VoNbw/L YOTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WzDjqq1p; 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 qb42-20020a1709077eaa00b0072b44c95da6si2261786ejc.1002.2022.07.14.03.54.57; Thu, 14 Jul 2022 03:55:22 -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=WzDjqq1p; 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 S237237AbiGNKQi (ORCPT + 99 others); Thu, 14 Jul 2022 06:16:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230073AbiGNKQh (ORCPT ); Thu, 14 Jul 2022 06:16:37 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36C4F120A5; Thu, 14 Jul 2022 03:16:36 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id y195so2487074yby.0; Thu, 14 Jul 2022 03:16:36 -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=DAB/V2thJrX7oNWAiw69xQ9s2yER1z6zgaPEDVTbARY=; b=WzDjqq1pRDiX/e0JhdlBpio8zOrckRWFWYoqqx6oFzHppl1HXZKC0K0Vo9UvICBDx4 1IgGFxPhaOdHa0ijcMRnAWpg15ZqdMXn+A4AN+KbbyLfV+DLK/zGUswdeyoa6I/gMSWB mLZcWexKeicX3ZsiBj8qG9KhT504M9qLDNPa+/3b4OVXUQmkey6iL5NUBSkO06Ql9xqx 7ABvX+TuwC6gjV6lZglt+ptPstfpEqlr1Yg9+65NKMHYYSOzn23aEysk+sSCVoQV5iL6 RIo+DgXA1m8aiBJ1aC+G2pOf803m52JzwysZxxKXTmLKrJdLDZZrFNf6ymvczZtUZHNx NC+Q== 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=DAB/V2thJrX7oNWAiw69xQ9s2yER1z6zgaPEDVTbARY=; b=zd0TXa3ccyOwBBJjB+uQo+lzRSumxdbxEoV3qr/dCPj55C2RbbWDifNraEZm609qu0 w1QvJbffkV2WGGFkjggR4ZRI0Tb5w1O8PyrBoZcfILoHtN8621+mLzP6989YbrOaEFir XVdMdrDPw4bN+fOZUSGWg4HmivMQHFqmU6w+5orxmrTaC4c+2fM+YtzsBVSNF/Wi8NYL zznjtl6dwodcR2TGJwEpaCJ4RMMC2X6LYD3DhYvl+TfKTX+s9KRWu2yfxJ0cNZboDLHb 406SMFaviorzsXpObR8aQyJZSrubJhNBovqSc6d1tS74oC9wALA3XxgOSKHH1TJO/HaA DYOw== X-Gm-Message-State: AJIora9n0DiigPni0fiNksHx987JPA6i7BH6qczxLrbSgkVRddkU6fGm F9LhETRK4YMzSYuT6VG4aA0vySQCwqAg8E2ZLTw= X-Received: by 2002:a05:6902:686:b0:66e:627f:4d29 with SMTP id i6-20020a056902068600b0066e627f4d29mr7320510ybt.385.1657793795448; Thu, 14 Jul 2022 03:16:35 -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 12:15:58 +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 11:43 AM Andy Shevchenko wrote: > On Thu, Jul 14, 2022 at 11:27 AM Andy Shevchenko > wrote: > > 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 ... > > > * 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 alre= ady) > > > > Since we take the lower limit, it means ffs(): > > > > y =3D (ffs(x - 1) + 1) / 2; > > > > Does it work for you? > > It wouldn't, because we need to use fls() against it actually. > > So, > 0..1 (-1..0) --> 0 > 2..4 (1..3) --> 1 > 5..16 (4..15) --> 2 > 17..64 (16..63) --> 3 > > y =3D x ? ((fls(x - 1) + 1) / 2 : 0; Okay, I nailed it down, but Daniel is right, it's simpler to have just conditionals. y =3D x >=3D2 ? __fls(x - 1) / 2 + 1 : 0; -- With Best Regards, Andy Shevchenko