Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp383305imw; Thu, 14 Jul 2022 03:15:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uX18aEecj6GC8izcR/avYlOnmCUlIxfFsgNKXfhyrtsqR5bqBdAgnr38CdYFkuqQDi+bMJ X-Received: by 2002:a17:902:c992:b0:16b:d8b9:1c5f with SMTP id g18-20020a170902c99200b0016bd8b91c5fmr7585470plc.93.1657793731220; Thu, 14 Jul 2022 03:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657793731; cv=none; d=google.com; s=arc-20160816; b=A6cQnRAJ+lw8lZlQZ2JKxrk2toDRkncfT7WszpSsVg9aX50UBXcqq/nkptOOVjWiss l+aTEVcHCTg6VzkKhxsw5IaEg37mn30Syy+KhKzjEsCfSxzcx25f9Huv/59S5jfCso0p jd+vj1e3svq/7fHhy7s65ejWPRSeMvfDe0zTwNPMpP5s8dNWs/Aq2TFrjIHLqG8MBPQj 9uR4Q1cNyqs3R/bIX/pvZvif7+/82bTVLbND8Xgvjfoo1bJ/7X9SGRyj0cPEyhgbY+Uj +HGUAdersbGHbXart9WknskT3UG2i9iaWkt5iPZ65DBrXdZQqhE6N8R+VkkGJBIdIruf oKzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=UBLXrSfINFn+OkykEbtev0CVHfJNR4Ha91FDbpJe6vw=; b=nO7eZeKm/5/Wu2Vekh0ZQoC5FHgDnQSd4azXpVgcsTNPvkLDPhKS+/P9J7Sv91TJKq 5rE++05i6qMIBQ5cIptW87VzYJ1+HYyym5UXYEPaSz7N9cFFn54kIP3thSxBQp3BSUSE zqAQuk5ljY28fQO7MI/Gtzmyy+brhMdpWlRDaaoLaAjw83QXC9rzmwpiQzEXGz+xWlJQ jRoDkQ/widkiUXCehSAN+IQGQd5ICuBOtVSeWfOGoLViqK5aC8jYX5vZvMOqKnGlTLM+ LyI6h+icRd4W91w6sDVzbje9kf6gnF/rS7BMl7zBB7ZZkhHROMztAKIq/mfczRIJSqYB 0m0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jco1TUUJ; 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 j17-20020a170903029100b00168db723df8si1401075plr.581.2022.07.14.03.15.19; Thu, 14 Jul 2022 03:15:31 -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=jco1TUUJ; 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 S230126AbiGNJvC (ORCPT + 99 others); Thu, 14 Jul 2022 05:51:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234301AbiGNJuT (ORCPT ); Thu, 14 Jul 2022 05:50:19 -0400 Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8FAC12D26; Thu, 14 Jul 2022 02:50:07 -0700 (PDT) Received: by mail-yb1-xb32.google.com with SMTP id l11so2244959ybu.13; Thu, 14 Jul 2022 02:50:07 -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; bh=UBLXrSfINFn+OkykEbtev0CVHfJNR4Ha91FDbpJe6vw=; b=jco1TUUJamGLBjUMKQJxmHydRs46RlrJYGVBVuXrdgoujFg+bNA+FRuqu9xySWKxm+ iJ1MtPVhlh7NDYej/YkFvBQH1rWl4haWJzS8oJMmpCSCAzDBnx5brocoXUfXiB/uAfdM OFCWFOj+Wa/coQ+L/p2yRun8h9nxwhqAUhtPNkhFXDvtJQmjTfMKd8aLu5aGAQ9r4rKt pG3Pip2NDEZSbCM/gpswT2iVdDW8lMLvPHmzuu6unQZJ9SrI3aON/fekc5ofeaTFY0gc 5sGqoeNtKloDBRE9yF69b0PWXyQ8T9A1xzHCn4bZ9woFCXpR/laDfNHFMvp3+dX42tLc fMvQ== 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; bh=UBLXrSfINFn+OkykEbtev0CVHfJNR4Ha91FDbpJe6vw=; b=E7GOkMxKQvvxTeKx1WSSygnh68cvDjSYCp+lefeV/QDM912R3H2C6Y/dSo+9W+tsi+ yz21Ew4YxkhiNaZyOKtOH+y/cmbooM8xuG1XIbmcXFRPbBtn9YtlS+3UGEOG3Pq+HHJj xpaWEaOyA1pRCaMMXLmCy6qfuDesdeEbS8YbAwYfQ9ur3VkI4vDMGI4gvN08Elp7eiNe VYVVsSb0VfaIvkL5wZRnJZo3qwEP3eHG91p+0MmSoYeKhQsHhH778BrL/c2iuw4cThKW U56TAyCOM1wjAKqHgmdhs/MO4wujVlAfoPAVuJDoZJnqSYp8CWjlFY4otQokoLt0RN4X keoQ== X-Gm-Message-State: AJIora/NIu+kSPoBMxcmQNc7R1Ed2Ovi5gqPSTpMSOaNsixBR++rk7Tx SEZvltegrip4HzPXO2DDsK6UrSxIqUIBdKNG+Hg= X-Received: by 2002:a25:df97:0:b0:66f:6e7c:b3c0 with SMTP id w145-20020a25df97000000b0066f6e7cb3c0mr7544434ybg.93.1657792207178; Thu, 14 Jul 2022 02:50:07 -0700 (PDT) MIME-Version: 1.0 References: <20220704053901.728-1-peterwu.pub@gmail.com> <20220704053901.728-14-peterwu.pub@gmail.com> <20220714094709.6ekfnfcf5sktiegi@maple.lan> In-Reply-To: <20220714094709.6ekfnfcf5sktiegi@maple.lan> From: Andy Shevchenko Date: Thu, 14 Jul 2022 11:49:30 +0200 Message-ID: Subject: Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support To: Daniel Thompson Cc: ChiaEn Wu , Lee Jones , 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" 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:47 AM Daniel Thompson wrote: > > On Thu, Jul 14, 2022 at 11:27:07AM +0200, Andy Shevchenko wrote: > > On Thu, Jul 14, 2022 at 9:13 AM ChiaEn Wu wrote: > > > I have tried two methods so far, as follows > > > ------------------------------------------------------------- > > > /* > > > * prop_val = 1 --> 1 steps --> b'00 > > > * prop_val = 2 ~ 4 --> 4 steps --> b'01 > > > * prop_val = 5 ~ 16 --> 16 steps --> b'10 > > > * prop_val = 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 = (ffs(x - 1) + 1) / 2; > > > > Does it work for you? > > To be honest, for this tiny table, writing code that *doesn't* require intricate > deciphering together with a huge comment saying what is does would probably be > better: > > prop_val = (prop_val <= 1 ? 0 : > prop_val <= 4 ? 1 : > prop_val <= 16 ? 2 : > 3); > > This would be "obviously correct" and require no comment. Agree. It will also limit checking (and whatever needed for that). -- With Best Regards, Andy Shevchenko