Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1775856rwl; Sun, 26 Mar 2023 08:54:47 -0700 (PDT) X-Google-Smtp-Source: AKy350aPb/MdMGPFjO3dXIdgYQgHJIi4ECWAQnzr/frTngF+x8n8+fRkEuvQeK3gojYmFagaMtVC X-Received: by 2002:a17:902:f243:b0:19e:b6b0:6b3 with SMTP id j3-20020a170902f24300b0019eb6b006b3mr7482326plc.15.1679846087640; Sun, 26 Mar 2023 08:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679846087; cv=none; d=google.com; s=arc-20160816; b=WtqF8Kr/Y6ZvBcYWbNE+5LVfgVLqkyWB8egj8DDYYcXT5InzX6GeI1UelqD1XC/7XL rQuMZZar6INgN57x5Q3P01mbT0VKSscjY6k+gXSZ6wiVO48x9iLy8SJHd8CzswpYyPFE aJvX8BUw0yEgTeP4e7nqLFbKLjJuo/CYhZX9M0o36C77wTvG1Z4pPbCDb+R5VQB94EU2 UG6PVoXnMttlcRpIRQCZnvSA/xNBF1ioSF/uOPjV1FbESERIKppX9LC4Pk0300ZiA/y2 IDANz+36uFCWHe3dkU5jbDu88UEKBL26reOP6hyt0JcDFxu6T61hSXfzvCYRV+uJFppL kDIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=uctRIe2bZla+yug5rGspur8RVLaFggvVGV73vpRJbTM=; b=w63tLQBWon2UEGhIgPF9vniAnU7xu+sz7rYOIlelAUbZGFxe7Zew1CTcQpLlGVyanG /DhUUhxX1+Ng78HpUBbg80uGIao7YGCbzdBdAjkXQ9RJbALxi00NcdmLdcLOqpsmuBAi UibZdKYjHa0VxOoyL0wgSyJzaX/ccF7gkAqlrlNxUlfanUg3swgnQNYih2aOZZ/Dke0s D4v4/PeFZNwKFrkD6/0+R21I8l1e+m59mqm3StwkjdYbw/VLA1YaqJkn7zV2TODwclAG iA4LV003S9u7x1h6fICkHJkGVQcosp/fvRhIitPeU/0qzfI2X/fa63M01uyxDntqtVkQ S0Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W8UV2+C2; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q28-20020a635c1c000000b0050b8a7635dfsi25061607pgb.295.2023.03.26.08.54.34; Sun, 26 Mar 2023 08:54:47 -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=@kernel.org header.s=k20201202 header.b=W8UV2+C2; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232251AbjCZPlG (ORCPT + 99 others); Sun, 26 Mar 2023 11:41:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbjCZPlE (ORCPT ); Sun, 26 Mar 2023 11:41:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D33119BA; Sun, 26 Mar 2023 08:41:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0836D60DE7; Sun, 26 Mar 2023 15:41:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D533C433D2; Sun, 26 Mar 2023 15:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679845262; bh=21uEPRsfEI6Bmn4l2Yo3fQlTwIXz1UGKObvRJC3gEzY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=W8UV2+C20/Ija6ZI/S572nlTDADojVrGdQ31d3VqGtzPothV7yLPpcN73LCcBY9/v LBURlPry05C4uENgAOfQjGxzcLpNGk8EksOGlPsJOIRDIsFP/c2j5pbmXTi9WQO2Jm Dr9hMyewDKdIwPmgw1sXDfjQo0mnTL/k7Ek1S951FQHLKAUTH/skK1DHc8hTC4GMpX +jw/2Shj2oVOANbym7tOoUYtFkYMmDRF4UA/mN19HhKdlQ8Zno+Fp1fPZVmIMhLyV7 P3KxigVaIZ/uRjRu8+SVaAzGPnEZb6lOdqdFAWFRgXF0U6mpSFK32bj9kqB0Xn8yRu Yu31MHVyBCy6g== Date: Sun, 26 Mar 2023 16:56:04 +0100 From: Jonathan Cameron To: ChiaEn Wu Cc: , , , , , , , , Subject: Re: [PATCH] iio: adc: mt6370: Fix ibus and ibat scaling value of some specific vendor ID chips Message-ID: <20230326165604.27338cc6@jic23-huawei> In-Reply-To: <1679667167-16261-1-git-send-email-chiaen_wu@richtek.com> References: <1679667167-16261-1-git-send-email-chiaen_wu@richtek.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.37; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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, 24 Mar 2023 22:12:47 +0800 ChiaEn Wu wrote: > The scale value of ibus and ibat on the datasheet is incorrect due to the > customer report after the experimentation with some specific vendor ID > chips. > > Signed-off-by: ChiaEn Wu Hi. Only significant issue here is the one the build bot found. A few other trivial formatting suggestions inline. Thanks, Jonathan > > static int mt6370_adc_read_channel(struct mt6370_adc_data *priv, int chan, > @@ -98,6 +105,26 @@ static int mt6370_adc_read_channel(struct mt6370_adc_data *priv, int chan, > return ret; > } > > +static int mt6370_adc_get_ibus_scale(struct mt6370_adc_data *priv) > +{ > + if (priv->vid == MT6370_VID_RT5081 || > + priv->vid == MT6370_VID_RT5081A || > + priv->vid == MT6370_VID_MT6370) > + return 3350; > + else I'd drop the else. We are special casing the matches above, so it makes sense for them to be out of line. The 'normal' case doesn't need to be indented. > + return 3875; > +} > + > +static int mt6370_adc_get_ibat_scale(struct mt6370_adc_data *priv) > +{ > + if (priv->vid == MT6370_VID_RT5081 || > + priv->vid == MT6370_VID_RT5081A || > + priv->vid == MT6370_VID_MT6370) > + return 2680; > + else > + return 3870; > +} > + > static int mt6370_adc_read_scale(struct mt6370_adc_data *priv, > int chan, int *val1, int *val2) > { > @@ -123,7 +150,7 @@ static int mt6370_adc_read_scale(struct mt6370_adc_data *priv, > case MT6370_AICR_250_mA: > case MT6370_AICR_300_mA: > case MT6370_AICR_350_mA: > - *val1 = 3350; > + *val1 = mt6370_adc_get_ibus_scale(priv); > break; > default: > *val1 = 5000; > @@ -150,7 +177,7 @@ static int mt6370_adc_read_scale(struct mt6370_adc_data *priv, > case MT6370_ICHG_600_mA: > case MT6370_ICHG_700_mA: > case MT6370_ICHG_800_mA: > - *val1 = 2680; > + *val1 = mt6370_adc_get_ibat_scale(priv); > break; > default: > *val1 = 5000; > @@ -251,6 +278,19 @@ static const struct iio_chan_spec mt6370_adc_channels[] = { > MT6370_ADC_CHAN(TEMP_JC, IIO_TEMP, 12, BIT(IIO_CHAN_INFO_OFFSET)), > }; > > +static int mt6370_get_vendor_info(struct mt6370_adc_data *priv) > +{ > + unsigned int dev_info; > + int ret; > + > + ret = regmap_read(priv->regmap, MT6370_REG_DEV_INFO, &dev_info); > + if (ret) > + return ret; > + > + priv->vid = FIELD_GET(MT6370_VENID_MASK, dev_info); Blank line preferred before a simple return like this. Makes the code a tiny bit more readable. > + return 0; > +} > + > static int mt6370_adc_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -263,6 +303,10 @@ static int mt6370_adc_probe(struct platform_device *pdev) > if (!regmap) > return dev_err_probe(dev, -ENODEV, "Failed to get regmap\n"); > > + ret = mt6370_get_vendor_info(priv); The build bot spotted this one. Can't use priv yet as it doesn't exist for a few more lines. > + if (ret) > + return dev_err_probe(dev, ret, "Failed to get vid\n"); > + > indio_dev = devm_iio_device_alloc(dev, sizeof(*priv)); > if (!indio_dev) > return -ENOMEM;