From patchwork Mon Nov 5 19:14:58 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: 10668991 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 836DF15A6 for ; Mon, 5 Nov 2018 19:15:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71F0929B92 for ; Mon, 5 Nov 2018 19:15:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61F6429B9A; Mon, 5 Nov 2018 19:15:06 +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 0300A29B92 for ; Mon, 5 Nov 2018 19:15:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387891AbeKFEgL (ORCPT ); Mon, 5 Nov 2018 23:36:11 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:41147 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387659AbeKFEgL (ORCPT ); Mon, 5 Nov 2018 23:36:11 -0500 Received: by mail-qk1-f196.google.com with SMTP id 189so16784991qkj.8; Mon, 05 Nov 2018 11:15:03 -0800 (PST) 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=HiIV5c0pyju/OZ+2mp4LyYN/kJGYikFjdsbcyKgsdTE=; b=hpZk47D/nW6h1DgbyeUYNMBNMSaBKiCvhaTX9dht9ZyYmUSPzxt+r49XE8Q2jrQWrs ktyWkqYdUtRC5d99S2ZBHXWomstSU8cWVG/KkoiEFsxg1i3YCmRrbsJ8alB4yJSo3Mmd zGADia0zL+axz/mRDuNhKE90l+zFdp1orGvC4W1AeecSvVNi9t7k5KXda7Om+C3eQL90 /15ZQOnX5E/faWTirIiOUYipd0TLwNAjYvw28c369pdFa/yJqFrNoDauFkE6UzJPPmps EWrre8Dlf/BAAfp1hVXe9rJrT0KgT2vezPHoMrqW9SAfFtCL3ydiKyyQARrP+ekvosPh cbfw== 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=HiIV5c0pyju/OZ+2mp4LyYN/kJGYikFjdsbcyKgsdTE=; b=PBjcdGxb9Vr/IxM7WkLiz1Ba0Y2IZ5GqeuI48JwUJ1s8UmG86uBKEw9XuZBwBteG+S 0vm37PP8F4DqYiZNDYxKf/LBrvI661Rmktsigt9axjQ7STOSXnzyIktV1BahaGfuLpNo YYVyBpWF9u/R6qFCxExwdRFlTR9lv4OW/jnKVtOaqICt5ltW7hCQ91oNX5jo+0cDbUw+ JM+DA6jvuAz43r3SPuttgHNMXno41LrtD3zERb0eu+gdUWgAeGqpCrx8wIhM5yydapj0 Ki3w25GtHhsLTXh4rRD4Q4dtWDAmszV2MfbuJcNebxHSevFiVuTUmcY+Y+hT+yqpne4t doqQ== X-Gm-Message-State: AGRZ1gJ+q1VdVTwZsMrLZ1erto9krKWjhnnC+oKGSP/zY9M6RJ2qk3+9 lA2W6rb/w4sYSXnnzDAJnk4= X-Google-Smtp-Source: AJdET5fxSbr9ArhxZb2rifXjZePBGgNB6AGbB2hCese2PkTzSHkM0xL/l4xDqsqKkwuugBR17g5Bcw== X-Received: by 2002:a0c:aff9:: with SMTP id t54mr22541753qvc.93.1541445303455; Mon, 05 Nov 2018 11:15:03 -0800 (PST) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id 67sm11428931qku.60.2018.11.05.11.15.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Nov 2018 11:15:03 -0800 (PST) Date: Mon, 5 Nov 2018 17:14:58 -0200 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, 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 v4 1/2] staging: iio: ad7780: update voltage on read Message-ID: <4b47bd8f4bac2575b72529b37e5ac90bebae2446.1541444377.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 Acked-by: Alexandru Ardelean --- Changes in v3: - removed initialization (int voltage_uv = 0) - returns error when voltage_uv is null Changes in v4: - returns error when voltage_uv is negative drivers/staging/iio/adc/ad7780.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index b67412db0318..c7cb05cedbbc 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -87,12 +87,16 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, long m) { struct ad7780_state *st = iio_priv(indio_dev); + int voltage_uv; switch (m) { case IIO_CHAN_INFO_RAW: return ad_sigma_delta_single_conversion(indio_dev, chan, val); case IIO_CHAN_INFO_SCALE: - *val = st->int_vref_mv * st->gain; + voltage_uv = regulator_get_voltage(st->reg); + if (voltage_uv < 0) + return voltage_uv; + *val = (voltage_uv / 1000) * st->gain; *val2 = chan->scan_type.realbits - 1; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_OFFSET: From patchwork Mon Nov 5 19:16:14 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: 10668993 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 6D8ED15A6 for ; Mon, 5 Nov 2018 19:16:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5507329BCA for ; Mon, 5 Nov 2018 19:16:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45CA929BCF; Mon, 5 Nov 2018 19:16:21 +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 DF91D29BCA for ; Mon, 5 Nov 2018 19:16:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387488AbeKFEh1 (ORCPT ); Mon, 5 Nov 2018 23:37:27 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:43215 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387441AbeKFEh1 (ORCPT ); Mon, 5 Nov 2018 23:37:27 -0500 Received: by mail-qk1-f193.google.com with SMTP id r71so16775522qkr.10; Mon, 05 Nov 2018 11:16:19 -0800 (PST) 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=IL8R6y1gtaHkaLcJ+ACkXbSV0NqE62Dg14qzw/H8vqE=; b=L6D5QHgXEnf7t8DF1KyoKyUyW3HFGh5J9ZoW8f2iQkVTKZDhDurqw3iK4qFOxRvLKo pigaQlxQwbK78oFI0/xXoo/tFgXcpUDJPlQ5hPc3DrtZaHH0BnIvqb2b9NobY0xwHSW0 8uKYLOwCh9J8j0wkVJ/vOIfpqtpM9uwwrQ6W7dVCowKH+IR3GNdmdSEzHybpLv//Nig3 ZINhpNShw+rFUzqjTDQB/30k3u8BZGMmcfEwedEpz3b/rzAp04QF5W7br7Atc3niGUzF xUZd1rQaGwJaRlUy1dahTjn3OJZ04IFQWdQLY6+oSolbLpC7Gf+c9gUNqlDG/PfrQ3Oz n7Fw== 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=IL8R6y1gtaHkaLcJ+ACkXbSV0NqE62Dg14qzw/H8vqE=; b=aUwtTllq17LtPcskMJA2RhD+g/BuwNZ97a2fniULgGeQjmKxixAUv/oGPmN8k4n0kU x11V7ufMYfL3qQNkSTJFFkyE6nXGMDRKn9ixFAAxIEt/1BeOEdiAyDueMAizuq2hCTOc X05z6Qfw5/HZvk/J0mMbJRQrIgvQnDj7hBVNqCWTBrkM+V6qv0qDE1PU1JSRhZbxWNU5 ltPK2pNMQX2RWpir+jMjs0NYbBwzbCzEialr7P5D6VNgfYCNYmznxL6YSO17X8BcUT+E oeruFibCPYPGuIGnM3Q4F6Fgge6oa4P1hbI2/MpxiavZVKgwq9CUQ+XPs5xYEsikOIHt vP+A== X-Gm-Message-State: AGRZ1gJmlveGkD7rH82JMdJ+RPNsXpMn8BwIjVjVot+87qJ4Pv63pS+6 WYQjdXgb+2JqiRGD4JdDgQ0= X-Google-Smtp-Source: AJdET5fLmKLWWHCr9Orv5JzCnUGklmGdHaWq6nZD3Cczdqt2jPKMd4W+FOzhdDUVzwtSX/bpBgtOhw== X-Received: by 2002:a37:90c5:: with SMTP id s188-v6mr21684457qkd.104.1541445378692; Mon, 05 Nov 2018 11:16:18 -0800 (PST) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id b9-v6sm7208705qti.4.2018.11.05.11.16.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Nov 2018 11:16:18 -0800 (PST) Date: Mon, 5 Nov 2018 17:16:14 -0200 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, 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 v4 2/2] staging: iio: ad7780: remove unnecessary stashed voltage value Message-ID: <3920d49d888f63b600a4d2f2600921ed2900a470.1541444377.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 This patch removes the unnecessary field int_vref_mv in ad7780_state referring to the device's voltage. Signed-off-by: Renato Lui Geh --- Changes in v3: - removed unnecessary int_vref_mv from ad7780_state Changes in v4: - removed voltage reading on probe drivers/staging/iio/adc/ad7780.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index c7cb05cedbbc..52a914360574 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -42,7 +42,6 @@ struct ad7780_state { struct regulator *reg; struct gpio_desc *powerdown_gpio; unsigned int gain; - u16 int_vref_mv; struct ad_sigma_delta sd; }; @@ -165,7 +164,7 @@ static int ad7780_probe(struct spi_device *spi) { struct ad7780_state *st; struct iio_dev *indio_dev; - int ret, voltage_uv = 0; + int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) @@ -185,16 +184,10 @@ static int ad7780_probe(struct spi_device *spi) dev_err(&spi->dev, "Failed to enable specified AVdd supply\n"); return ret; } - voltage_uv = regulator_get_voltage(st->reg); st->chip_info = &ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data]; - if (voltage_uv) - st->int_vref_mv = voltage_uv / 1000; - else - dev_warn(&spi->dev, "Reference voltage unspecified\n"); - spi_set_drvdata(spi, indio_dev); indio_dev->dev.parent = &spi->dev;