From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 852E4C43334 for ; Fri, 15 Jul 2022 18:30:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbiGOSaW (ORCPT ); Fri, 15 Jul 2022 14:30:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbiGOSaV (ORCPT ); Fri, 15 Jul 2022 14:30:21 -0400 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB5F1747B7; Fri, 15 Jul 2022 11:30:19 -0700 (PDT) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-31caffa4a45so55017947b3.3; Fri, 15 Jul 2022 11:30:19 -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=nt4bJMHyhYZZNJmsHG+jvKocDnQ/uRBuL8blfA1ku0E=; b=JugXTEP6dHNPhtEvF7a+5JHtnQB0Wezxj3mXkDrGYozqfRojDQsyF1yaMm4ScB7/Jm WsEkXJ0SEUGVVrZkC8BCoP0SfwdVW7GCvaD3VfdXQIsQWYFdR6LU4jAozR5eLknvx1TA ImyChQqdYXJ0emEU0f1Dn5cGjmGGfK8hvylIv7olh1kv26+7rkg/ROqYp55f4+j0shBF rb8dsgfz2gABDl/R7/RQA/+frn3Nz/VTzWGjxNJ696EP7aWkPhW2AZ98uCXxLlWzju6y gW9J1WwQmK2wGdyYn3ZQfH/AHS1DVivoCmAvm5pg5MqTybZj012lhFCUjYCBV37kdAdW bB7w== 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=nt4bJMHyhYZZNJmsHG+jvKocDnQ/uRBuL8blfA1ku0E=; b=3GYe1k6x2hqr9kIsNoQ/zb7wc0Ujbfox0Zajs6Ld4jLgZ/63llqcZgvumMs+wU6+tM b7lDsmPUY11ZDNVej89c5CM7IVSivkJZ5Gjs81v+n31srnyVKtR28fmcfOxctvePtOfC rlT4a3Q+A+rJyKa6Nx6QEbQ3UZJb87KQQNsE6FBxZqzFtD2uPROmeXwmQLmVbXll9oyx imX8wppsjv3p8AEw4uMsBEfCCIh3Obyspi6E757DinJvwuTFFYKk0DgDRbixTozp/zjZ nNSbbrB0mqOHesAYESI9gO0n+ToarpMjRh8q5oP582zc6milmVeyiSaxdaNKLp7IT3zl wp3g== X-Gm-Message-State: AJIora/YuE7Gq4sb0NRHl0/Mw8jVopFPnVqoYK5bUa3tA6WOz7UHA23l W++HU9yCQQ0I8MYYgDhXsQbRtrodTq6qnaN2Vhs= X-Google-Smtp-Source: AGRyM1vzP7L4rkzgqFevRJH1d667ZKPy7GjYyztLTPXytxkGqbpO4dyGE5UlcSEsEn68hi2rmxg67+K7y1Uib8FAXL0= X-Received: by 2002:a81:54c1:0:b0:31d:ec18:fd5d with SMTP id i184-20020a8154c1000000b0031dec18fd5dmr7586417ywb.277.1657909819017; Fri, 15 Jul 2022 11:30:19 -0700 (PDT) MIME-Version: 1.0 References: <20220715112607.591-1-peterwu.pub@gmail.com> <20220715112607.591-12-peterwu.pub@gmail.com> In-Reply-To: <20220715112607.591-12-peterwu.pub@gmail.com> From: Andy Shevchenko Date: Fri, 15 Jul 2022 20:29:42 +0200 Message-ID: Subject: Re: [PATCH v5 11/13] leds: mt6370: Add MediaTek MT6370 current sink type LED Indicator 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" Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org On Fri, Jul 15, 2022 at 1:29 PM ChiaEn Wu wrote: > > From: ChiYuan Huang > > The MediaTek MT6370 is a highly-integrated smart power management IC, > which includes a single cell Li-Ion/Li-Polymer switching battery > charger, a USB Type-C & Power Delivery (PD) controller, dual > Flash LED current sources, a RGB LED driver, a backlight WLED driver, > a display bias driver and a general LDO for portable devices. > > In MediaTek MT6370, there are four channel current-sink RGB LEDs that > support hardware pattern for constant current, PWM, and breath mode. > Isink4 channel can also be used as a CHG_VIN power good indicator. ... > + This driver can also be built as a module. If so the module so, the > + will be called "leds-mt6370.ko". No ".ko". Why did you ignore these comments? Please go and fix _everywhere_ in your series. It's basically the rule of thumb, if the reviewer gives a comment against an occurrence of something, go through entire series and check if there are other places like commented one and address them all. ... > + * Author: Alice Chen Strange, the commit message doesn't have a corresponding SoB, why? ... > +#define MT6370_PWM_DUTY 31 > +#define MT6372_PMW_DUTY 255 Looks like these are limits by hardware? Check with the datasheet if (BIT(x) - 1) makes more sense here. ... > + switch (led_no) { > + case MT6370_LED_ISNK1: > + sel_field = F_LED1_DUTY; > + break; > + case MT6370_LED_ISNK2: > + sel_field = F_LED2_DUTY; > + break; > + case MT6370_LED_ISNK3: > + sel_field = F_LED3_DUTY; > + break; > + default: > + sel_field = F_LED4_DUTY; Missed break; > + } ... > + switch (led_no) { > + case MT6370_LED_ISNK1: > + sel_field = F_LED1_FREQ; > + break; > + case MT6370_LED_ISNK2: > + sel_field = F_LED2_FREQ; > + break; > + case MT6370_LED_ISNK3: > + sel_field = F_LED3_FREQ; > + break; > + default: > + sel_field = F_LED4_FREQ; Ditto. > + } ... > + switch (led_no) { > + case MT6370_LED_ISNK1: > + case MT6370_LED_ISNK2: > + case MT6370_LED_ISNK3: > + *base = MT6370_REG_RGB1_TR + led_no * 3; > + break; > + default: > + *base = MT6370_REG_RGB_CHRIND_TR; Ditto. It seems you dropped them for all switch-cases. It's not goot, please restore them back. > + } ... > + u8 val[P_MAX_PATTERNS / 2] = {0}; { } should suffice > + /* > + * Pattern list > + * tr1: byte 0, b'[7: 4] > + * tr2: byte 0, b'[3: 0] > + * tf1: byte 1, b'[7: 4] > + * tf2: byte 1, b'[3: 0] > + * ton: byte 2, b'[7: 4] > + * toff: byte 2, b'[3: 0] > + */ > + for (i = 0; i < P_MAX_PATTERNS; i++) { > + curr = pattern + i; > + > + sel_range = i == P_LED_TOFF ? R_LED_TOFF : R_LED_TRFON; > + > + linear_range_get_selector_within(priv->ranges + sel_range, > + curr->delta_t, &sel); > + > + val[i / 2] |= sel << (4 * ((i + 1) % 2)); > + } > + > + memcpy(pattern_val, val, 3); > + return 0; > +} ... > +out: out_unlock: > + mutex_unlock(&priv->lock); > + > + return ret; ... > +out: Ditto. And so on. > + mutex_unlock(&priv->lock); > + > + return ret; ... > + sub_led = devm_kzalloc(priv->dev, > + sizeof(*sub_led) * MC_CHANNEL_NUM, > + GFP_KERNEL); NIH devm_kcalloc(). Also check if you really need zeroed data. > + if (!sub_led) > + return -ENOMEM; ... > + ret = fwnode_property_read_u32(child, "color", &color); > + if (ret) { > + dev_err(priv->dev, > + "led %d, no color specified\n", > + led->index); > + return ret; return dev_err_probe(...) ; ? Ditto for many places in your entire series. > + } ... > + priv = devm_kzalloc(&pdev->dev, > + struct_size(priv, leds, count), GFP_KERNEL); At least one parameter can be placed on the previous line. > + if (!priv) > + return -ENOMEM; -- With Best Regards, Andy Shevchenko From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44944C433EF for ; Fri, 15 Jul 2022 18:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ksy11N+R+k1XC2WDZuuWWbz80NiD2lXIz0NF/A05gFk=; b=lQlaJJAFMCHGxH NAwwwBHDtISWdFORDVV0fEdBfhIH7rFn3IQl5FnuYWd6/p9IQf761I/8yljozRKH76Q36iC4TupZJ 9cAZRF9HSaCh0gs9Le2XbUcMfLbfpk87dJRCP5N62nBhaJe03Rhznbbd59OFB62q9ClFF/th8Yza5 Lio2diVaBq2rleFgZhgbjS12umdelgHDxTFytVsFfh1vN/vgDFAm6/fcY6gChs5kWNYVnfT8kRHzC LThgXlkcfjqL2ryAXy12lh2R4Yn1NU83XLdbObBChR2x7ID7K2z3SXh8akBSdecLCwri1H5FHImxj ukDmT4F/M1SbXUO05ncA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCQ53-009S9E-P3; Fri, 15 Jul 2022 18:30:25 +0000 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCQ50-009S7m-Dq; Fri, 15 Jul 2022 18:30:23 +0000 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-31bf3656517so54700767b3.12; Fri, 15 Jul 2022 11:30:19 -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=nt4bJMHyhYZZNJmsHG+jvKocDnQ/uRBuL8blfA1ku0E=; b=JugXTEP6dHNPhtEvF7a+5JHtnQB0Wezxj3mXkDrGYozqfRojDQsyF1yaMm4ScB7/Jm WsEkXJ0SEUGVVrZkC8BCoP0SfwdVW7GCvaD3VfdXQIsQWYFdR6LU4jAozR5eLknvx1TA ImyChQqdYXJ0emEU0f1Dn5cGjmGGfK8hvylIv7olh1kv26+7rkg/ROqYp55f4+j0shBF rb8dsgfz2gABDl/R7/RQA/+frn3Nz/VTzWGjxNJ696EP7aWkPhW2AZ98uCXxLlWzju6y gW9J1WwQmK2wGdyYn3ZQfH/AHS1DVivoCmAvm5pg5MqTybZj012lhFCUjYCBV37kdAdW bB7w== 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=nt4bJMHyhYZZNJmsHG+jvKocDnQ/uRBuL8blfA1ku0E=; b=ors9BboGLiJJMbW2KM7tGNCNQedt7LwiJJq30rgrWyALHgz8U4vvCfkDfSmGzW/JyP 5jEeF5BI8kCOyIOTXGaAXVP5svGgqaYj9NZG/OXgoRCYJM4Cv7I6p68YvmgxpEBFGcua B8qDmsP9paI5srJcBaWO5zxy43hGB70ijwoGCgNknW808qnXMnm/9X90LeuPVe/VenKj sPjKbr5vgXhrmTlyffjSsTM+GGwHuDVbpKJCMPQx47JzOToaC2+x6EuAMdOrfUbEa820 4HBljpa2sn0o+k7GIEy2k6Fi9qqldJboTF7jLk5lZsCsOKSJSHD+gQR+qbRvhN72sYWN AHlw== X-Gm-Message-State: AJIora9ROTen5IMNgScsdI47KWEDyFJyPHAteA4H3symOu5RdcsYzve6 C34F6Qeu6nxPE+fWheIxma3sbqldWVofh7oRX+w= X-Google-Smtp-Source: AGRyM1vzP7L4rkzgqFevRJH1d667ZKPy7GjYyztLTPXytxkGqbpO4dyGE5UlcSEsEn68hi2rmxg67+K7y1Uib8FAXL0= X-Received: by 2002:a81:54c1:0:b0:31d:ec18:fd5d with SMTP id i184-20020a8154c1000000b0031dec18fd5dmr7586417ywb.277.1657909819017; Fri, 15 Jul 2022 11:30:19 -0700 (PDT) MIME-Version: 1.0 References: <20220715112607.591-1-peterwu.pub@gmail.com> <20220715112607.591-12-peterwu.pub@gmail.com> In-Reply-To: <20220715112607.591-12-peterwu.pub@gmail.com> From: Andy Shevchenko Date: Fri, 15 Jul 2022 20:29:42 +0200 Message-ID: Subject: Re: [PATCH v5 11/13] leds: mt6370: Add MediaTek MT6370 current sink type LED Indicator 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220715_113022_491369_FB405983 X-CRM114-Status: GOOD ( 25.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jul 15, 2022 at 1:29 PM ChiaEn Wu wrote: > > From: ChiYuan Huang > > The MediaTek MT6370 is a highly-integrated smart power management IC, > which includes a single cell Li-Ion/Li-Polymer switching battery > charger, a USB Type-C & Power Delivery (PD) controller, dual > Flash LED current sources, a RGB LED driver, a backlight WLED driver, > a display bias driver and a general LDO for portable devices. > > In MediaTek MT6370, there are four channel current-sink RGB LEDs that > support hardware pattern for constant current, PWM, and breath mode. > Isink4 channel can also be used as a CHG_VIN power good indicator. ... > + This driver can also be built as a module. If so the module so, the > + will be called "leds-mt6370.ko". No ".ko". Why did you ignore these comments? Please go and fix _everywhere_ in your series. It's basically the rule of thumb, if the reviewer gives a comment against an occurrence of something, go through entire series and check if there are other places like commented one and address them all. ... > + * Author: Alice Chen Strange, the commit message doesn't have a corresponding SoB, why? ... > +#define MT6370_PWM_DUTY 31 > +#define MT6372_PMW_DUTY 255 Looks like these are limits by hardware? Check with the datasheet if (BIT(x) - 1) makes more sense here. ... > + switch (led_no) { > + case MT6370_LED_ISNK1: > + sel_field = F_LED1_DUTY; > + break; > + case MT6370_LED_ISNK2: > + sel_field = F_LED2_DUTY; > + break; > + case MT6370_LED_ISNK3: > + sel_field = F_LED3_DUTY; > + break; > + default: > + sel_field = F_LED4_DUTY; Missed break; > + } ... > + switch (led_no) { > + case MT6370_LED_ISNK1: > + sel_field = F_LED1_FREQ; > + break; > + case MT6370_LED_ISNK2: > + sel_field = F_LED2_FREQ; > + break; > + case MT6370_LED_ISNK3: > + sel_field = F_LED3_FREQ; > + break; > + default: > + sel_field = F_LED4_FREQ; Ditto. > + } ... > + switch (led_no) { > + case MT6370_LED_ISNK1: > + case MT6370_LED_ISNK2: > + case MT6370_LED_ISNK3: > + *base = MT6370_REG_RGB1_TR + led_no * 3; > + break; > + default: > + *base = MT6370_REG_RGB_CHRIND_TR; Ditto. It seems you dropped them for all switch-cases. It's not goot, please restore them back. > + } ... > + u8 val[P_MAX_PATTERNS / 2] = {0}; { } should suffice > + /* > + * Pattern list > + * tr1: byte 0, b'[7: 4] > + * tr2: byte 0, b'[3: 0] > + * tf1: byte 1, b'[7: 4] > + * tf2: byte 1, b'[3: 0] > + * ton: byte 2, b'[7: 4] > + * toff: byte 2, b'[3: 0] > + */ > + for (i = 0; i < P_MAX_PATTERNS; i++) { > + curr = pattern + i; > + > + sel_range = i == P_LED_TOFF ? R_LED_TOFF : R_LED_TRFON; > + > + linear_range_get_selector_within(priv->ranges + sel_range, > + curr->delta_t, &sel); > + > + val[i / 2] |= sel << (4 * ((i + 1) % 2)); > + } > + > + memcpy(pattern_val, val, 3); > + return 0; > +} ... > +out: out_unlock: > + mutex_unlock(&priv->lock); > + > + return ret; ... > +out: Ditto. And so on. > + mutex_unlock(&priv->lock); > + > + return ret; ... > + sub_led = devm_kzalloc(priv->dev, > + sizeof(*sub_led) * MC_CHANNEL_NUM, > + GFP_KERNEL); NIH devm_kcalloc(). Also check if you really need zeroed data. > + if (!sub_led) > + return -ENOMEM; ... > + ret = fwnode_property_read_u32(child, "color", &color); > + if (ret) { > + dev_err(priv->dev, > + "led %d, no color specified\n", > + led->index); > + return ret; return dev_err_probe(...) ; ? Ditto for many places in your entire series. > + } ... > + priv = devm_kzalloc(&pdev->dev, > + struct_size(priv, leds, count), GFP_KERNEL); At least one parameter can be placed on the previous line. > + if (!priv) > + return -ENOMEM; -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6882BC43334 for ; Sat, 16 Jul 2022 14:40:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7911E10FC4A; Sat, 16 Jul 2022 14:36:14 +0000 (UTC) Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0523010E05A for ; Fri, 15 Jul 2022 18:30:19 +0000 (UTC) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-31cf1adbf92so55042657b3.4 for ; Fri, 15 Jul 2022 11:30:19 -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=nt4bJMHyhYZZNJmsHG+jvKocDnQ/uRBuL8blfA1ku0E=; b=JugXTEP6dHNPhtEvF7a+5JHtnQB0Wezxj3mXkDrGYozqfRojDQsyF1yaMm4ScB7/Jm WsEkXJ0SEUGVVrZkC8BCoP0SfwdVW7GCvaD3VfdXQIsQWYFdR6LU4jAozR5eLknvx1TA ImyChQqdYXJ0emEU0f1Dn5cGjmGGfK8hvylIv7olh1kv26+7rkg/ROqYp55f4+j0shBF rb8dsgfz2gABDl/R7/RQA/+frn3Nz/VTzWGjxNJ696EP7aWkPhW2AZ98uCXxLlWzju6y gW9J1WwQmK2wGdyYn3ZQfH/AHS1DVivoCmAvm5pg5MqTybZj012lhFCUjYCBV37kdAdW bB7w== 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=nt4bJMHyhYZZNJmsHG+jvKocDnQ/uRBuL8blfA1ku0E=; b=jLbE3zmWgkKdtAiu4Mwattd62s3A86QSZanmS3hhJgIZGa5fSjiGZ2kbCQt+NOu0t/ 1/WFOYwxzodDrXeX5HdH4K+84+SMqkhKdy4wH4ipVsR6c5BwxuapzqzkB0627CmZ5Y3w JBoXFwCHSGYJ8Gh5KU0sILGSGQKljc9PHcT8UjoF4zGc+z7DHdq6IGmYKCdT2NVIsETk 7pyfHBoRYMCgrAjrEhTMm+xJfawXknrxanQ1wdd2+0WnhtaVglS1nDyUuEAiAU6B1hxP xgvOXATc5OGw0hJMexJZ+UQpFXoG8pPSLBdrm0PHSvvDXggvpjfIWZRJnW8eswDBq52X YEDg== X-Gm-Message-State: AJIora/JONLfFKHPs78CXFOanOcKSGLofqWxU/Orrg3Q64+b0ngCEjmP xAdpP5tkowR+BkkRu1kylmhW4I+324sGSaTlKRc= X-Google-Smtp-Source: AGRyM1vzP7L4rkzgqFevRJH1d667ZKPy7GjYyztLTPXytxkGqbpO4dyGE5UlcSEsEn68hi2rmxg67+K7y1Uib8FAXL0= X-Received: by 2002:a81:54c1:0:b0:31d:ec18:fd5d with SMTP id i184-20020a8154c1000000b0031dec18fd5dmr7586417ywb.277.1657909819017; Fri, 15 Jul 2022 11:30:19 -0700 (PDT) MIME-Version: 1.0 References: <20220715112607.591-1-peterwu.pub@gmail.com> <20220715112607.591-12-peterwu.pub@gmail.com> In-Reply-To: <20220715112607.591-12-peterwu.pub@gmail.com> From: Andy Shevchenko Date: Fri, 15 Jul 2022 20:29:42 +0200 Message-ID: Subject: Re: [PATCH v5 11/13] leds: mt6370: Add MediaTek MT6370 current sink type LED Indicator support To: ChiaEn Wu Content-Type: text/plain; charset="UTF-8" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:FRAMEBUFFER LAYER" , "Krogerus, Heikki" , Krzysztof Kozlowski , Alice Chen , linux-iio , dri-devel , Liam Girdwood , cy_huang , Pavel Machek , Lee Jones , Linux LED Subsystem , Daniel Thompson , Helge Deller , Rob Herring , Chunfeng Yun , Guenter Roeck , devicetree , Linux PM , szuni chen , Mark Brown , "moderated list:ARM/Mediatek SoC support" , Matthias Brugger , linux-arm Mailing List , Jingoo Han , USB , Sebastian Reichel , Linux Kernel Mailing List , ChiaEn Wu , Greg Kroah-Hartman , Jonathan Cameron Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Fri, Jul 15, 2022 at 1:29 PM ChiaEn Wu wrote: > > From: ChiYuan Huang > > The MediaTek MT6370 is a highly-integrated smart power management IC, > which includes a single cell Li-Ion/Li-Polymer switching battery > charger, a USB Type-C & Power Delivery (PD) controller, dual > Flash LED current sources, a RGB LED driver, a backlight WLED driver, > a display bias driver and a general LDO for portable devices. > > In MediaTek MT6370, there are four channel current-sink RGB LEDs that > support hardware pattern for constant current, PWM, and breath mode. > Isink4 channel can also be used as a CHG_VIN power good indicator. ... > + This driver can also be built as a module. If so the module so, the > + will be called "leds-mt6370.ko". No ".ko". Why did you ignore these comments? Please go and fix _everywhere_ in your series. It's basically the rule of thumb, if the reviewer gives a comment against an occurrence of something, go through entire series and check if there are other places like commented one and address them all. ... > + * Author: Alice Chen Strange, the commit message doesn't have a corresponding SoB, why? ... > +#define MT6370_PWM_DUTY 31 > +#define MT6372_PMW_DUTY 255 Looks like these are limits by hardware? Check with the datasheet if (BIT(x) - 1) makes more sense here. ... > + switch (led_no) { > + case MT6370_LED_ISNK1: > + sel_field = F_LED1_DUTY; > + break; > + case MT6370_LED_ISNK2: > + sel_field = F_LED2_DUTY; > + break; > + case MT6370_LED_ISNK3: > + sel_field = F_LED3_DUTY; > + break; > + default: > + sel_field = F_LED4_DUTY; Missed break; > + } ... > + switch (led_no) { > + case MT6370_LED_ISNK1: > + sel_field = F_LED1_FREQ; > + break; > + case MT6370_LED_ISNK2: > + sel_field = F_LED2_FREQ; > + break; > + case MT6370_LED_ISNK3: > + sel_field = F_LED3_FREQ; > + break; > + default: > + sel_field = F_LED4_FREQ; Ditto. > + } ... > + switch (led_no) { > + case MT6370_LED_ISNK1: > + case MT6370_LED_ISNK2: > + case MT6370_LED_ISNK3: > + *base = MT6370_REG_RGB1_TR + led_no * 3; > + break; > + default: > + *base = MT6370_REG_RGB_CHRIND_TR; Ditto. It seems you dropped them for all switch-cases. It's not goot, please restore them back. > + } ... > + u8 val[P_MAX_PATTERNS / 2] = {0}; { } should suffice > + /* > + * Pattern list > + * tr1: byte 0, b'[7: 4] > + * tr2: byte 0, b'[3: 0] > + * tf1: byte 1, b'[7: 4] > + * tf2: byte 1, b'[3: 0] > + * ton: byte 2, b'[7: 4] > + * toff: byte 2, b'[3: 0] > + */ > + for (i = 0; i < P_MAX_PATTERNS; i++) { > + curr = pattern + i; > + > + sel_range = i == P_LED_TOFF ? R_LED_TOFF : R_LED_TRFON; > + > + linear_range_get_selector_within(priv->ranges + sel_range, > + curr->delta_t, &sel); > + > + val[i / 2] |= sel << (4 * ((i + 1) % 2)); > + } > + > + memcpy(pattern_val, val, 3); > + return 0; > +} ... > +out: out_unlock: > + mutex_unlock(&priv->lock); > + > + return ret; ... > +out: Ditto. And so on. > + mutex_unlock(&priv->lock); > + > + return ret; ... > + sub_led = devm_kzalloc(priv->dev, > + sizeof(*sub_led) * MC_CHANNEL_NUM, > + GFP_KERNEL); NIH devm_kcalloc(). Also check if you really need zeroed data. > + if (!sub_led) > + return -ENOMEM; ... > + ret = fwnode_property_read_u32(child, "color", &color); > + if (ret) { > + dev_err(priv->dev, > + "led %d, no color specified\n", > + led->index); > + return ret; return dev_err_probe(...) ; ? Ditto for many places in your entire series. > + } ... > + priv = devm_kzalloc(&pdev->dev, > + struct_size(priv, leds, count), GFP_KERNEL); At least one parameter can be placed on the previous line. > + if (!priv) > + return -ENOMEM; -- With Best Regards, Andy Shevchenko