Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1020786imd; Sat, 3 Nov 2018 15:51:10 -0700 (PDT) X-Google-Smtp-Source: AJdET5cg49zLsblM+0SUx+Ek9/R5jK+ekBDNtPXdYIDxn+rJQgeFNLxjbznUyzUKAEbdtzDFUWLU X-Received: by 2002:a17:902:a9cb:: with SMTP id b11-v6mr16562236plr.219.1541285470658; Sat, 03 Nov 2018 15:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541285470; cv=none; d=google.com; s=arc-20160816; b=ZFDXBKEbXvvqgNW1vEF/YvSgaLgY665jjytGC5oWRrXsOTDC1Ugkz3Oc+eSXkjVAvL l8U11oTc/U7Y3IGlDigxcg3RImsusQlBz+S7X1L81QcxSUFM8RKbN1xAZxNYIYVQrce6 bm1YftIaBX7Bv/Z0CrY1LhUCWYZqzCPQQwV49rKoEF1vS8C0anWBq1JXu2xaPZeNZS55 4FCvgIHjMJjFhzw6EmSGS1i+yWpcjlzxttKW36eWueM6dYznh1QP9j5/ekSzc9a4Egk3 JOg/9K7Kz5jXWYEcgG+fzVehkP/yyKitYWEQqhP5Xpd04aycdNx/P8RE62InySd/3GAI rnbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=m0AamTcm1g4t7bycgutx/ePAEZettKzmbxK6n56vTuo=; b=k2uZyRkYGhWmfl+1yCQOewJDKNY+ngVDgvdLqbOZI7z1JvVYxhlRnEnW8YivnMEmcH cPkWyHUx/MDIB+pdFEC+7Da9l0p6KKC7AtpO0qBldSwQW/kR2ybgSwOnevoQtzjku6t5 5Gs0Uq+c7+6IYGBOQixOSH/XshqO2a8ZWaP8Y1IpR2Rw4FoPSzYjYPprwL+7auWFa5LD bCuR9v2WcxbbSEFK/ubNJ0my1KXgPV9UT1TR3DOti+r+nJpcSmJ360NHH8rY02htRUAq 9zlOSIAfMJoLV3rGbU8M66dRLmlUO9/8Y6Jilj8Ce6COQno5sphIb38uWt7PBWtb4dWC dldg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@usp-br.20150623.gappssmtp.com header.s=20150623 header.b=xVuXDa7S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=usp.br Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3-v6si30841566pld.435.2018.11.03.15.50.56; Sat, 03 Nov 2018 15:51:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@usp-br.20150623.gappssmtp.com header.s=20150623 header.b=xVuXDa7S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=usp.br Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728814AbeKDIDE (ORCPT + 99 others); Sun, 4 Nov 2018 03:03:04 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:42695 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727087AbeKDIDD (ORCPT ); Sun, 4 Nov 2018 03:03:03 -0500 Received: by mail-qk1-f193.google.com with SMTP id u68so8938629qkg.9 for ; Sat, 03 Nov 2018 15:50:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp-br.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=m0AamTcm1g4t7bycgutx/ePAEZettKzmbxK6n56vTuo=; b=xVuXDa7SIAlQvPnjjEqBbluD0g7qOhssMDDXcJ4NVxL2IP8nNndDK2RVatjx+MHffm DlwmktP1oEZ34TqmR4dToUiSvQDRsEWbyzGlHQN+Lzk5D+uSqPUmRmsSgdQg2eQkTX6c birMcUVjD7EQhoLj78nxCfaOqc+Lux+1UufnYgWUA4TSHN5XAfasQpip/KAhJSXXenYU VM5AizT+3+4hZdbEIJqMogjC1LwOnElI+LfrL76QFtzrLlyEG+6GqQr2kStvAecxHZCk 9f+mmsA/XiarkEEY9Lk4nSBZifQfA8H/A5xc7p9b6TmU6TAL20MohUxAn5VWceKqYdRz lfoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=m0AamTcm1g4t7bycgutx/ePAEZettKzmbxK6n56vTuo=; b=SgNNsBMgXQmarj2cnG7Fn9NiPOwhD7Ov6aMMBxHzwdHWBnjukJjFf53PTqS+VspYOy h5VcboXOP/+0x6e0At9A7ab3vy4OdDY74bnKjMpnBYGJi52z8uMBJ2hiLRdsA2AlWsay jeAbvyP5RwAU40uVnsRXccYnl9e0yPwDyDeD8W6OP2VfcM5SVUgC6xGxoc8OcHYOhK2N f+ynXtjaDEu15DGzTRRleo2F/JIUv3SQiyyn2gWhRZOLvmjXBAsbKtbbNkH8hslIljjX et44G/lFWsNCFmQfIfR8A2d6zRZAGF4SmoRfG2UoxhAPS/fbaehnDQtoB/gQ/vErcd/M WdwA== X-Gm-Message-State: AGRZ1gKv+my5kHAmTrRaXYA4vgcoKeBp8PUYTQYISPG8OTibCimq9XzE h9B4H7t0UMREiDQptCH80YoLYw== X-Received: by 2002:ad4:5307:: with SMTP id y7mr16298887qvr.9.1541285422387; Sat, 03 Nov 2018 15:50:22 -0700 (PDT) Received: from mango.spo.virtua.com.br ([2804:14c:81:942d::1]) by smtp.gmail.com with ESMTPSA id 35-v6sm27550924qtu.69.2018.11.03.15.50.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Nov 2018 15:50:21 -0700 (PDT) From: Matheus Tavares To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, Victor Colombo Subject: [PATCH v3 5/6] staging:iio:ad2s90: Add IIO_CHAN_INFO_SCALE to channel spec and read_raw Date: Sat, 3 Nov 2018 19:49:47 -0300 Message-Id: <20181103224948.31014-6-matheus.bernardino@usp.br> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181103224948.31014-1-matheus.bernardino@usp.br> References: <20181103224948.31014-1-matheus.bernardino@usp.br> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds the IIO_CHAN_INFO_SCALE mask to ad2s90_chan and implements the relative read behavior at ad2s90_read_raw. Signed-off-by: Victor Colombo Signed-off-by: Matheus Tavares --- drivers/staging/iio/resolver/ad2s90.c | 30 +++++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 8f79cccf4814..9c168b7410d0 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -34,17 +34,29 @@ static int ad2s90_read_raw(struct iio_dev *indio_dev, int ret; struct ad2s90_state *st = iio_priv(indio_dev); - mutex_lock(&st->lock); - ret = spi_read(st->sdev, st->rx, 2); - if (ret < 0) { + switch (m) { + case IIO_CHAN_INFO_SCALE: + /* 2 * Pi / 2^12 */ + *val = 6283; /* mV */ + *val2 = 12; + return IIO_VAL_FRACTIONAL_LOG2; + case IIO_CHAN_INFO_RAW: + mutex_lock(&st->lock); + ret = spi_read(st->sdev, st->rx, 2); + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); + mutex_unlock(&st->lock); - return ret; - } - *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); - mutex_unlock(&st->lock); + return IIO_VAL_INT; + default: + break; + } - return IIO_VAL_INT; + return -EINVAL; } static const struct iio_info ad2s90_info = { @@ -55,7 +67,7 @@ static const struct iio_chan_spec ad2s90_chan = { .type = IIO_ANGL, .indexed = 1, .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), }; static int ad2s90_probe(struct spi_device *spi) -- 2.18.0