Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp2570503imi; Mon, 25 Jul 2022 02:10:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uTfWcReobDQU98cfuP5KDMEHIg1tp1PNXMl8LoTkQjq5CaYuDAeTMFpiwtZFMzDQkvd99E X-Received: by 2002:a17:907:868f:b0:72b:859e:8fe4 with SMTP id qa15-20020a170907868f00b0072b859e8fe4mr9080351ejc.98.1658740248952; Mon, 25 Jul 2022 02:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658740248; cv=none; d=google.com; s=arc-20160816; b=musi4onDsqnwcmNlR+aTJuh+mCv0fOJCrubsUQvg3236AdTc11C9YVXyz1iHiuGh2b AhgLrCijB211KjmaOoJ/UgzyBRK2Hcdc4iOoiK/b1sI6Jg0MBqvIPfxgJaq709cyhdx5 agoCUBkcH7FZkXk5LU8aaMWI5fTX1c+x9rjCatHyAPh1Zn9aaANdmHBq9r93oSfod8J4 TbWl7HBf26647IaiPLKsdPIKDZBVh8QQsrM8IIYO9Kbf7mD2pjIu8cgvYyd+i+wEBZIT U9tlwR1N+BLvCqqPhDorqJt19VJGgg25PLtGQLykvYxoKj0BWYF56mpeMa6bwSEHUYCh DC/w== 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=UdipHJQcUj266PLPEbEmcprZ34Syq9EbeJ0nWcxYTz4=; b=AsmpbpwRQCwD05qDYz3Mby4gaq4Dy8iAlVQvO0rFsD6W/X1Kw0rFIWWZqBXNW4G9N4 g3FZUflFWyTkneVyvLtVFVk3KoLR1J3J17/s30F9Zoa6rs7PwULBk0iRCbi4Z2bONA2i Q6dNzeIujhUPc2ZZGbv9kI/gL4n+gv3W/f7GBjCUb44HpPg5egtmVLN/yAEBOFXFJJi3 x3/ZsZdob/eeNbZmhGEL3kwp8H4gtEzOT1vh6KkP+ZRoMlciID75QVnABKp7fvME3kmT y0Jo65UKXtEVbxHwzRgmM7oEob+ie59p5GKo9BdT2jGkvzbELwjor5fd1/hT6xtaEB7d 3p9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ABfKDB+h; 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 js2-20020a17090797c200b0072f190400f7si13219788ejc.1.2022.07.25.02.10.24; Mon, 25 Jul 2022 02:10:48 -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=ABfKDB+h; 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 S234133AbiGYIlW (ORCPT + 99 others); Mon, 25 Jul 2022 04:41:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233645AbiGYIlO (ORCPT ); Mon, 25 Jul 2022 04:41:14 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BD9E9FC2; Mon, 25 Jul 2022 01:41:11 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id e15so12973863edj.2; Mon, 25 Jul 2022 01:41:11 -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=UdipHJQcUj266PLPEbEmcprZ34Syq9EbeJ0nWcxYTz4=; b=ABfKDB+hF3n9Vc4uXcJH/wxowVuuZXANQHezQzdWr5Ngsh/idO85i0Q+mD/KzM+CSB JRG1GVu0xs6ZoCw7wBbOa5FdTc5eWvaqw+UVN9SHdJEHFfzbRmgkEdix6DCMyHAi1FCr JAr6axiQmtyvfzbVJQU1yILv+fNOSMc4pdNm12H0yVakxITFMYusQqnWis60Xho8AsGP L+ODp9hB0BQ9UuYk5DfBPx3HnH1fkimsB44PQM+VpR5aT9SXUllZ5JiUeNza+o1o5KiL NcV0q9dJ/h5dX9Q0H/4tQoS8YRcvn0AIT770BeqYm2Um/2gYOKrCHjcAMx/p6BEsJKeg en4A== 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=UdipHJQcUj266PLPEbEmcprZ34Syq9EbeJ0nWcxYTz4=; b=ixh1b8iIDmOL4ouTOSiuJP8zgseJsF3SUOmBEzmwwM+ZhUBlJDSeQRzjiVxyuvoYLN CNE7xxwG4zMOI1GAPJMVE1RdGfFBy+0iBRQh+sDrAN4wslBlNVMUOxJAPd7Hr9s5FWwW Fj1ScAaJ1b1igAre5sSgUo11dNF/Jmt52Gf+ic/kGzp2u9Oh6/p8x8iHgXvs5v3HlXHx adYXASIoLtuVwyGcn9EolO2iODRYHFDPQeAnxdoWalQYkN/EgnL663uaO4DCz2hxZhcs 5LzIHsC/xZrKUQZGCS4bR8jcqxtk+yzA3o9UcrFjd2UgPgLEaDpAxWw5IldPEDcQrKjp iRpQ== X-Gm-Message-State: AJIora8nUJu4IFtQQ9/ihcPXFJWCBIRP/1w9p/GT8QfnnUKj/OHL8OaI 97DFcM70TcjrPlgj53eN5p457QSMfGp/Ve9fbP0= X-Received: by 2002:a05:6402:34c5:b0:43a:8f90:e643 with SMTP id w5-20020a05640234c500b0043a8f90e643mr11897371edc.88.1658738469088; Mon, 25 Jul 2022 01:41:09 -0700 (PDT) MIME-Version: 1.0 References: <20220722102407.2205-1-peterwu.pub@gmail.com> <20220722102407.2205-12-peterwu.pub@gmail.com> In-Reply-To: <20220722102407.2205-12-peterwu.pub@gmail.com> From: Andy Shevchenko Date: Mon, 25 Jul 2022 10:40:32 +0200 Message-ID: Subject: Re: [PATCH v6 11/13] leds: rgb: 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" 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: ChiYuan Huang ^^^^ (Note this and read below) > > 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. > Signed-off-by: Alice Chen > Signed-off-by: ChiYuan Huang In conjunction with above what SoB of Alice means? You really need to take your time and (re-)read https://www.kernel.org/doc/html/latest/process/submitting-patches.html. ... > + * Author: Alice Chen > + * Author: ChiYuan Huang Would * Authors: * Name_of_Author 1 * Name_of_Author 2 work for you? ... > +struct mt6370_led { > + union { > + struct led_classdev isink; > + struct led_classdev_mc mc; > + }; Where is the field that makes union work? > + struct mt6370_priv *priv; > + u32 default_state; > + u32 index; > +}; ... > +static int mt6370_gen_breath_pattern(struct mt6370_priv *priv, > + struct led_pattern *pattern, u32 len, > + u8 *pattern_val, u32 val_len) > +{ > + enum mt6370_led_ranges sel_range; > + struct led_pattern *curr; > + unsigned int sel; > + u8 val[P_MAX_PATTERNS / 2] = {}; > + int i; > + > + if (len < P_MAX_PATTERNS && val_len < P_MAX_PATTERNS / 2) > + return -EINVAL; > + > + /* > + * 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); Isn't it something like put_unaligned_be24()/put_unaligned_le24()? > + return 0; > +} ... > +static inline int mt6370_mc_pattern_clear(struct led_classdev *lcdev) > +{ > + struct led_classdev_mc *mccdev = lcdev_to_mccdev(lcdev); > + struct mt6370_led *led = container_of(mccdev, struct mt6370_led, mc); > + struct mt6370_priv *priv = led->priv; > + struct mc_subled *subled; > + int i, ret = 0; Redundant assignment. > + mutex_lock(&led->priv->lock); > + > + for (i = 0; i < mccdev->num_colors; i++) { > + subled = mccdev->subled_info + i; > + > + ret = mt6370_set_led_mode(priv, subled->channel, > + MT6370_LED_REG_MODE); > + if (ret) > + break; > + } > + > + mutex_unlock(&led->priv->lock); > + > + return ret; > +} ... > + if (!fwnode_property_read_string(init_data->fwnode, "default-state", > + &stat_str)) { ret = fwnode_...(...); if (!ret) > + ret = match_string(states, ARRAY_SIZE(states), stat_str); > + if (ret < 0) > + ret = STATE_OFF; > + > + led->default_state = ret; > + } ... > + int i = 0, ret; unsigned int i = 0; int ret; -- With Best Regards, Andy Shevchenko