Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3099893pxm; Mon, 28 Feb 2022 12:01:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzguN3YpneeEzj9KBmyuXWks/ap0UI23//QhzMf6RHqTuAEGmT1+qdw380jFns+77Aqrj0u X-Received: by 2002:a17:90a:bc89:b0:1bd:33ac:d293 with SMTP id x9-20020a17090abc8900b001bd33acd293mr9623546pjr.51.1646078467888; Mon, 28 Feb 2022 12:01:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646078467; cv=none; d=google.com; s=arc-20160816; b=aUddwSWLAf6pM6hdUqgFuXRTUMVd/HRjFaSDwxzkP4XZ5jObnNHplvACnMOn9WLvyN 6h7k2LXiJs8+VtQyVMlyWWFvM5+VnayAShCc4GHbqMr8X3Hy7bAR/ldC4hd7KImzKSSx Z7R0LOaMkDNrqo+KQN4pnEbLIWV5Py9e0QxB4HSQ5agrhdoSUhKYksWefQlzJZtFjIpR z+6dJkSyDmztCQ1HiAIoKT4Xpa9QZ0GEQ/BLjHpBBNeluvEqSfLazxliecde1Cr0td0f cbnhQRafVPbi/lYH2nCftKoKL2rIy4Kvz1SXKoaI+Lnjp9mSiCdEqr7xcecbuNp+/s99 foDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:sender:dkim-signature; bh=d1AmaAaEMdz2x5BUvuXaCe1mKX/9fT+CrQaw2mHcoFY=; b=S6aVkuq88VXKw6HxI6UBgMUDDb2yDjssZZW0PLF4vICArKjGZvZpeLpeuKbDrMnffb lwAprf5kPyoc+OaVJWWdu0AkCO+Wj3EgplJgVDsQp9oBVsohWJZmleW5MSgSvO570w7/ M7y2h2yymepJ7GFZ9RC5EdtFYPXo5IC6zK9BnF1Deg/tyiYSeaZa/GaMstag4c0Tot66 4CRRC0IpeGn2onJjoMWRCU006XjlZdRzr01HqgOKFtHI87pDpWqrDC3VWBhTqkuiwnfc y1CN6MKv4JqZ7gkxAE9EoByzyJfUmit7sY9LAzmKcTLZ9d14L0liQGc7qdz70L7o8T/4 XCkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="W/zV0DlB"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r2-20020a17090b050200b001bc62e27ccfsi348059pjz.99.2022.02.28.12.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:01:07 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="W/zV0DlB"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E4CF12220D; Mon, 28 Feb 2022 11:30:21 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240806AbiB1S3h (ORCPT + 99 others); Mon, 28 Feb 2022 13:29:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240876AbiB1S3Z (ORCPT ); Mon, 28 Feb 2022 13:29:25 -0500 Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2549EE61F0; Mon, 28 Feb 2022 10:12:43 -0800 (PST) Received: by mail-oo1-xc32.google.com with SMTP id 189-20020a4a03c6000000b003179d7b30d8so19745767ooi.2; Mon, 28 Feb 2022 10:12:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=d1AmaAaEMdz2x5BUvuXaCe1mKX/9fT+CrQaw2mHcoFY=; b=W/zV0DlBABRfKVI0YNf8QA1qRNlRfMuu2wPwwoPVjjgfZw1aFcV0K0J7KBighDG7mL jxnY/NZajJCuKB18+ubTx2H7eS/Ug0kUF9L/eYmqUjXMHzch3EaP2sXyGtf1FMdCASH0 P351C/3mVw4EYJizPlxIu1kgAh8Q+jUUWsGO/jvzSKL5J5x/yALc1kPYEOlubG+rhZO7 8IbN2GbHfob4dHmiBcv+O+8dnVmMalfo3bPoJwT7SdsoTPSoH7jw+cggk4PbwiuhquVR pATVs5/S0lO/ONWFC9FaeYd1XvLNOskQvRRE0JFd+U9LHfdRITq5993j7cLE2RrBQ5Qf MFhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=d1AmaAaEMdz2x5BUvuXaCe1mKX/9fT+CrQaw2mHcoFY=; b=aPw1tXdJ+6lxRKOUHQmN2uVah9d4PdGazae0FHvdPOgTXLrcoinORBc1gPbVdnbC/3 hkzrnKCBZYu23ylXgzquHVX6N0pVo0E7BXQ0qGu7NlVj6ym1WfiiVAhknmRTam0KZGhm 54byVRwcP4shfuRsaNnI8xLmROt1ZxQgT5u+JJrbpi9IrF2CdLKWY6zGcFX3CQn00WMo 9iS+vY8JxpXC4NwftDPQYr+YoVhH7nCcY8iMVQLjcPfEc588224Q9lcfdUnG1ALmVnfM 0fg5NsIffvJoGVWig7zfTEtGsKdYjCokYE/FCJkOL9VAKJjD161yera/iZttx2XmN+HS yfNw== X-Gm-Message-State: AOAM53263LZ+P4htGst9DcGNTz1GPfeWOlrs1fpp14vOsU/kCbw88nLG AtA0dykzb7SEXAvScCzU5qg= X-Received: by 2002:a4a:95d1:0:b0:317:9a32:fd21 with SMTP id p17-20020a4a95d1000000b003179a32fd21mr9502562ooi.89.1646071962172; Mon, 28 Feb 2022 10:12:42 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id a4-20020a9d6e84000000b005afe328af91sm3900287otr.54.2022.02.28.10.12.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Feb 2022 10:12:41 -0800 (PST) Sender: Guenter Roeck Message-ID: Date: Mon, 28 Feb 2022 10:12:39 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v3 1/2] hwmon: (adm1275) Allow setting sample averaging Content-Language: en-US To: Potin Lai , Jean Delvare , Rob Herring , Krzysztof Kozlowski Cc: Patrick Williams , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org References: <20220228103716.10774-1-potin.lai@quantatw.com> <20220228103716.10774-2-potin.lai@quantatw.com> From: Guenter Roeck In-Reply-To: <20220228103716.10774-2-potin.lai@quantatw.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 2/28/22 02:37, Potin Lai wrote: > Current driver assume PWR_AVG and VI_AVG as 1 by default, and user needs > to set sample averaging via sysfs manually. > > This patch parses the properties below from device tree, and setting > sample averaging during probe. Allowed input value from 1 to 128. If the > inputed value is not power of 2, the sample averaging number will be > configured with the smaller and cloest power of 2. > > - adi,power-sample-average > - adi,volt-curr-sample-average > > Signed-off-by: Potin Lai > --- > drivers/hwmon/pmbus/adm1275.c | 36 +++++++++++++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) > > diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c > index d311e0557401..212c7f3c59b0 100644 > --- a/drivers/hwmon/pmbus/adm1275.c > +++ b/drivers/hwmon/pmbus/adm1275.c > @@ -475,6 +475,7 @@ static int adm1275_probe(struct i2c_client *client) > int vindex = -1, voindex = -1, cindex = -1, pindex = -1; > int tindex = -1; > u32 shunt; > + u32 avg; > > if (!i2c_check_functionality(client->adapter, > I2C_FUNC_SMBUS_READ_BYTE_DATA > @@ -756,6 +757,41 @@ static int adm1275_probe(struct i2c_client *client) > return -ENODEV; > } > > + if (data->have_power_sampling && > + of_property_read_u32(client->dev.of_node, > + "adi,power-sample-average", &avg) == 0) { > + if (avg > ADM1275_SAMPLES_AVG_MAX || avg < 1) > + return -EINVAL; > + dev_info(&client->dev, > + "Setting power sample averaging number to %u", > + BIT(ilog2(avg))); > + ret = adm1275_write_pmon_config(data, client, true, > + ilog2(avg)); > + if (ret < 0) { > + dev_err(&client->dev, > + "Setting power sample averaging failed with error %d", > + ret); > + return ret; > + } > + } > + > + if (of_property_read_u32(client->dev.of_node, > + "adi,volt-curr-sample-average", &avg) == 0) { > + if (avg > ADM1275_SAMPLES_AVG_MAX || avg < 1) > + return -EINVAL; > + dev_info(&client->dev, > + "Setting voltage and current sample averaging number to %u", > + BIT(ilog2(avg))); Please no such logging noise. Imagine if everyone would do that - the log would be full with similar messages. Thanks, Guenter > + ret = adm1275_write_pmon_config(data, client, false, > + ilog2(avg)); > + if (ret < 0) { > + dev_err(&client->dev, > + "Setting voltage and current sample averaging failed with error %d", > + ret); > + return ret; > + } > + } > + > if (voindex < 0) > voindex = vindex; > if (vindex >= 0) {