From patchwork Fri May 18 18:23:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Veenstra X-Patchwork-Id: 10411807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C44866031B for ; Fri, 18 May 2018 18:23:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B38BD28707 for ; Fri, 18 May 2018 18:23:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A825B287C1; Fri, 18 May 2018 18:23:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4845C28707 for ; Fri, 18 May 2018 18:23:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751588AbeERSXT (ORCPT ); Fri, 18 May 2018 14:23:19 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35745 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751049AbeERSXS (ORCPT ); Fri, 18 May 2018 14:23:18 -0400 Received: by mail-wm0-f68.google.com with SMTP id o78-v6so16871136wmg.0; Fri, 18 May 2018 11:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=+sv5BvUShL+4bkEs6M+e6zrL/rIJgqMHmfgEu9DxDY4=; b=kBkJ/oFmEqKaoVguFsjcc4ph/QanmqD5NPwJKVE8NXe48s22fnqbxMqMb4io3erqN3 65YBgQv0FnCXV7oOmiovvvsxwQ0Bf6b9MjVsoSOUmRCjMP+TP7HscSSC6ydPGJ61P6qu M9IZQLoQQ+0svZLkh3AaHXA4zNbE/jkTjIWhhOCGq21fTONzgMfhuag/BVb2exBImRxu iZmPhWuaziUg1/keBC7nTLnXWaopb3OITvLYex/lse3JNmd/ExKzFuHRTCrKyKtex58I vy+mBmQQJC+Dbic50T9aP90Vi6qnm57E09qQeK7a8WbBuaQt4vfvzOHPDYW8dNYC7TMk WsgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+sv5BvUShL+4bkEs6M+e6zrL/rIJgqMHmfgEu9DxDY4=; b=c8l/FYKo50Tn33R3HEbFFTA2QcWmOnyzKkU/UeRrcYrer/woK1+Kh6L8d1VSYSYME3 5IudyYFBNi0xOGIsB4k0UwZIXKqq760Ub8J1KFo3B+GBk6o4oLRaixLPv/8opml8iz+1 RhQEyimUeBFmSeaYjSyz8xnKisKlLe3/AC5AsyjfhS9DmanO2hZ9Zax1cMoYvL5NnZqd JqMdyBTdnLjkJgqnFc3rhpFP0SiakBrAiAr80Nd7tn45dSa301UGHnMJWdgfJVZe51OX FvvQhdYu6P0M80bFIKOYqOGpQ+dWyP3sQcGla1iQkVZzKo5ecAqbJsDGf+hgwDRbfAqV Nnmg== X-Gm-Message-State: ALKqPwcjJmVS72rCokxx5ghNggMBG89dvfN63W/TStacfTzySqyq2Wje yjc/ELlY16HwCaQq+/lE2b4= X-Google-Smtp-Source: AB8JxZpRZtQNnaIFBl747//ekqdQrwOcaihiSgq607kOI6k330Typ3/cu5/DYi9nKUPUl8fRQelABg== X-Received: by 2002:a50:ab82:: with SMTP id u2-v6mr12850976edc.163.1526667797662; Fri, 18 May 2018 11:23:17 -0700 (PDT) Received: from zenbook-arch (s559434a1.adsl.online.nl. [85.148.52.161]) by smtp.gmail.com with ESMTPSA id v14-v6sm4114391edi.91.2018.05.18.11.23.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 May 2018 11:23:17 -0700 (PDT) Date: Fri, 18 May 2018 20:23:14 +0200 From: David Veenstra To: jic23@kernel.org, lars@metafoo.de, pmeerw@pmeerw.net, robh+dt@kernel.org Cc: Michael.Hennerich@analog.com, knaack.h@gmx.de, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, devicetree@vger.kernel.org Subject: [PATCH v4 10/12] staging: iio: ad2s1200: Add scaling factor for angle channel Message-ID: <559356a5b2467bd871e12460faa4edb3c80980ec.1526667118.git.davidjulianveenstra@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A scaling factor of approximately 2 * Pi / (2^12 -1) is added, to scale the 12-bits angular position to radians. A return type of IIO_VAL_INT_PLUS_NANO is used, so that the scale of both the angle channel and angular velocity channel has 7 significant digits. Signed-off-by: David Veenstra --- drivers/staging/iio/resolver/ad2s1200.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index 7b8af558e921..10d6d79dce79 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -58,6 +58,11 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_SCALE: switch (chan->type) { + case IIO_ANGL: + /* 2 * Pi / (2^12 - 1) ~= 0.001534355 */ + *val = 0; + *val2 = 1534355; + return IIO_VAL_INT_PLUS_NANO; case IIO_ANGL_VEL: /* 2 * Pi ~= 6.283185 */ *val = 6; @@ -112,6 +117,7 @@ static const struct iio_chan_spec ad2s1200_channels[] = { .indexed = 1, .channel = 0, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), }, { .type = IIO_ANGL_VEL, .indexed = 1,