Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp705728imw; Fri, 15 Jul 2022 11:16:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sRRkBZ0Kykt6XyREdg3+xQrOyXhGq7PWHK1Y0N4+nMLYQYcepar1RmUOqsOhFhUkOD/i3k X-Received: by 2002:a05:6830:3686:b0:61c:4a56:5c8b with SMTP id bk6-20020a056830368600b0061c4a565c8bmr6318708otb.49.1657908970793; Fri, 15 Jul 2022 11:16:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657908970; cv=none; d=google.com; s=arc-20160816; b=oXWnRWT/MG32xk7/v6uh/NiaMvpKAkWhL35BUw2tFzEedIrLBQq993ZNkpM4QYs52M DryB4YEKczJJXs0vUR9Dukhu3mywCMLuq1NjQh4HWZ8pLrJ37WT0iBStTgIQGgMYjetT sfevWT/wJlZFMNcNe0h26Ip4WxpGtyL1x/SE4f3bHDJNZfsvepXp79aJ9O8GaQU1EgfE nrE0DwUiZUrEIGGYkcSqNtxxGnqIQtxBF3Cw7bcEVLLBDDyIX9aIHYGaAUsEWSB4uHvW UXx61wvp+A22zfmYhMN5WGgWy9qrSdfOZlwoOn8g+Z6ioAAABYDlujrSvgHa+lM7TPnL 4B+g== 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=wYQx40/iCC7JCsgHdkd0E1jOgqV54xGVWGfgqFpzTxo=; b=fyaoxW18PcHwDZaSMLP3NQcwep7Sz9b3o6EfJbWHtwIWFLe2uXbRzb5QTwlhRL8Fof oxT1+ZXIMLSww+M6DznN42DiqGsdyNXHHFSEq1bPlVRqWuANosuevnjTPlFo6DVXwjE+ UXxfL4AvOrE23Wy8qSVS3ytENs9pMERBL50bb8XvhsFqaodzCpvU3gR4Hl2Zu0Nag3Ml t0COK2+Zo2dbFJnmWCLCt0UYm8yfsdfoKTmeYM4JNgHbbIO2E+gwm+ehX8wmQvbvmNVl yEPyqLUg/+arlnnb7d5l+yZ2bmTVg3ve539kAaGSOuEdKLdPPKX16UwpNtXfdkKcHDDR wADw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CCNqrZ6x; 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 k30-20020a056870819e00b00108c29210d1si1656040oae.107.2022.07.15.11.15.55; Fri, 15 Jul 2022 11:16:10 -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=CCNqrZ6x; 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 S229776AbiGOSOa (ORCPT + 99 others); Fri, 15 Jul 2022 14:14:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbiGOSO3 (ORCPT ); Fri, 15 Jul 2022 14:14:29 -0400 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8786015FD9; Fri, 15 Jul 2022 11:14:27 -0700 (PDT) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-31bf3656517so54333307b3.12; Fri, 15 Jul 2022 11:14:27 -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=wYQx40/iCC7JCsgHdkd0E1jOgqV54xGVWGfgqFpzTxo=; b=CCNqrZ6xxLNILlnpWQJZURCM7WccDYI4HArJBKyxVZQ4tUE7wHsb8C+1xQrCcy/ctP hgNxqF3L/l+JVN/sIioIK7hlY2E24EgjBaYcjObgBZ96Go1MFnvrauI9olx68o+tAec5 0zqXIns8v8XdElhZwR+ilBWSFm2BAz09sy+iAz5QQOYZmnuuIUuyYZ7ilSKeAOMj7Dr0 nmKdVBdXufKKDMVxiWrXIc+cIpZBo8ghQfSQgHJj69Av/M38jJkwWwu38WYhZktwk2Sr Ktcv4iMX1VtKF6apNGtKuW2hT3Gz86OVl/1giJmpSuReSlovrn8AP0YP6RZk9atjVy9y /pvQ== 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=wYQx40/iCC7JCsgHdkd0E1jOgqV54xGVWGfgqFpzTxo=; b=F1Rb0F4hJTU3z+RjtUcnUk40dINLOEJWsSkUJXA19zkvWio+EVFRGGZI3TZN9Jsdor ikHvlAI8RfNLkl6B+9LXP2LwEHF5pr3aEg6bTqDJQL3dw25xiXFDcxENbovKZxZpP9Me xJQqt9rCvQXLMtdk7s2mByd4+g9tglCxLp26Z/evry+1ygE8upN5PDhuGlYo3Ilm+yV5 ddRdRN9SNRTJxX6sefLpjqplGeirGYTyK2eVs6x+4XEUYSbyN+EwwtLuEORFiJPFD5jD WamwcsOyWXoUBf9l23BWRjFx67ikGRmfHHoVy0y4YK/24x32ZZJeLVRxytkeDPCwI9dX F07A== X-Gm-Message-State: AJIora+cA9Ick5GK3oJPozXOmfTohLm1/p2y2Rch9m3FQCOwpJtKa7H9 IXceeMgrt1X5ZX5XuFvKeZeE1MebIhmgsHZvXwjOCc4HxYo= X-Received: by 2002:a81:4bd7:0:b0:31c:91da:5a20 with SMTP id y206-20020a814bd7000000b0031c91da5a20mr18833575ywa.131.1657908866682; Fri, 15 Jul 2022 11:14:26 -0700 (PDT) MIME-Version: 1.0 References: <20220715112607.591-1-peterwu.pub@gmail.com> <20220715112607.591-13-peterwu.pub@gmail.com> In-Reply-To: <20220715112607.591-13-peterwu.pub@gmail.com> From: Andy Shevchenko Date: Fri, 15 Jul 2022 20:13:49 +0200 Message-ID: Subject: Re: [PATCH v5 12/13] leds: flashlight: 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 15, 2022 at 1:29 PM ChiaEn Wu wrote: > The MediaTek MT6370 is a highly-integrated smart power management IC, > whichincludes a single cell Li-Ion/Li-Polymer switching battery which includes > 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 channel and support torch/strobe mode. channels > The commit add the support of MT6370 FLASH LED. Add the ... > +#define MT6370_FLCSEN_MASK_ALL (BIT(0) | BIT(1)) GENMASK() ... > + for (i = 0; i < MT6370_MAX_LEDS; i++) { > + ret = regmap_update_bits(priv->regmap, > + MT6370_REG_FLEDISTRB(i), > + MT6370_ISTROBE_MASK, flevel[i]); > + if (ret) > + return ret; > + } > + } else { > + ret = regmap_update_bits(priv->regmap, > + MT6370_REG_FLEDISTRB(led->led_no), > + MT6370_ISTROBE_MASK, val); > + } > + return ret; return regmap_update_bits(...); } return 0; ... > + /* > + * If the flash need to be on, needs > + * config the flash current ramping up to the setting value. > + * Else, always recover back to the minimum one. > + */ ... > + /* For the flash turn on/off, need to wait HW ramping up/down time to turn > + * 5ms/500us to prevent the unexpected problem. > + */ Wrong multi-line comment style. > + No need for a blank line. > + if (!prev && curr) > + usleep_range(5000, 6000); > + else if (prev && !curr) > + udelay(500); ... > +static int mt6370_led_register(struct device *parent, struct mt6370_led *led, > + struct led_init_data *init_data) > +{ > + struct v4l2_flash_config v4l2_config = {0}; > + int ret; > + > + ret = devm_led_classdev_flash_register_ext(parent, &led->flash, > + init_data); > + if (ret) { > + dev_err(parent, "Couldn't register flash %d\n", led->led_no); > + return ret; return dev_err_probe() here and everywhere where it is about probe stage. > + } > + > + mt6370_init_v4l2_flash_config(led, &v4l2_config); > + led->v4l2_flash = v4l2_flash_init(parent, init_data->fwnode, > + &led->flash, &v4l2_flash_ops, > + &v4l2_config); > + if (IS_ERR(led->v4l2_flash)) { > + dev_err(parent, "Failed to register %d v4l2 sd\n", led->led_no); > + return PTR_ERR(led->v4l2_flash); > + } > + > + return 0; > +} ... > + num = fwnode_property_count_u32(init_data->fwnode, "led-sources"); > + if (num < 1 || num > MT6370_MAX_LEDS) { > + dev_err(priv->dev, > + "Not specified or wrong number of led-sources\n"); > + return -EINVAL; Ditto. > + } ... > + ret = fwnode_property_read_u32(init_data->fwnode, "led-max-microamp", > + &val); One line? ... > + val = clamp_align(val, MT6370_STRBTO_MIN_US, MT6370_STRBTO_MAX_US, > + MT6370_STRBTO_STEP_US); I would name it mt6370_clamp() to avoid potential collision in the global namespace in the future. -- With Best Regards, Andy Shevchenko