Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp2569843imi; Mon, 25 Jul 2022 02:09:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ujvyTnYYYL9uKWJYFyF20ygayvfN5YwgPHGw3AHbDX3XkZ/WkA/d45g2UQrTWVUNlmH+Te X-Received: by 2002:a17:907:3f9f:b0:72b:5af2:bc06 with SMTP id hr31-20020a1709073f9f00b0072b5af2bc06mr9344344ejc.381.1658740157222; Mon, 25 Jul 2022 02:09:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658740157; cv=none; d=google.com; s=arc-20160816; b=yfEJCXX7rgWgpywmegTMpOkmWUzGGn+8cH4JIp6ihiBhvhSVpxt6eqeT1ouroSZP5e RXPWdsFpyWMUxXqFGM1jwS4Eu2YHlJjyquOMtywVDaMQ1hXs1jazeSTmxhiOWMxMldvc Ijw+ifgsNNoD15rJesQc3xYGFP6tWiwzMbu5b2TEbxENMw90xIBaGd5NdZXp0yXL+1td pDxkJjBOgVikj7xY4EKyRJCRbiuYRN5t19otLPxPsjYfZx6nZgiuQdAmyUb//XLy0+Bh zipvzcYuM5HXeI0cFiH59FcYW1XvODWbxKjwB1nscrvIGi9pws0E7ZKI1lrECIyG+vsM 5zIw== 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=sRH3Ko4u3nUzP+XsjQZDkgCAeoY72VHZaoe9ljYtNKk=; b=WrZ88VAFaT7U6Iwle3f+Gm3aXRmTKtHq25MUyexzxmXrn6sRCODS54K6M6ZFwv9Umj I8TpKSnt+u2L5Q1K3u1fSM0V/c9Rkx9S7oNIDfe2+vAUa+Rb1zoL9dvu/4cg//kUBeAD cKUYqDz5DFXzjbO8tYXf4v/So+hZbHg2s8Wu6qq0/g8H9llGZkLTxchXf6T7yMXAx0WH wBMqDs0g1VOPa9Nf7z71oJh/yN1lKizfnCjuoCQWds+J7gUs3X4Gx/yxRxu3s0D6RpK6 PyeoBhh2XTWeTnpmivysjkOFQRTFBqSaxYQ8d3G5PxNN2VHpSimeMMA5TnHnZtM6wjG+ FYug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b1ttEgok; 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 l3-20020a1709061c4300b00726b4f91300si10981957ejg.269.2022.07.25.02.08.52; Mon, 25 Jul 2022 02:09:17 -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=b1ttEgok; 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 S234192AbiGYIvt (ORCPT + 99 others); Mon, 25 Jul 2022 04:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234146AbiGYIvr (ORCPT ); Mon, 25 Jul 2022 04:51:47 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67EA6140C4; Mon, 25 Jul 2022 01:51:44 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id l23so19329568ejr.5; Mon, 25 Jul 2022 01:51:44 -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=sRH3Ko4u3nUzP+XsjQZDkgCAeoY72VHZaoe9ljYtNKk=; b=b1ttEgokmKJ5jDFSHg4C3qui+lCgzhMb1cFI+vnFX9/Qaqz5wXWkN7XbXTCmQ3rbX8 /3TN1NF7tN2a41ftKlXShOS7XLz6vjt/dE/JoVvRFVa7TBsRv37MEJRyEWP7V4gtObN8 DWOlJaAA+IaENb1E9U2bsj5iMsc5NaHbap/4bNNdkO+vyaoG6bExWIwrQG9s7uFg7Baj s+FY3gPXBy8r3qaYg0AV960MNBWHc4g/ppm+fVbr7FGTau4bS6hbfDOGbOOSslhkiqHB 4edKEq3lX1FHBOVPE941JMEmpBIHu6i/Z5b0c8XziqmaTyViSW8bxZxzR+/rVIJcM7jV un+A== 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=sRH3Ko4u3nUzP+XsjQZDkgCAeoY72VHZaoe9ljYtNKk=; b=W8jUwZGhehqGXf2omf/rXy1s93Pmb6J8SzTXfCNpY4DNQVAr4N7/dxmWhNrNt4jwdR xPMpS3zle8XoODg+lVdPaJglcRWLR+ced9JjGz2xfnKwjY+C+wWpEJwTXFvFLq64kUH0 A4tFXi0uiV/JPAAieFbal1RipjM7a5/n+xMHSgqsh93VL40N/WjBZvfqfV9FRGJ89DX8 6NE4PFg2kxn8hVp5a5QDvvDM13/cyiLpCkga1Ej2vdPTwnYYDRQj244cAXKmRMjSRBAJ hHtB58nAqbyxmyKffuYumE7MgzwZBUuPbj9u3YfKmGOvXNm59ouPyo0fjWIEgqjAWOxw oTVg== X-Gm-Message-State: AJIora+yz8UfFvOLxWhTVECYfKpJXUWAbm01y+ne/QMRetXDH0qdZcp2 iW2x70TFKMnYViWcAH7tPewuFhWaiPBCMrYTwO4= X-Received: by 2002:a17:907:1c8d:b0:6f2:eb2:1cd6 with SMTP id nb13-20020a1709071c8d00b006f20eb21cd6mr9106852ejc.568.1658739102757; Mon, 25 Jul 2022 01:51:42 -0700 (PDT) MIME-Version: 1.0 References: <20220722102407.2205-1-peterwu.pub@gmail.com> <20220722102407.2205-13-peterwu.pub@gmail.com> In-Reply-To: <20220722102407.2205-13-peterwu.pub@gmail.com> From: Andy Shevchenko Date: Mon, 25 Jul 2022 10:51:06 +0200 Message-ID: Subject: Re: [PATCH v6 12/13] leds: flash: mt6370: Add MediaTek MT6370 flashlight 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" 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 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 Fri, Jul 22, 2022 at 12:25 PM ChiaEn Wu wrote: > > From: Alice Chen > > 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. > > The Flash LED in MT6370 has 2 channels and support torch/strobe mode. > Add the support of MT6370 FLASH LED. > > Signed-off-by: Alice Chen This SoB chain is wrong. Prioritize and read Submitting Patches! ... > +static int mt6370_torch_brightness_set(struct led_classdev *lcdev, > + enum led_brightness level) > +{ > + struct mt6370_led *led = to_mt6370_led(lcdev, flash.led_cdev); > + struct mt6370_priv *priv = led->priv; > + u32 led_enable_mask = (led->led_no == MT6370_LED_JOINT) ? > + MT6370_FLCSEN_MASK_ALL : > + MT6370_FLCSEN_MASK(led->led_no); > + u32 enable_mask = MT6370_TORCHEN_MASK | led_enable_mask; > + u32 val = level ? led_enable_mask : 0; > + u32 prev = priv->fled_torch_used, curr; Here and in the other functions with similar variables it seems you never use prev after assigning curr. Just define a single variable and use it accordingly. > + int ret, i; > + > + mutex_lock(&priv->lock); > + > + /* > + * Only one set of flash control logic, > + * use the flag to avoid strobe is currently used. > + */ > + if (priv->fled_strobe_used) { > + dev_warn(lcdev->dev, "Please disable strobe first [%d]\n", > + priv->fled_strobe_used); > + ret = -EBUSY; > + goto unlock; > + } > + > + if (level) > + curr = prev | BIT(led->led_no); > + else > + curr = prev & ~BIT(led->led_no); > + > + if (curr) > + val |= MT6370_TORCHEN_MASK; > + > + if (level) { > + level -= 1; > + if (led->led_no == MT6370_LED_JOINT) { > + int flevel[MT6370_MAX_LEDS]; > + > + flevel[0] = level / 2; > + flevel[1] = level - flevel[0]; > + for (i = 0; i < MT6370_MAX_LEDS; i++) { > + ret = regmap_update_bits(priv->regmap, > + MT6370_REG_FLEDITOR(i), > + MT6370_ITORCH_MASK, flevel[i]); > + if (ret) > + goto unlock; > + } > + } else { > + ret = regmap_update_bits(priv->regmap, > + MT6370_REG_FLEDITOR(led->led_no), > + MT6370_ITORCH_MASK, level); > + if (ret) > + goto unlock; > + } > + } > + > + ret = regmap_update_bits(priv->regmap, MT6370_REG_FLEDEN, > + enable_mask, val); > + if (ret) > + goto unlock; > + > + priv->fled_torch_used = curr; > + > +unlock: > + mutex_unlock(&priv->lock); > + return ret; > +} ... > + struct v4l2_flash_config v4l2_config = {0}; 0 is not needed. -- With Best Regards, Andy Shevchenko