Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp62494ima; Thu, 25 Oct 2018 15:31:11 -0700 (PDT) X-Google-Smtp-Source: AJdET5ePE0K6enqfgPbTnNDz3A+UHcxgnG1dValkoscN1XhFs4N4YkHCUsJstcGEKh7jrA142Ej9 X-Received: by 2002:a62:8490:: with SMTP id k138-v6mr988085pfd.177.1540506671716; Thu, 25 Oct 2018 15:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540506671; cv=none; d=google.com; s=arc-20160816; b=fNxcp6xlUH4lhZTSUQF9Hz4VyvrPdG43TH/3lO1Lm7pOBws4Wu7Du0n4IBF5qRRRwv 57zurR+LwcSOWvj+yRzQw5Rpz/bfqmsfDmF0OuyS7X6FRiIV7la1gAcW6HGQ7Rgjqe5m WE9WyfFKcn619kLjxPMw291aJgk3eoA5zrqT5+KBLuldIdYfkUbXKPkkYjYE9R/CT7PE F66uvczfHEx4bLs955Vqyey0LY2qz9KULgFxW2pe/AdZs4Z8Mmgy+Vt9hs32yHMAdaE3 MFG50a34QqLeL47G5Zer/rvx6tG7kFvsZuD9J3T0cpgS8rLRipsoax6Hr8uQdb1i0mmv A0Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=S8vZmvdGUiC7CSK5dkt+m3y87P6zuXNe3u1DBd0mrVo=; b=A8OcwbLDwf4O88Tp1byrfvu2NuV1p/E+oViLXP1U9l5I432mb/QGhYwdiHr4unFcrF b83/+bf4tjC9/GFsln3+jbxJl4LO5Oj9Trv/a6WoLEI/93UWimJiYtwTgyFdQP5M3XQy M9Qur7aI28SZ5qtmqh1s0BoC6YclZHih1zP9w78Xgf/ehnCLp4R99DYc3Qi7dnL7hQwD 8MHY/tPTZroOl95DxzL74QhZ10H5dPtwYbJDNzUAicBoBr9VYZ9MRqKtPCCJAQBe+tvQ mfbBZMwL/CD52pLnGImDqJhdETBxBJh5WMYerzlWYEFpdqOoNYeIHiZvkvekKxVm5u+u 5nqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gORb6cHD; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5-v6si9507673pgj.506.2018.10.25.15.30.55; Thu, 25 Oct 2018 15:31:11 -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=@gmail.com header.s=20161025 header.b=gORb6cHD; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727537AbeJZHEj (ORCPT + 99 others); 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-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-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.19.1