Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp559151imw; Wed, 13 Jul 2022 03:55:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s5VZLoCaPyVZkQvtJTVJdYlZ27YGbTyuOA1rp7fkwZm5hLm1Y03m/dJ+xBcwgLrMhwJVJ8 X-Received: by 2002:a17:902:f652:b0:156:701b:9a2a with SMTP id m18-20020a170902f65200b00156701b9a2amr2888640plg.14.1657709750152; Wed, 13 Jul 2022 03:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657709750; cv=none; d=google.com; s=arc-20160816; b=D9XKnGbEk1Wf7gY7psEYTIHPxCoxvEkrezNUP/MDxgoX9lnUfp0qaBfjCHO8ChcsCM H18VJfhyYEvawgmZPa6Eie2GKe4+rlTPxjC9Fk92su7yTYHzTDsFXu1fPls5bNJtF+lA 5ls3v3dLnt70cUwAfiYEs/0enrPjLi2KZ9TMtL4Y3sia9Aus1JcW07l5oN34vbbll7W4 UT2WDQ6+soCq+JqAK+5JYLdlGQWy4S33ZQBlvq9f99IvaXbPXeb+pX03Nrd6WBV52P3G 8mFnNUOiP5D/TxO9WOdmN2Ervflz6zmNSd7IUxxKh5xpDRtS0mRNs58zL+A9OupKbyqD AiBw== 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=DtbNdnUc44YIlF6TRQBufQhc3QEyoL5MrmX0wLT8k54=; b=Hd9S3wUDa0fmoj8ukW18kPyn9bxNHqaTVaUKU0PUOYlygr2xdpzOQZZ5Z8w58/mSa+ WtT+rNZ6dOVwLgL9GGJzL/0PZs3FpPuGufPeorpL0M3b+Dt1HVEQFCgd7J/8OD+4cKX8 WLdazJzeU/V3+Bi75YuOlkxuA7vihLkYmqKoJ38xpYMxRyB/+eUIrF9rPoVFQ0sscSIz BET3PkJBJ2O6JrWh5zqT4l3TIldzD+8XINdneBy0yaWhxZFyVdG/nNIYleDKwR5qv2h1 Ty1IDNCkeroqi8Lf4YKz4eVO91Cjd6oNkRh0lEsQXrPaX7hZxxe1tlfIz9QlKDVR5frB ZX1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Gyo9ib/Q"; 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 196-20020a6300cd000000b004199286220dsi1617133pga.25.2022.07.13.03.55.35; Wed, 13 Jul 2022 03:55:50 -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="Gyo9ib/Q"; 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 S235206AbiGMKxn (ORCPT + 99 others); Wed, 13 Jul 2022 06:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231169AbiGMKxl (ORCPT ); Wed, 13 Jul 2022 06:53:41 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE58C20F6F; Wed, 13 Jul 2022 03:53:38 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id j27so974641qtv.4; Wed, 13 Jul 2022 03:53:38 -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=DtbNdnUc44YIlF6TRQBufQhc3QEyoL5MrmX0wLT8k54=; b=Gyo9ib/QcIdb16MTJkh9cbA18WvicHplsE0W3sU861LHrnSg07BYqH7gJMgBhngnKz HcevAv8xN2yoj76j2VtRiK2gtKJVtYu4yl5/zly8b+NniYgUqKX802rsbScX12+DWFC4 f0KpI6KMxAijdVif10K4Yr7TL49g59ksBWPF+FSCOp555hmLxPKqliprXs0MwfV8RcVf ETobhf/JgYbtx1rqJ3zRweW6zFE9EFO0mg+t95Av28GUjrByGd6Dv732KM7J1jq47j2b 8+Q496cjjPl2IE4bcmCDO+D9bk6yPPzE9JlJzEBLhQ3fyJGOnWiUMtJcmMXwpI3pw5T7 noUA== 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=DtbNdnUc44YIlF6TRQBufQhc3QEyoL5MrmX0wLT8k54=; b=2dlLst/eKigysqG5Qlhy5ahBIvichPs1QHnAmRIt4BupqfA2zVMjiac5KhdhcxC07a lpbv0f3b6yd238ANL0KfdlGyJJbnJMtvvLrVcmV8fNOMrU8ikBhlHcfJGvFTfn9dKDKB vZhxZzijHWm5YFiXCVF0d5fXNTHevC5y4t3ijPJLN8TVTRvQ/zWt7oKNDICElMI/S8fE 2lU+m+RV2Z2tmsGw+0WtqejFLX8s7kQ404g2q5rxpvLGyQrrt8TCDpuTOefM05Kk7TtA E5Ewaa4HSwVor8N4et1Jhkbp9wT+EBT/NRPIAaXwDVACGAcJQw/SBUMlF9RR98FdbJJc SlgQ== X-Gm-Message-State: AJIora8T/IGO2g/aL5RWQLCwcj2gedHWyfzCf9euRsZLd/R2dwKQoU8A zEm3KBzwCI1S5l6FH3RHpLyUpHhOZao5Dtv5U8s= X-Received: by 2002:a05:622a:1755:b0:31e:cbdf:2e32 with SMTP id l21-20020a05622a175500b0031ecbdf2e32mr1387023qtk.548.1657709618139; Wed, 13 Jul 2022 03:53:38 -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: ChiaEn Wu Date: Wed, 13 Jul 2022 18:53:26 +0800 Message-ID: Subject: Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support To: Andy Shevchenko 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 Hi Andy, Thanks for your reply! I have some questions want to ask you below. 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 wrote: > > > > From: ChiaEn Wu > > > > Add Mediatek MT6370 Backlight support. > > ... > > > + This driver can also be built as a module. If so the module > > If so, > > > + will be called "mt6370-backlight.ko". > > No ".ko" part. > > ... > > > +#include > > Can you elaborate on this? > > > +#include > > +#include > > +#include > > +#include > > > +#include > > Can you elaborate on this? > > > +#include > > +#include > > Missed mod_devicetable.h. > > ... > > > + brightness_val[0] =3D (brightness - 1) & MT6370_BL_DIM2= _MASK; > > + brightness_val[1] =3D (brightness - 1) > > + >> fls(MT6370_BL_DIM2_MASK); > > Bad indentation. One line? Well... if indent to one line, it will be over 80 characters(or called colu= mns?) From my understanding, it is not allowed, right?? > > ... > > > + if (priv->enable_gpio) > > Dup check. > > > + gpiod_set_value(priv->enable_gpio, brightness ? 1 : 0); > > ... > > > + brightness =3D brightness_val[1] << fls(MT6370_BL_DIM2_MASK); > > + brightness +=3D (brightness_val[0] & MT6370_BL_DIM2_MASK); > > Too many parentheses. > > ... > > > + /* > > + * prop_val =3D 1 --> 1 steps --> 0x00 > > + * prop_val =3D 2 ~ 4 --> 4 steps --> 0x01 > > + * prop_val =3D 5 ~ 16 --> 16 steps --> 0x10 > > + * prop_val =3D 17 ~ 64 --> 64 steps --> 0x11 > > + */ > > + 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?? > > ... > > > + props->max_brightness =3D min_t(u32, brightness, > > + MT6370_BL_MAX_BRIGHTNESS); > > One line? Ditto, it will be over 80 characters... > > ... > > > + val =3D 0; > > Do you need this here? > > > + prop_val =3D 0; > > Useless. > > > + ret =3D device_property_read_u8(dev, "mediatek,bled-channel-use= ", > > + &prop_val); > > + if (ret) { > > + dev_err(dev, "mediatek,bled-channel-use DT property mis= sing\n"); > > + return ret; > > + } > > + > > + if (!prop_val || prop_val > MT6370_BL_MAX_CH) { > > + dev_err(dev, > > + "No channel specified or over than upper bound = (%d)\n", > > + prop_val); > > + return -EINVAL; > > + } > > ... > > > +static int mt6370_bl_probe(struct platform_device *pdev) > > +{ > > + struct mt6370_priv *priv; > > + struct backlight_properties props =3D { > > + .type =3D BACKLIGHT_RAW, > > + .scale =3D BACKLIGHT_SCALE_LINEAR, > > + }; > > + int ret; > > struct device *dev =3D &pdev->dev; > > will save you a few LoCs. > > -- > With Best Regards, > Andy Shevchenko Best regards, ChiaEn Wu