From patchwork Thu Oct 25 22:30:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renato Lui Geh X-Patchwork-Id: 10656763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B64913A4 for ; Thu, 25 Oct 2018 22:30:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CFBD2C4A5 for ; Thu, 25 Oct 2018 22:30:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8101E2C594; Thu, 25 Oct 2018 22:30:11 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 194CE2C4A5 for ; Thu, 25 Oct 2018 22:30:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726808AbeJZHEj (ORCPT ); Fri, 26 Oct 2018 03:04:39 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:37202 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726763AbeJZHEi (ORCPT ); Fri, 26 Oct 2018 03:04:38 -0400 Received: by mail-qt1-f194.google.com with SMTP id d14-v6so11914911qto.4; Thu, 25 Oct 2018 15:30:09 -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=S8vZmvdGUiC7CSK5dkt+m3y87P6zuXNe3u1DBd0mrVo=; b=gORb6cHDZ9Xsqvb2oeWBtl55DonGhhVaghZAuIP9SNcwV5zYLnNzsRxHimFPkYkKHs BMeqH19LUWviDdqPiHa8XbYijjw4YRb1wy8v6EWG9aTMnF/XGs3BqkafNr0r8w0RPXbO i419LH8XyDgICnoRTuWXaHMm56fQ3e9fMyI08qT0XuGX9gau6pWtSYr7L78AA6k/a6Wa nwaNPy9zr2OjzKTYZS+mSjyMtFwdlT4+MvlMrWJyCQwPuO+WXVAMqssW5ZUlKIGqVC/+ mpGc9ioI+NWuz3mRcZshKmS0HMtOna24T66uHdMi2+EWD8Us8DAxYdMpvpFt3q24sPTy TbDg== 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=S8vZmvdGUiC7CSK5dkt+m3y87P6zuXNe3u1DBd0mrVo=; b=jkPYU9bscpcpGgPUJ4oIaDlOo91cZbwWtNPQKanCad2l5gp5qvtgeEoXTk8VsVCb2O WKAobmObpZUoH9pnzFw4q+d8fjQ1h9Op9c2rH+TVlo/fiVNtC74Z4Yi0xZLrgCYoFPNV oJHLV15KBk6IpOhxSFiTzFo+9UMH5A0SsPV19jGXOHPl82AZXLGxWioF0yCH8JkfV9wH iGyPJjyDbzp2l4RT7kreOmcMYXkc54IPMAFUCcSB73ONcj8CvuwXVFLj3luwNKj6u9nM Lt6DXinoHAbGR+f3iq9uNgFX4Yn1PH15glOUghHASbWzAJ8z0nOIxdugjz59ZhET3Vaf iCxg== X-Gm-Message-State: AGRZ1gJJaja+b4Wlkb0DElN1Obd9srukrfMpqvmY0t/J1xgdlX6JePOq t7OGHBPhVnR6EQVeHrMhKbI= X-Google-Smtp-Source: AJdET5eDD5KtxyJuUHOfWb/oq2R/DOHUwKExBPlvNqm4SNjVAQFlwGigCB/4FzEa/d6mEa/IO9E9mg== X-Received: by 2002:ac8:33ad:: with SMTP id c42-v6mr1042922qtb.190.1540506609387; Thu, 25 Oct 2018 15:30:09 -0700 (PDT) Received: from renatolg ([186.220.20.163]) by smtp.gmail.com with ESMTPSA id y47-v6sm8619123qtc.15.2018.10.25.15.30.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Oct 2018 15:30:09 -0700 (PDT) Date: Thu, 25 Oct 2018 19:30:04 -0300 From: Renato Lui Geh To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, alexandru.Ardelean@analog.com, stefan.popa@analog.com, giuliano.belinassi@usp.br Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH v2 1/2] staging: iio: ad7780: update voltage on read Message-ID: <1f7b2c6ee0e18b1c43a8b27f482b08313c52d4e9.1540506298.git.renatogeh@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 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 ad7780 driver previously did not read the correct device output, as it read an outdated value set at initialization. It now updates its voltage on read. Signed-off-by: Renato Lui Geh --- drivers/staging/iio/adc/ad7780.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index b67412db0318..27972563bb6a 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -87,11 +87,15 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, long m) { struct ad7780_state *st = iio_priv(indio_dev); + int voltage_uv = 0; switch (m) { case IIO_CHAN_INFO_RAW: return ad_sigma_delta_single_conversion(indio_dev, chan, val); case IIO_CHAN_INFO_SCALE: + voltage_uv = regulator_get_voltage(st->reg); + if (voltage_uv) + st->int_vref_mv = voltage_uv/1000; *val = st->int_vref_mv * st->gain; *val2 = chan->scan_type.realbits - 1; return IIO_VAL_FRACTIONAL_LOG2; From patchwork Thu Oct 25 22:30:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renato Lui Geh X-Patchwork-Id: 10656765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA89314DE for ; Thu, 25 Oct 2018 22:30:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B914D2C594 for ; Thu, 25 Oct 2018 22:30:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A977E2C5F9; Thu, 25 Oct 2018 22:30:44 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 5F5722C594 for ; Thu, 25 Oct 2018 22:30:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726763AbeJZHFM (ORCPT ); Fri, 26 Oct 2018 03:05:12 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:39160 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbeJZHFM (ORCPT ); Fri, 26 Oct 2018 03:05:12 -0400 Received: by mail-qt1-f196.google.com with SMTP id g10-v6so11893343qtq.6; Thu, 25 Oct 2018 15:30:42 -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=GOH5FTRIP3FPe1Cf6mg0NjeaY1IjAp+qJmnzPVmJk30=; b=eYHc4jdtnwIaRYvfosi6txc39FCOSMUozoqneiD7TExsXsjp2Jxu7kgU3eo7K+czDg GLNjpEnhfuU/KgoSFcnI4nTEOAq8hVHcwApVS+LQm95c3AoUXVIlMY5tbBCE+iRS9iv3 mhOEKKDUK1xTqxBw9mb1sBys+sSOeZLQ3wMJCpfDiJdnzlM82dXYDNlgkE7JuRfwhtPw 3Og65Tm7lubSvTp5a6xrKOmAygp82DdTh7gNoO0MJW++9JkgbvoWO9VPu86IwiovOJd8 6bTzb33AJXTaXbCfvU5RgfljJvB+SUICspripBI5r2YRT4HXXt8KYSo9q2pTvtcyklmM +6SQ== 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=GOH5FTRIP3FPe1Cf6mg0NjeaY1IjAp+qJmnzPVmJk30=; b=IChF+96d5Ym7UjLoJKgLfhQzaO+w4C2lv6Pbrjl9pZ1NkSAKbgKTKwJBUnKW8rQ8PC bF8u/lLyWd6ibBi5S1AFIwhvlEgQkY30fGRu2KOtPbP+Hw+ZO8JDB6aby3RZiHSsYyl7 iasypbSG0egcImUr0RjY7JFq/gmlYL4FFgS4/UiY22b34CcLtEHOhbUcY1MFENLc2YuT RxFVdIcNR9NjUNx2SWIz6ZmBD3sBna6IdH6q3GiL9gtLuwYijhX6ITBa1mRzxWxTQwhP it6PgU91TZsuWSKtowlD5B9hyQM88uWp3pfX57Qn5zgDdOpKVKWnmx4iJpakem6LuSIk gmLw== X-Gm-Message-State: AGRZ1gLdxj2IWjRVBrFo4zxEjsPuPEOgZEAkJNm4hEfplRvWisUDG92z aZ0j/3cCsPS36iCWhdTp2Lo= X-Google-Smtp-Source: AJdET5dIDdEk5S3KHeIKgACmUOGGgLkpVHGThVIjJvvUi54v0k7h5tCMAJlxZg5NVijw+ZkK/MALPA== X-Received: by 2002:a0c:f047:: with SMTP id b7mr1037530qvl.236.1540506642441; Thu, 25 Oct 2018 15:30:42 -0700 (PDT) Received: from renatolg ([186.220.20.163]) by smtp.gmail.com with ESMTPSA id n47-v6sm8983755qtc.29.2018.10.25.15.30.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Oct 2018 15:30:42 -0700 (PDT) Date: Thu, 25 Oct 2018 19:30:37 -0300 From: Renato Lui Geh To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, alexandru.Ardelean@analog.com, stefan.popa@analog.com, giuliano.belinassi@usp.br Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH v2 2/2] staging: iio: ad7780: fix offset read value Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 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 Variable val subtracted an uninitialized value on IIO_CHAN_INFO_OFFSET. This was fixed by assigning the correct value instead. Signed-off-by: Renato Lui Geh --- drivers/staging/iio/adc/ad7780.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 27972563bb6a..06700fe554a2 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -100,7 +100,7 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, *val2 = chan->scan_type.realbits - 1; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_OFFSET: - *val -= (1 << (chan->scan_type.realbits - 1)); + *val = -(1 << (chan->scan_type.realbits - 1)); return IIO_VAL_INT; }