Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp792388iog; Mon, 13 Jun 2022 13:06:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdfmJTrlgYwUJiYCAvHzp7whmqv1AGAm0fpjHLbM7nMaMpDgfSd29sB1zcLwGWoKxEItoE X-Received: by 2002:a63:485d:0:b0:3fe:2b87:cef6 with SMTP id x29-20020a63485d000000b003fe2b87cef6mr1183243pgk.2.1655150790779; Mon, 13 Jun 2022 13:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655150790; cv=none; d=google.com; s=arc-20160816; b=uIU+yI6J4tIFAm5MfCopi65VlRUTeNO+LNvrJ4BHSVs09BUDTy0WR+zehixp/XSYPD WoBNN28awV344XSwoHIzrfmW/iVEvDUFcTvWUtDCXHxO6viCG+hCRw5Nz0+lGXJD49WV vWbmux1veaI1ItBHPlgXqE5UFUUiw1Zfq5LgHnG1hHr9DMcMHq8ZQWGti/W78X9qoujg Kr6GZAmvCSQnfL7uCnxiB18N4rPbr1XW8ILwphSVRErO/XNY5QN2x2XYatnAe8X6T1k5 1DdY2ATe4hDV94PQomecZAm88AiFwZfHLt4Fv5io52wl5ZQNUB4i6OL7SB0YCtHQDfn1 d7lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AZWAPWwrm8+A0CgIBwRq++T65dkqg+V1CymCWTXMIwM=; b=DKsBMWs3p2I9aHOH+/2UTgSIzrbzRcijwz6wj1dVaPr0Emx6+XTTq1UTQIUy8dFqSd 4iJPyOxzYcYf5hbiUqm+8rQzeYb+xB4QKpeLtbjYBjhRfEx4hZDmH+HGQBwIp7DHA40t bo7kQd75QEbgK8F/sLRLx4ma+spaloJhKVXfqg8TGmMSxdCwlhE3+NR6HVDlB01ac2U+ GKMb391Jqc0kTdUMGxfAWF53yx4KLCinG4Cv07rlzhoWtq+A7qsehamiHRFcVmg+3OyE PyQqjEjzCiAUbVgBfpDEIZRCV7TrvOafFmwKIvioohHfEef4Dfm9DcItwKXcrj/3hNkb m7Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LIOySr/b"; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ob15-20020a17090b390f00b001e84a4796b0si16116344pjb.149.2022.06.13.13.06.18; Mon, 13 Jun 2022 13:06:30 -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=@linaro.org header.s=google header.b="LIOySr/b"; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347936AbiFMTK5 (ORCPT + 99 others); Mon, 13 Jun 2022 15:10:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351644AbiFMTKN (ORCPT ); Mon, 13 Jun 2022 15:10:13 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4415F30F5C for ; Mon, 13 Jun 2022 10:08:58 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id o33-20020a17090a0a2400b001ea806e48c6so6573302pjo.1 for ; Mon, 13 Jun 2022 10:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=AZWAPWwrm8+A0CgIBwRq++T65dkqg+V1CymCWTXMIwM=; b=LIOySr/baoj4EAyTjKf+aH+Qatb2p3UHDovP+gotSlTiSN1yTcg4GCjyqC3fyUX7wl npmmJtdNhVDNh5XKGkUnpjvg/YJI9/ZyQwGvcnz/SS0pPOuUekmDMJRnmbvEUG9D+H7+ BZM1DLAMJ8q+I+4MvG2IfeZzZu5Z2p2pmZvJH76I7ELfeoqXCbnsuzr33o2epyIJ5WeO vlWeMTh3YdX80pJSfJHrPWOfpq4BMQV7PRBFhgbMKMVtr4faZ0ISbwZoAbpm/guz5Lxu 3Q1Lh7nmkcWUV2iquou5G8hgE2UlhX7m7htGh4cx10X02rbX81xYSe5d64L24n5jYZOT up1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=AZWAPWwrm8+A0CgIBwRq++T65dkqg+V1CymCWTXMIwM=; b=g9FSksw5leGGiPxW1rTeYg1a5ZCfALcf+CH2Jcgj8VeU2g/fimwa+q8i2ZkzeiF0np FmBna16Edqlvzr8HRPYkFzk6YwXlVIIqp1e4PfXOpu4iHSM1q2sXKSDaiQr8b0hsvP99 f/8iskptykJ78pHLpYj23VjHOFAF/V4VhikmIAn5pU5E7vVEsYLoUbrzxMhCbHYGczpg +c6cqkFWKK+5tzH/VuqI9emRKFKX1GqHeM4kEKx6R/xXkZX+OkOBdnFX6MmX1JZnEO9K zMIw8S9GCI5Fk+H6bmKsvynwcLm7kCyCE2EcJGV3dyxOtLoIPYpJrYQ4n8F4HkbQQ0Ij tdhA== X-Gm-Message-State: AJIora+BEn9FTSwBVPeNC5/oA9QPBxfx8JlemysWcFLeUdtMw+Bx+ttc sZzhPBs6kroWCLsOVeao8itjUQ== X-Received: by 2002:a17:902:c94b:b0:166:4f65:cffb with SMTP id i11-20020a170902c94b00b001664f65cffbmr14965pla.103.1655140137656; Mon, 13 Jun 2022 10:08:57 -0700 (PDT) Received: from ash.lan ([192.77.111.2]) by smtp.gmail.com with ESMTPSA id 142-20020a621994000000b00518b4cfbbe0sm5632766pfz.203.2022.06.13.10.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jun 2022 10:08:56 -0700 (PDT) Date: Mon, 13 Jun 2022 18:08:53 +0100 From: Daniel Thompson To: ChiaEn Wu Cc: jic23@kernel.org, lars@metafoo.de, matthias.bgg@gmail.com, lee.jones@linaro.org, jingoohan1@gmail.com, pavel@ucw.cz, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, szunichen@gmail.com, ChiaEn Wu Subject: Re: [PATCH v2 15/15] video: backlight: mt6370: Add Mediatek MT6370 support Message-ID: <20220613170853.bffuwkcmflfgg4gt@ash.lan> References: <20220613111146.25221-1-peterwu.pub@gmail.com> <20220613111146.25221-16-peterwu.pub@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220613111146.25221-16-peterwu.pub@gmail.com> X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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 Mon, Jun 13, 2022 at 07:11:46PM +0800, ChiaEn Wu wrote: > +static int mt6370_init_backlight_properties(struct mt6370_priv *priv, > + struct backlight_properties *props) Most of the changes in this version looks good... but it looks the new code in this function has a number of problems. See below... > +{ > + struct device *dev = priv->dev; > + u8 prop_val; > + u32 brightness; > + unsigned int mask, val; > + int ret; > + > + /* Vendor optional properties > + * if property not exist, keep value in default. > + */ That's not the right strategy for booleans. Not existing means false (e.g. flags should actively be unset). > + if (device_property_read_bool(dev, "mediatek,bled-pwm-enable")) { > + ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_PWM, > + MT6370_BL_PWM_EN_MASK, > + MT6370_BL_PWM_EN_MASK); > + if (ret) > + return ret; > + } As above comment... all of the boolean properties are now being read incorrectly. > + > + if (device_property_read_bool(dev, "mediatek,bled-pwm-hys-enable")) { > + ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_PWM, > + MT6370_BL_PWM_HYS_EN_MASK, > + MT6370_BL_PWM_HYS_EN_MASK); > + if (ret) > + return ret; > + } > + > + ret = device_property_read_u8(dev, "mediatek,bled-pwm-hys-input-bit", > + &prop_val); > + if (!ret) { > + val = min_t(u8, prop_val, 3) > + << (ffs(MT6370_BL_PWM_HYS_SEL_MASK) - 1); > + ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_PWM, > + MT6370_BL_PWM_HYS_SEL_MASK, val); > + if (ret) > + return ret; > + } > + > + ret = device_property_read_u8(dev, "mediatek,bled-ovp-microvolt", > + &prop_val); > + if (!ret) { > + val = min_t(u8, prop_val, 3) > + << (ffs(MT6370_BL_OVP_SEL_MASK) - 1); This has been renamed but still seems to the using 0, 1, 2, 3 rather than an actual value in microvolts. > + ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_BSTCTRL, > + MT6370_BL_OVP_SEL_MASK, val); > + if (ret) > + return ret; > + } > + > + if (device_property_read_bool(dev, "mediatek,bled-ovp-shutdown")) { > + ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_BSTCTRL, > + MT6370_BL_OVP_EN_MASK, > + MT6370_BL_OVP_EN_MASK); > + if (ret) > + return ret; > + } > + > + ret = device_property_read_u8(dev, "mediatek,bled-ocp-microamp", > + &prop_val); > + if (!ret) { > + val = min_t(u8, prop_val, 3) > + << (ffs(MT6370_BL_OC_SEL_MASK) - 1); Likewise, should this be accepting a value in microamps? > + ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_BSTCTRL, > + MT6370_BL_OC_SEL_MASK, val); > + if (ret) > + return ret; > + } > + > + if (device_property_read_bool(dev, "mediatek,bled-ocp-shutdown")) { > + ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_BSTCTRL, > + MT6370_BL_OC_EN_MASK, > + MT6370_BL_OC_EN_MASK); > + if (ret) > + return ret; > + } > + > + /* Common properties */ > + ret = device_property_read_u32(dev, "max-brightness", &brightness); > + if (ret) > + brightness = MT6370_BL_MAX_BRIGHTNESS; > + > + props->max_brightness = min_t(u32, brightness, > + MT6370_BL_MAX_BRIGHTNESS); > + > + ret = device_property_read_u32(dev, "default-brightness", &brightness); > + if (ret) > + brightness = props->max_brightness; > + > + props->brightness = min_t(u32, brightness, props->max_brightness); > + > + > + ret = device_property_read_u8(dev, "mediatek,bled-channel-use", > + &prop_val); > + if (ret) { > + dev_err(dev, "mediatek,bled-channel-use DT property missing\n"); > + return ret; > + } > + > + if (!prop_val || prop_val > MT6370_BL_MAX_CH) { > + dev_err(dev, "No channel specified (ch_val:%d)\n", prop_val); Error string has not been updated to match condition that triggers it. > + return -EINVAL; > + } Daniel.