From patchwork Sun Mar 18 13:37:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Veenstra X-Patchwork-Id: 10291173 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 7805160385 for ; Sun, 18 Mar 2018 13:37:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 662EA28E11 for ; Sun, 18 Mar 2018 13:37:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A8982900F; Sun, 18 Mar 2018 13:37:09 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 E6E6A28E11 for ; Sun, 18 Mar 2018 13:37:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753966AbeCRNhI (ORCPT ); Sun, 18 Mar 2018 09:37:08 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:52820 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752372AbeCRNhI (ORCPT ); Sun, 18 Mar 2018 09:37:08 -0400 Received: by mail-wm0-f68.google.com with SMTP id l9so1600161wmh.2 for ; Sun, 18 Mar 2018 06:37:07 -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=q89DSAUGyov5wBCvpaUPiO50lS0KEyoDUsxKfEUvDOM=; b=HjrMnp1V/uEjk3KH3dhw2eIB3SSp6Ry75GXKd5xeO0qMmxc1yKQhbQNYJp2oX1vnNk M/xhMwoUlkCI6917tWKzudEEBZcGm4X/l+v4oxfJ77niSDQpZfKKv3QUoalSaf69GK8Z IEPFzApgaBo+shc+gYZSR8TLNxmnDaxdtDK2ZFIpVD9qVjgYlfdd1Al4FnfiB7sqFirf NxGmk6+MIf4DF63prm2j88BUrw7Ns1tEAMtOnjS2x25WjhVSj73wdAiaw5V/snyxNV/7 FX+GO/3EGze8h7VhTcuTig6faG4ArcON8SxO24VvzNGGLDluVyGMRqCdu98azOZIVrFx jS9Q== 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=q89DSAUGyov5wBCvpaUPiO50lS0KEyoDUsxKfEUvDOM=; b=bgE4LRIENdqXBNwZN+OFiOSGJKWpvGkF2hV61VK3SSyQePoiQvYOjRIs52BpDNuUfR 3X/pIQ49+BLz6wyDOqBgTjmQReghBCc8GWU8VDE1Vy+UT2fEwj6sAL5san2nrV3W1Jde xRDMSDTuOxOMe/Djmldhp7DWFA4azswiNgGCG67TlDnMHbkIEJPD4y0LmiF7wEUXGYkX btrarl0WfzausG4S4QgNzLmNN9cMu/9ibDswY69mfgIw6dbG3hrTn6jw5sR5nIucWrbZ +btQQ+n2z0J1HtU/9duaRv1PzbK+0o4kfcU9cj0VeHX5gtHpwXtUt580pIe5UwqRoV0T puxQ== X-Gm-Message-State: AElRT7EQuHYO5z/33dRp/mZHmSDmAQ6E8yQIXAg1wXyQAwEBTtceZsCs dGhWI43MKN0RFs9nAcYL4Rc= X-Google-Smtp-Source: AG47ELuR1lewQjKEwe0eufz0B4MrCTBM8kqgLJD4sMHKwRFIXPZo0GxjmF5UHs3e02fqQ02SmWJ/BA== X-Received: by 10.80.187.75 with SMTP id y69mr10009868ede.251.1521380226929; Sun, 18 Mar 2018 06:37:06 -0700 (PDT) Received: from zenbook-arch (s559434a1.adsl.online.nl. [85.148.52.161]) by smtp.gmail.com with ESMTPSA id i7sm7304060edk.7.2018.03.18.06.37.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 Mar 2018 06:37:06 -0700 (PDT) Date: Sun, 18 Mar 2018 14:37:04 +0100 From: David Veenstra To: lars@metafoo.de, jic23@kernel.org Cc: Michael.Hennerich@analog.com, knaack.h@gmx.de, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org Subject: [PATCH 10/11] staging: iio: ad2s1200: Replace angle channel with inclination channel Message-ID: <73912d42bd2718325313ec792f8402a20f47405c.1521379685.git.davidjulianveenstra@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) 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 The angle channel is not defined in sysfs iio ABI. So it is replaced with an inclination channel, because it is defined in the ABI, and has the semantics of an angle. In addition, a fractional scaling factor of 360 / (2^12 -1) is added, to scale the 12-bits angular position to degrees, conform the ABI. Signed-off-by: David Veenstra --- drivers/staging/iio/resolver/ad2s1200.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index 4b97a106012c..937676bcc0d4 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -64,6 +64,10 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_SCALE: switch (chan->type) { + case IIO_INCLI: + *val = 360; + *val2 = 0xFFF; + return IIO_VAL_FRACTIONAL; case IIO_ANGL_VEL: /* * 2 * Pi is almost equal to @@ -91,7 +95,7 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, /* delay (6 * AD2S1200_TSCLK + 20) nano seconds */ udelay(1); gpiod_set_value(st->sample, 1); - gpiod_set_value(st->rdvel, !!(chan->type == IIO_ANGL)); + gpiod_set_value(st->rdvel, !!(chan->type == IIO_INCLI)); ret = spi_read(st->sdev, st->rx, 2); if (ret < 0) { @@ -101,7 +105,7 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, vel = be16_to_cpup((__be16 *)st->rx); switch (chan->type) { - case IIO_ANGL: + case IIO_INCLI: *val = vel >> 4; ret = IIO_VAL_INT; break; @@ -128,10 +132,11 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, static const struct iio_chan_spec ad2s1200_channels[] = { { - .type = IIO_ANGL, + .type = IIO_INCLI, .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,