From patchwork Wed Jun 14 07:48:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 107774 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1067095vqr; Wed, 14 Jun 2023 00:52:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4GYJ7saoRJAATXfIvcG0zwYIcRqG0ph3t9i3VEDFMW6+J/ykJ+WztfGlmGE73/aEZJxHHQ X-Received: by 2002:a17:907:9349:b0:977:eed1:4510 with SMTP id bv9-20020a170907934900b00977eed14510mr14839818ejc.21.1686729153854; Wed, 14 Jun 2023 00:52:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686729153; cv=none; d=google.com; s=arc-20160816; b=N1Q7bEZKYQjvx3hBxlxsysoUoOQoRsLiryqcX4BqAZ5IJmj5n4VsNk3SrzSMbnf9mN /C5TeJhi/t/l+4anhj9g2e9eeQ3Dd/kMIsGSghywHXNdYKjF6OvzSv5zZEJ02bTTd8Ms 2+tlPScMCkeHYhrkFNAuy6bhCPmPUyLtXMl1dMAO2vX0VNsUmMWNzXjyhJUI1JFqdXRt NBbMbF5IFXA15qs2VmgjJDLe96RVIZXeZtEW/EEGlhOnIcLl4S23jctQnih0sFqIQMrn X6JxzvZBjRZAkOKC0E+1h1OTZvOR7gfR7Z1cptXIEzqDLDmlGKGN7dSxfkSMn1pFcn1x 29xg== 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:date:subject:cc:to:from :dkim-signature; bh=rgrvFu84ZrZIMRnZAFcmpkUkbG8qISQlNfLp/T/UU5I=; b=VeUuPITACNEsqlA4VRfyJg1dzBr6vM/Pht0qC31xQx9z+eP/KTZu54QrhFsdbq5N5D D0nCi3z0TwEqk1hQQcMyl3km3ki1UepE7jAzeCwUcjgVAh2/SKFNzOhZgCMgXOllVipF UzTqdF21jzSYoe3SQjFFgpbVhuxvLYehApMHK9QtrGJWzKHIzPbXzvoPBF+mC5vROPW5 dmgiSkQO5KKBKIVdHW2xW2rQHqMfQZlb9UZtBMOJeDjd0zUBS3HVD4v8MHAB7MoRncmb 03lg8k02q5eDBD3vHGOje3brx9FQ1W//Cm8OfCNB/foJSc2zxK549cA60BodjluVaEYV OTvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oLJh22A5; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ch9-20020a170906c2c900b00977e0fde813si8354317ejb.1043.2023.06.14.00.52.10; Wed, 14 Jun 2023 00:52:33 -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=@bootlin.com header.s=gm1 header.b=oLJh22A5; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243504AbjFNHuc (ORCPT + 99 others); Wed, 14 Jun 2023 03:50:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243335AbjFNHth (ORCPT ); Wed, 14 Jun 2023 03:49:37 -0400 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD379170E; Wed, 14 Jun 2023 00:49:35 -0700 (PDT) X-GND-Sasl: herve.codina@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686728974; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rgrvFu84ZrZIMRnZAFcmpkUkbG8qISQlNfLp/T/UU5I=; b=oLJh22A5HuMXJQbcnfPT/Xol6viKiHPqVmtZge5Z0fe7d4zquT9pB8unrK400DQ1I+nyK7 JD/t9ZiFEUbaYdZWgdPvmRUYW3B88gBtBCnMnPhY1K9M3NDQ5iKZyp8g6eFD7UdIVzAwuF 9taeIDgJCoD7dw/g8YGHYC6zj6acJCjBhkBOAfw4gBqXgMybvOSSgIKjx3L1/D9FclY+3E 1bc7EUIOwzK3Ow6TCaOSfLdhtMOUmvy0WPhirIUazKY3PKPbe6YKB6c3C8ELPb6vsp/TPH wYstIbvp1stsk3UYySWsafTQhiwskrbRdeUs5RaxZE56+j+GG2XWOKJEkqNM1w== X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPA id 29D061C0016; Wed, 14 Jun 2023 07:49:33 +0000 (UTC) From: Herve Codina To: Herve Codina , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , Lars-Peter Clausen , Jaroslav Kysela , Takashi Iwai , Kuninori Morimoto , Andy Shevchenko Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Christophe Leroy , Thomas Petazzoni , Jonathan Cameron Subject: [PATCH v4 04/13] iio: consumer.h: Fix raw values documentation notes Date: Wed, 14 Jun 2023 09:48:55 +0200 Message-Id: <20230614074904.29085-5-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230614074904.29085-1-herve.codina@bootlin.com> References: <20230614074904.29085-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768663708973247512?= X-GMAIL-MSGID: =?utf-8?q?1768663708973247512?= The raw values notes mention 'ADC counts' and are not fully accurate. Reword the notes in order to remove the 'ADC counts' and describe the conversion needed between a raw value and a value in the standard units. Signed-off-by: Herve Codina Acked-by: Jonathan Cameron Reviewed-by: Andy Shevchenko --- include/linux/iio/consumer.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index 6802596b017c..f536820b9cf2 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h @@ -201,8 +201,9 @@ struct iio_dev * @chan: The channel being queried. * @val: Value read back. * - * Note raw reads from iio channels are in adc counts and hence - * scale will need to be applied if standard units required. + * Note, if standard units are required, raw reads from iio channels + * need the offset (default 0) and scale (default 1) to be applied + * as (raw + offset) * scale. */ int iio_read_channel_raw(struct iio_channel *chan, int *val); @@ -212,8 +213,9 @@ int iio_read_channel_raw(struct iio_channel *chan, * @chan: The channel being queried. * @val: Value read back. * - * Note raw reads from iio channels are in adc counts and hence - * scale will need to be applied if standard units required. + * Note, if standard units are required, raw reads from iio channels + * need the offset (default 0) and scale (default 1) to be applied + * as (raw + offset) * scale. * * In opposit to the normal iio_read_channel_raw this function * returns the average of multiple reads. @@ -281,8 +283,9 @@ int iio_read_channel_attribute(struct iio_channel *chan, int *val, * @chan: The channel being queried. * @val: Value being written. * - * Note raw writes to iio channels are in dac counts and hence - * scale will need to be applied if standard units required. + * Note that for raw writes to iio channels, if the value provided is + * in standard units, the affect of the scale and offset must be removed + * as (value / scale) - offset. */ int iio_write_channel_raw(struct iio_channel *chan, int val); @@ -292,8 +295,9 @@ int iio_write_channel_raw(struct iio_channel *chan, int val); * @chan: The channel being queried. * @val: Value read back. * - * Note raw reads from iio channels are in adc counts and hence - * scale will need to be applied if standard units are required. + * Note, if standard units are required, raw reads from iio channels + * need the offset (default 0) and scale (default 1) to be applied + * as (raw + offset) * scale. */ int iio_read_max_channel_raw(struct iio_channel *chan, int *val); @@ -308,8 +312,9 @@ int iio_read_max_channel_raw(struct iio_channel *chan, int *val); * For ranges, three vals are always returned; min, step and max. * For lists, all the possible values are enumerated. * - * Note raw available values from iio channels are in adc counts and - * hence scale will need to be applied if standard units are required. + * Note, if standard units are required, raw available values from iio + * channels need the offset (default 0) and scale (default 1) to be applied + * as (raw + offset) * scale. */ int iio_read_avail_channel_raw(struct iio_channel *chan, const int **vals, int *length);