Message ID | d31f2ebf08837337d3bbc6a00fd4b5eb3c86a04e.1681301472.git.mazziesaccount@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp296095vqo; Wed, 12 Apr 2023 05:45:01 -0700 (PDT) X-Google-Smtp-Source: AKy350Zg4Xm9u0py2bSi0uiP1q7dzK6PrsU4mOzHcC4pXJ77q5F5mlzp2BGRWVfKBcAJhI3iiDZT X-Received: by 2002:a17:906:43c6:b0:931:af6a:ad08 with SMTP id j6-20020a17090643c600b00931af6aad08mr1836668ejn.57.1681303501538; Wed, 12 Apr 2023 05:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681303501; cv=none; d=google.com; s=arc-20160816; b=tGxwN6QiST+NDFHAyIRupfl2iZDz88iD5r8ZnQcReTFbLYnj1RlDaD3LndilULCkIX Qioxm6exvuxpfMfQ8GsFzIPsT+yWwwP00aimLRKEbAQ/SQ55Tt9dkCiGFOeE4RADFFkq zm9QCQl9RCpMYGfRRxpu35Dk0VUKUYWHYv4/Zq5UCc8UV1uLWHdxUiXqcnj8Ww5DkoZT JhuWaPqjOWkHUEdaQ9SsEEJOZ/LJ/xrDtZEi5pVxEIV/ErPKQMRyJbwdJxs2JZOWO462 YOsrdsRGApZSuLRkgZwLIH2ohyiSZNKWw0JDTo3ENqPRRS5YRuczb//dOBkjLNBzv+V0 c2vw== 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=sgOwPu+FboPmTEq+F0N4Fog/45+TxGJHI0yCy72fcPY=; b=FBH0EBUufUqkTWqvlIM20zYgA8enzD5K1N3XPL1/QbR/QgEYy1nrz2AVLXkmZG7W3X ZRr7B3AuUYFntMi44lU7qspVJlFkH/hNb7OnyJg3NDS1/MrkGzOB/YCF1TJeTKVeegI6 R9aG57bCELTcKrwAHKef9SPe/drSazqJWoUxfws7xev3NAadiOdjqDvTRwa786WU7HI7 9333kXFxXRfMquuYYlFlnmvbtHiSkLknRivx/dxcVnYEIovxLfaEi+PpF85snzBOO0y1 9utO4MgQreeNfi1l8G8o3Kq7OyVlrTJc69yACcZ/kgB4SQCGVQpAF5KFdgs+8vX6BnZ7 8JBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=bUGFSLOH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id tg15-20020a1709078dcf00b0094a97ed58b8si5886892ejc.687.2023.04.12.05.44.37; Wed, 12 Apr 2023 05:45:01 -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=@gmail.com header.s=20221208 header.b=bUGFSLOH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229933AbjDLM1l (ORCPT <rfc822;peter110.wang@gmail.com> + 99 others); Wed, 12 Apr 2023 08:27:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231643AbjDLM1g (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 12 Apr 2023 08:27:36 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5017030EE; Wed, 12 Apr 2023 05:27:26 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id t20so14439552lfd.5; Wed, 12 Apr 2023 05:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681302444; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=sgOwPu+FboPmTEq+F0N4Fog/45+TxGJHI0yCy72fcPY=; b=bUGFSLOHSf8IOPs0vBg4h3142MTO/Uar2S7LbKDhUcqBXArUyeIogzmCBzqZpLXbOv 6LEcsgmaK5Iz536y7HqVscXtUbwLtyt6isKczHv7M851ZqYxFF2C1PLxawMExL1/rJtx cXQJ1wkeyR4oiJNPQX/aoYi5FapO4QAG/EyARlWXGnLD5ZUrUe9jOznW2cmp7hVS1u7A g+dZaNUjXBPvbBlef8wczMA5/f7iyn0hByjFS4Yw+aeL2O6vt3I/VBiQHPdJ06vbJv7n UJprE3rDrj7y9Ud3K/iJDpBQ/NGBuzJtbkyPoutOGfEePpFB9DeLjzsmIW0y7dHDflxU e8/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681302444; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=sgOwPu+FboPmTEq+F0N4Fog/45+TxGJHI0yCy72fcPY=; b=TS5j7l6NxcNnqz7+K/xK1agVy9J4dTwwwwTjmylQyXSAhk6npRxGPNdhrx8jSaSCCp thfYXXYHqeufASOMljDSVHz7vrAZniuXhNXxyQBZAiV7CTcbuv9dSWHAUJyYiwPmN2Cm NfVl5aRVFEDLJDBrcHvGEnojVemmRB1Uq/7+hyOBq/T2YwY5mJnNxlWNHaCqDDOyqmxn f3+O5NPGsRkk3dXGRBHrm82EjFCFipmknU3I/OwctaQiX7vrk0bXqPappjodRS5x452G e1No0WMoT6T2fQudhCiSBOclc9uZviIPPViBZjV7x9Ymd4K9mKj7bsmuPRsQkSs7+fWc hC2w== X-Gm-Message-State: AAQBX9cGY4msQ/gspEF4jkcUs1KFw6f0jbUhXAOGg5Eue6rexyrJys/w 6WupzRcNq/2H95rZM9LQkuc= X-Received: by 2002:ac2:44a3:0:b0:4e9:bf52:7898 with SMTP id c3-20020ac244a3000000b004e9bf527898mr566918lfm.37.1681302444438; Wed, 12 Apr 2023 05:27:24 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::1]) by smtp.gmail.com with ESMTPSA id z20-20020ac25df4000000b004d85895d7e0sm2984411lfq.147.2023.04.12.05.27.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 05:27:23 -0700 (PDT) Date: Wed, 12 Apr 2023 15:27:14 +0300 From: Matti Vaittinen <mazziesaccount@gmail.com> To: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Cc: Jonathan Cameron <jic23@kernel.org>, Lars-Peter Clausen <lars@metafoo.de>, Matti Vaittinen <mazziesaccount@gmail.com>, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] iio: core: add IIO_VAL_INT_MICRO Message-ID: <d31f2ebf08837337d3bbc6a00fd4b5eb3c86a04e.1681301472.git.mazziesaccount@gmail.com> References: <cover.1681301472.git.mazziesaccount@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gz1hgTNomGVmMv2T" Content-Disposition: inline In-Reply-To: <cover.1681301472.git.mazziesaccount@gmail.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762974500216697977?= X-GMAIL-MSGID: =?utf-8?q?1762974500216697977?= |
Series |
iio: Fix integration time units for iio-gts
|
|
Commit Message
Matti Vaittinen
April 12, 2023, 12:27 p.m. UTC
There are a few cases like light sensor integration times, where values
returned from *_available() and read_raw() are smaller than 1 and often
in the units of micro. (Like micro second scale integration times,
always smaller than 1 second). Currently those are often handled using
IIO_VAL_INT_PLUS_MICRO, which requires drivers to initialize the integer
part to zero. Furthermore, using IIO_VAL_INT_PLUS_MICRO in iio lists
requires one to always allocate the 'dummy' integer part too.
Introduce IIO_VAL_INT_MICRO which allows omitting the always zero integer.
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
---
drivers/iio/industrialio-core.c | 4 ++++
include/linux/iio/types.h | 1 +
2 files changed, 5 insertions(+)
Comments
On Wed, 12 Apr 2023 15:27:14 +0300 Matti Vaittinen <mazziesaccount@gmail.com> wrote: > There are a few cases like light sensor integration times, where values > returned from *_available() and read_raw() are smaller than 1 and often > in the units of micro. (Like micro second scale integration times, > always smaller than 1 second). Currently those are often handled using > IIO_VAL_INT_PLUS_MICRO, which requires drivers to initialize the integer > part to zero. Furthermore, using IIO_VAL_INT_PLUS_MICRO in iio lists > requires one to always allocate the 'dummy' integer part too. > > Introduce IIO_VAL_INT_MICRO which allows omitting the always zero integer. > > Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Hi Matti, I'm not keen on adding yet another case just to avoid having to have the integer part for IIO_VAL_INT_PLUS_MICRO. Seems like the wrong trade off of maintainability vs ease of use. Jonathan > --- > drivers/iio/industrialio-core.c | 4 ++++ > include/linux/iio/types.h | 1 + > 2 files changed, 5 insertions(+) > > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c > index c117f50d0cf3..c5ae965e9961 100644 > --- a/drivers/iio/industrialio-core.c > +++ b/drivers/iio/industrialio-core.c > @@ -628,6 +628,8 @@ static ssize_t __iio_format_value(char *buf, size_t offset, unsigned int type, > switch (type) { > case IIO_VAL_INT: > return sysfs_emit_at(buf, offset, "%d", vals[0]); > + case IIO_VAL_INT_MICRO: > + return sysfs_emit_at(buf, offset, "0.%06u", vals[0]); > case IIO_VAL_INT_PLUS_MICRO_DB: > scale_db = true; > fallthrough; > @@ -758,6 +760,7 @@ static ssize_t iio_format_list(char *buf, const int *vals, int type, int length, > > switch (type) { > case IIO_VAL_INT: > + case IIO_VAL_INT_MICRO: > stride = 1; > break; > default: > @@ -952,6 +955,7 @@ static ssize_t iio_write_channel_info(struct device *dev, > case IIO_VAL_INT_PLUS_MICRO_DB: > scale_db = true; > fallthrough; > + case IIO_VAL_INT_MICRO: > case IIO_VAL_INT_PLUS_MICRO: > fract_mult = 100000; > break; > diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h > index 82faa98c719a..b4e316172c7f 100644 > --- a/include/linux/iio/types.h > +++ b/include/linux/iio/types.h > @@ -30,6 +30,7 @@ enum iio_event_info { > #define IIO_VAL_FRACTIONAL 10 > #define IIO_VAL_FRACTIONAL_LOG2 11 > #define IIO_VAL_CHAR 12 > +#define IIO_VAL_INT_MICRO 13 /* val is micro <units>. Integer part is 0 */ > > enum iio_available_type { > IIO_AVAIL_LIST,
Hi Jonathan, On 4/12/23 23:32, Jonathan Cameron wrote: > On Wed, 12 Apr 2023 15:27:14 +0300 > Matti Vaittinen <mazziesaccount@gmail.com> wrote: > >> There are a few cases like light sensor integration times, where values >> returned from *_available() and read_raw() are smaller than 1 and often >> in the units of micro. (Like micro second scale integration times, >> always smaller than 1 second). Currently those are often handled using >> IIO_VAL_INT_PLUS_MICRO, which requires drivers to initialize the integer >> part to zero. Furthermore, using IIO_VAL_INT_PLUS_MICRO in iio lists >> requires one to always allocate the 'dummy' integer part too. >> >> Introduce IIO_VAL_INT_MICRO which allows omitting the always zero integer. >> >> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> > Hi Matti, > > I'm not keen on adding yet another case just to avoid having to > have the integer part for IIO_VAL_INT_PLUS_MICRO. > Seems like the wrong trade off of maintainability vs ease of use. I see your point. I would still argue that adding the IIO_VAL_INT_MICRO was not really an intrusive change and I'd expect the maintenance effort should not be increased that much. While the inconvenience for users in read_raw (initializing the *val = 0) is minor (meaning the benefit of adding IIO_VAL_INT_MICRO is also minor in this regard), iio_lists are stronger reason to consider this. With IIO_VAL_INT_MICRO the iio-list memory footprint will be halved. In my opinion, this benefit would exceed the cost of maintenance effort increase - sure thing it's easy for me to say as I am not the maintainer ;) (And as I wrote, this series was cooked in a hurry - I had no time to go through existing drivers to see how many could benefit from the new IIO_VAL_INT_MICRO. I may do this later when I get some pretty urgent things off my shoulders - assuming you're not opposing this change so strongly that this is out of the question no matter how many existing users could benefit from IIO_VAL_INT_MICRO). Anyways, if this is your final stance, then I need to rework the integration time list allocations in the gts helper, but I am most likely not able to do this until a week or two from now - meaning it might be better to revert the bu27034 and iio-gts-helpers until this gets fixed. (I reserve the right to do this during some night if I can't get sleep though.) Yours, -- Matti > Jonathan > >> --- >> drivers/iio/industrialio-core.c | 4 ++++ >> include/linux/iio/types.h | 1 + >> 2 files changed, 5 insertions(+) >> >> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c >> index c117f50d0cf3..c5ae965e9961 100644 >> --- a/drivers/iio/industrialio-core.c >> +++ b/drivers/iio/industrialio-core.c >> @@ -628,6 +628,8 @@ static ssize_t __iio_format_value(char *buf, size_t offset, unsigned int type, >> switch (type) { >> case IIO_VAL_INT: >> return sysfs_emit_at(buf, offset, "%d", vals[0]); >> + case IIO_VAL_INT_MICRO: >> + return sysfs_emit_at(buf, offset, "0.%06u", vals[0]); >> case IIO_VAL_INT_PLUS_MICRO_DB: >> scale_db = true; >> fallthrough; >> @@ -758,6 +760,7 @@ static ssize_t iio_format_list(char *buf, const int *vals, int type, int length, >> >> switch (type) { >> case IIO_VAL_INT: >> + case IIO_VAL_INT_MICRO: >> stride = 1; >> break; >> default: >> @@ -952,6 +955,7 @@ static ssize_t iio_write_channel_info(struct device *dev, >> case IIO_VAL_INT_PLUS_MICRO_DB: >> scale_db = true; >> fallthrough; >> + case IIO_VAL_INT_MICRO: >> case IIO_VAL_INT_PLUS_MICRO: >> fract_mult = 100000; >> break; >> diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h >> index 82faa98c719a..b4e316172c7f 100644 >> --- a/include/linux/iio/types.h >> +++ b/include/linux/iio/types.h >> @@ -30,6 +30,7 @@ enum iio_event_info { >> #define IIO_VAL_FRACTIONAL 10 >> #define IIO_VAL_FRACTIONAL_LOG2 11 >> #define IIO_VAL_CHAR 12 >> +#define IIO_VAL_INT_MICRO 13 /* val is micro <units>. Integer part is 0 */ >> >> enum iio_available_type { >> IIO_AVAIL_LIST, >
On Thu, 13 Apr 2023 08:48:08 +0300 Matti Vaittinen <mazziesaccount@gmail.com> wrote: > Hi Jonathan, > > On 4/12/23 23:32, Jonathan Cameron wrote: > > On Wed, 12 Apr 2023 15:27:14 +0300 > > Matti Vaittinen <mazziesaccount@gmail.com> wrote: > > > >> There are a few cases like light sensor integration times, where values > >> returned from *_available() and read_raw() are smaller than 1 and often > >> in the units of micro. (Like micro second scale integration times, > >> always smaller than 1 second). Currently those are often handled using > >> IIO_VAL_INT_PLUS_MICRO, which requires drivers to initialize the integer > >> part to zero. Furthermore, using IIO_VAL_INT_PLUS_MICRO in iio lists > >> requires one to always allocate the 'dummy' integer part too. > >> > >> Introduce IIO_VAL_INT_MICRO which allows omitting the always zero integer. > >> > >> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> > > Hi Matti, > > > > I'm not keen on adding yet another case just to avoid having to > > have the integer part for IIO_VAL_INT_PLUS_MICRO. > > Seems like the wrong trade off of maintainability vs ease of use. > > I see your point. I would still argue that adding the IIO_VAL_INT_MICRO > was not really an intrusive change and I'd expect the maintenance effort > should not be increased that much. Little things add up. :( > > While the inconvenience for users in read_raw (initializing the *val = > 0) is minor (meaning the benefit of adding IIO_VAL_INT_MICRO is also > minor in this regard), iio_lists are stronger reason to consider this. > With IIO_VAL_INT_MICRO the iio-list memory footprint will be halved. In > my opinion, this benefit would exceed the cost of maintenance effort > increase - sure thing it's easy for me to say as I am not the maintainer > ;) (And as I wrote, this series was cooked in a hurry - I had no time to > go through existing drivers to see how many could benefit from the new > IIO_VAL_INT_MICRO. I may do this later when I get some pretty urgent > things off my shoulders - assuming you're not opposing this change so > strongly that this is out of the question no matter how many existing > users could benefit from IIO_VAL_INT_MICRO). > > Anyways, if this is your final stance, then I need to rework the > integration time list allocations in the gts helper, but I am most > likely not able to do this until a week or two from now - meaning it > might be better to revert the bu27034 and iio-gts-helpers until this > gets fixed. (I reserve the right to do this during some night if I can't > get sleep though.) I don't think I'll be convinced on this for a couple of reasons: 1) It will inevitably lead to IIO_VAL_INT_NANO etc 2) There are other places this matters such as consumer drivers that have to cope with a bunch of possible return types from accessing read_raw and write_raw via the in kernel interfaces. For example see drivers/iio/afe/iio-rescale.c That might feel like it doesn't matter for your device (which is true) we would want wide use and that means a bunch of special casing in the more generic consumer drivers and potentially even in the specific ones that are scattered in various other kernel subsystems. Hence please rework this to add the annoying 0s. Thanks, Jonathan > > Yours, > -- Matti > > > Jonathan > > > >> --- > >> drivers/iio/industrialio-core.c | 4 ++++ > >> include/linux/iio/types.h | 1 + > >> 2 files changed, 5 insertions(+) > >> > >> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c > >> index c117f50d0cf3..c5ae965e9961 100644 > >> --- a/drivers/iio/industrialio-core.c > >> +++ b/drivers/iio/industrialio-core.c > >> @@ -628,6 +628,8 @@ static ssize_t __iio_format_value(char *buf, size_t offset, unsigned int type, > >> switch (type) { > >> case IIO_VAL_INT: > >> return sysfs_emit_at(buf, offset, "%d", vals[0]); > >> + case IIO_VAL_INT_MICRO: > >> + return sysfs_emit_at(buf, offset, "0.%06u", vals[0]); > >> case IIO_VAL_INT_PLUS_MICRO_DB: > >> scale_db = true; > >> fallthrough; > >> @@ -758,6 +760,7 @@ static ssize_t iio_format_list(char *buf, const int *vals, int type, int length, > >> > >> switch (type) { > >> case IIO_VAL_INT: > >> + case IIO_VAL_INT_MICRO: > >> stride = 1; > >> break; > >> default: > >> @@ -952,6 +955,7 @@ static ssize_t iio_write_channel_info(struct device *dev, > >> case IIO_VAL_INT_PLUS_MICRO_DB: > >> scale_db = true; > >> fallthrough; > >> + case IIO_VAL_INT_MICRO: > >> case IIO_VAL_INT_PLUS_MICRO: > >> fract_mult = 100000; > >> break; > >> diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h > >> index 82faa98c719a..b4e316172c7f 100644 > >> --- a/include/linux/iio/types.h > >> +++ b/include/linux/iio/types.h > >> @@ -30,6 +30,7 @@ enum iio_event_info { > >> #define IIO_VAL_FRACTIONAL 10 > >> #define IIO_VAL_FRACTIONAL_LOG2 11 > >> #define IIO_VAL_CHAR 12 > >> +#define IIO_VAL_INT_MICRO 13 /* val is micro <units>. Integer part is 0 */ > >> > >> enum iio_available_type { > >> IIO_AVAIL_LIST, > > >
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index c117f50d0cf3..c5ae965e9961 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -628,6 +628,8 @@ static ssize_t __iio_format_value(char *buf, size_t offset, unsigned int type, switch (type) { case IIO_VAL_INT: return sysfs_emit_at(buf, offset, "%d", vals[0]); + case IIO_VAL_INT_MICRO: + return sysfs_emit_at(buf, offset, "0.%06u", vals[0]); case IIO_VAL_INT_PLUS_MICRO_DB: scale_db = true; fallthrough; @@ -758,6 +760,7 @@ static ssize_t iio_format_list(char *buf, const int *vals, int type, int length, switch (type) { case IIO_VAL_INT: + case IIO_VAL_INT_MICRO: stride = 1; break; default: @@ -952,6 +955,7 @@ static ssize_t iio_write_channel_info(struct device *dev, case IIO_VAL_INT_PLUS_MICRO_DB: scale_db = true; fallthrough; + case IIO_VAL_INT_MICRO: case IIO_VAL_INT_PLUS_MICRO: fract_mult = 100000; break; diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index 82faa98c719a..b4e316172c7f 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h @@ -30,6 +30,7 @@ enum iio_event_info { #define IIO_VAL_FRACTIONAL 10 #define IIO_VAL_FRACTIONAL_LOG2 11 #define IIO_VAL_CHAR 12 +#define IIO_VAL_INT_MICRO 13 /* val is micro <units>. Integer part is 0 */ enum iio_available_type { IIO_AVAIL_LIST,