From patchwork Tue May 23 15:12:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 98038 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3046:b0:115:7a1d:dabb with SMTP id p6csp2202241rwl; Tue, 23 May 2023 08:16:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ij0YNxTAPLkGL00BhtARY3yPLAHgTCWVDrDQRN6PdNIu82QTj+IHppfzTTX/AH1KWTkCZ X-Received: by 2002:a05:6a20:9388:b0:109:2f11:8b77 with SMTP id x8-20020a056a20938800b001092f118b77mr16523030pzh.1.1684854969051; Tue, 23 May 2023 08:16:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684854969; cv=none; d=google.com; s=arc-20160816; b=KPLoVliIxfWhPCNNZBpLqRbU/55dAaGH8/a298nfL6phLraCKDje3nrYplHeuNqg27 lgAz3xDfghWhOBPRCcXiRUicWlQRJ7rySmanNRbuPIr3GPz8Cr6ZF9COwL4enrT6HnDV 98cag4DqqlxYqNjJwPllHbgI/U1Wm033RcK0/tB5UTB7ZSVz2cWjJS4bezaAL8i0RNWI PygT4MVfMOgUHkEG1zm/ZNWSKxQqFcdf8ISh8psuin2Vl1jUvccAqVX7lZXcQCUR8nsF o9tt8i3NBZ3V31WB948QEmPaSg2Ym6wwV6fzoxaYs/sNhqt87na/5sta+3I6dh7rtpCs 9Xvg== 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=B5Rp2Pe2hP+HZpzHQ6QCIJu8OkM1HG2ZQQx1TOta918=; b=r9M2wtsU9NGuM31Tp/COZYPGlRaggpqu0jDk6lHOcgK4mzzxFnaNB5F/y3bSDCDjdI UQCY3teNkzmV8t6iwxR72yRnORgAw0Hspiyv0lXos901A+YRPhQ/iCfawYLpQo5ezePt JCafyeIbSXSfgTnniK7HV1hgpTbZjNY18TF8Je4znC2kJz9h6rwjl2ISYk4XKeSVsi13 GcXRAqkYtj0QGpKfuXEaVW6NC3DTkz62SORWdJyQHJ3EvOV9YvaXpdgalE/BefoxMOrm BfHgEUqX0Q5/i+Lr+1KsryLU5Us3xwpLBkHyNmurkgkD7WWVpd8X6DI7YHosinaOGubQ KUuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=DCytTTlw; 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 e30-20020aa798de000000b0064d72691d73si1653315pfm.316.2023.05.23.08.15.56; Tue, 23 May 2023 08:16:09 -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=DCytTTlw; 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 S237475AbjEWPMy (ORCPT + 99 others); Tue, 23 May 2023 11:12:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237467AbjEWPMu (ORCPT ); Tue, 23 May 2023 11:12:50 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 115EB13E; Tue, 23 May 2023 08:12:45 -0700 (PDT) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id BB54AC0013; Tue, 23 May 2023 15:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1684854764; 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=B5Rp2Pe2hP+HZpzHQ6QCIJu8OkM1HG2ZQQx1TOta918=; b=DCytTTlwfYZ07XCnOC1y/PBxT/gt5Bv3UFAB1EGhRvleTo7U3AOLO8sxWlvI8yCC0E5kJS hpdV6Nx4P+qyD22hEu+LTLixj4X2zB/efzVU0C2VRSSinU3m/rfAcPup0BHVQSk3uxYh2P mFRLWDfTLBEW1GBVHtMaEeP7q5QAmR7hEaY2V4cwIUPHj2Ynid7erDgBv2fbMX7Hl3C6RA Ptx7ur7w85pztC+90lDvuhCgjxyjfuv32j7XqgLXnRmgq+2aYluashCX0sIDzD+SyjQeuo GXwV0M4nRAM/LZamGyqdUMVZ4aKLA/gi73pV79ZxUbqjigH9hGmJKAy5M8Yvfw== 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 Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v2 4/9] iio: consumer.h: Fix raw values documentation notes Date: Tue, 23 May 2023 17:12:18 +0200 Message-Id: <20230523151223.109551-5-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523151223.109551-1-herve.codina@bootlin.com> References: <20230523151223.109551-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_H2,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?1766698484022716896?= X-GMAIL-MSGID: =?utf-8?q?1766698484022716896?= 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 --- 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);