From patchwork Thu Nov 1 14:43:02 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: 10664037 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 A233A1734 for ; Thu, 1 Nov 2018 14:43:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CC4A2BF97 for ; Thu, 1 Nov 2018 14:43:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AF5F2BFA1; Thu, 1 Nov 2018 14:43: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=-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 383422BF97 for ; Thu, 1 Nov 2018 14:43:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728661AbeKAXqY (ORCPT ); Thu, 1 Nov 2018 19:46:24 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:45090 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728175AbeKAXqY (ORCPT ); Thu, 1 Nov 2018 19:46:24 -0400 Received: by mail-qt1-f194.google.com with SMTP id l9-v6so21290203qtj.12; Thu, 01 Nov 2018 07:43: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=tfdzyVc2dvWvT4n/qpMEEt+E0mRmUmqg0MbxEnbWuGY=; b=siZpDaWwcnzlnpZ7Mi+9PRLG/8noeYjczwWHZmH8aOhw60SmileiRHoV/9HjFMvpDt /WFEK1VKCrC0dw9HR47J+7IUFB+uJBThQE5GQx3Bb69BUU+sNo6J/Z1F2UmuZydG03K1 bWNuc79MA9oJ0tl7Oocpq/x3swzUNZ7E+S23LbkPzZ7bcKMbqm5HNJFWsSTOe5+PO29H UoKWywscoiI1QXE82PAtknVRjK5a/LQP9qAavdCp3psyAPbUt+zwvW300aaJ6snF631z riYJgwSiPkUqwiAMbt8tvla9reH1wnFzs9n5bTkOzribK4LMxtJrIlwkvh3tg7mTAAE3 r4wQ== 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=tfdzyVc2dvWvT4n/qpMEEt+E0mRmUmqg0MbxEnbWuGY=; b=alswjpV58V8PRlgN6qAsZoLirYtKJcXNND+gaA43a1ZC0kYoPjn0WvgY+GYQ6UF5j+ DUl18hEQzLOouxjn2MMKt2p+A/okBDKxPp/FDGNMDnBfSprQu27SBVWlb6LTg1bGF5XC YcpXswsz7+C6/czoxLEVCHvRk5mktLu7XjAc6T0bd+VhOftfh2KpYi2iUOMlD10k7r7M B0Z5LFDDMHZuPVEitJshl5JAM+F3j1oGKR0yalAvaGJCLImUfb+al04rPgwyeQ1Ykr3O dMRToXGXkAnOSueLyUse9AZ8Xa4LrQI3LkT/0KXIkDYGgvzGNpblnEfPkkxF0KB1XEs4 6R/g== X-Gm-Message-State: AGRZ1gK2SqjkMUfP8oNyQbMmx5FmbWcRnWa4elbGmyxUiNlwEN36uHer KpBLWf68gbgDeyBpo9c0/zg= X-Google-Smtp-Source: AJdET5cNRcrzQvYhKBre6Yd6MySbFyaFRTWYN+1g3/dTr/KmN46dzEULKeuoLNv/SDtTOKg16iSCkw== X-Received: by 2002:ac8:2579:: with SMTP id 54-v6mr6646752qtn.88.1541083387382; Thu, 01 Nov 2018 07:43:07 -0700 (PDT) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id d8-v6sm2893938qtd.34.2018.11.01.07.43.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Nov 2018 07:43:07 -0700 (PDT) Date: Thu, 1 Nov 2018 11:43:02 -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, 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 v3 1/3] staging: iio: ad7780: fix offset read value Message-ID: <2191be4d531651db39682178ec0660eeb5697439.1541082656.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 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 Acked-by: Alexandru Ardelean --- 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 b67412db0318..91e016d534ed 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -96,7 +96,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; } From patchwork Thu Nov 1 14:43:23 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: 10664039 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 2C16113A4 for ; Thu, 1 Nov 2018 14:43:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4FB828B89 for ; Thu, 1 Nov 2018 14:43:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A867328879; Thu, 1 Nov 2018 14:43:35 +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 5B0832880B for ; Thu, 1 Nov 2018 14:43:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728972AbeKAXqp (ORCPT ); Thu, 1 Nov 2018 19:46:45 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:44981 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728832AbeKAXqp (ORCPT ); Thu, 1 Nov 2018 19:46:45 -0400 Received: by mail-qk1-f195.google.com with SMTP id n12so12381058qkh.11; Thu, 01 Nov 2018 07:43:28 -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=o1HuJO1RUvHYO8Q8iTB6hQuobWCheoadrs6aZ7vHCNI=; b=nY10gtsG93nvrNjcVAcVuNlAnF+w1oTirQeSx2bZ/VkxfPvH69rp+m3ckEThXQvzvz vi/jgf2hipPe1tUnQ443J8Ld6JZacTZ08WoznWxmFWpaScFGkyRgQhlLQgwKGstxMvPR LIZypJp1hUmuklmJQ2gopUvmzUblfof2S2DKiHAYwQHn7DOJRYHevNkDcCrZIYK8SHgR cwrQDqdfmbvIjDrL4kH5OA/QDoNe0Xifh56YFRel8tr1SJgq7VFCrFLRKlwcT29dpDOO 6WF1Fd3fKRCe2o1mJQWabouYZr5fDJqVPmLMD441335iSRrunhGIuI1VZPp3rjwfO3TK acJQ== 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=o1HuJO1RUvHYO8Q8iTB6hQuobWCheoadrs6aZ7vHCNI=; b=lW5DaWNPVH4z0qto/7NSgi1rIsGMfrN9zRELFHUXCAwAjq+kKNMst0tonEYVruY+B3 tEoVfLb03kpxOZF9k5ZwCIi0mXSa03rSfIsZ0awZA+UpAiduFfhB0gmUnM+i+zEZY7L0 m0knVsZMLgPdEMw7uQipkNpDu7W9/JxhGpi8Tq+3yxGTezZKLR0067RaZwLz2Ma3VvvL 0XRkwgFc3Zt5PJKVHfpLbKM/I1Qs3KYt9GPQgSLUPa1xMZh85x1ZfrdbJBOK7ylqWueg rAfCIExpC2nix4OnRYmx7X1OgL14IsyUTIJ5xd4ZFfJBF06EvaLufKa8fRLxcS02H6Ti QUAg== X-Gm-Message-State: AGRZ1gLF/wxgqWjf+ataGsU0Qlkap7Y2E5KKRTq5HJV3vK8JLM51DpdE 0oB84+dhZM1U8+MrUXCFcHY= X-Google-Smtp-Source: AJdET5dsEA8KZ9vsxcTNEyCOcjO6zWEfZxkll7bQ17+Ly2lhlUvJi0MkaxOJfIrLD8OQzgieQc2oEg== X-Received: by 2002:a37:8006:: with SMTP id b6-v6mr6658028qkd.178.1541083407989; Thu, 01 Nov 2018 07:43:27 -0700 (PDT) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id b134sm1201946qkg.78.2018.11.01.07.43.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Nov 2018 07:43:27 -0700 (PDT) Date: Thu, 1 Nov 2018 11:43:23 -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, 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 v3 2/3] staging: iio: ad7780: update voltage on read Message-ID: <1bc4bdf6342d4bc0c2fea17fb3bcd79fabf0e1d1.1541082656.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 --- Changes in v3: - removed initialization (int voltage_uv = 0) - returns error when voltage_uv is null 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 91e016d534ed..f2a11e9424cd 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) + return -EINVAL; + *val = (voltage_uv / 1000) * st->gain; *val2 = chan->scan_type.realbits - 1; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_OFFSET: From patchwork Thu Nov 1 14:43:41 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: 10664041 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 363BF13A4 for ; Thu, 1 Nov 2018 14:43:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 049F426BE9 for ; Thu, 1 Nov 2018 14:43:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02B3C2880B; Thu, 1 Nov 2018 14:43:47 +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 AEE5628B1C for ; Thu, 1 Nov 2018 14:43:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728494AbeKAXrD (ORCPT ); Thu, 1 Nov 2018 19:47:03 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:45200 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728352AbeKAXrC (ORCPT ); Thu, 1 Nov 2018 19:47:02 -0400 Received: by mail-qt1-f194.google.com with SMTP id l9-v6so21292759qtj.12; Thu, 01 Nov 2018 07:43:46 -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=50YKaMUXZTtrepHYaXBxTyw7j/sLoX4pes7YMM1sdIA=; b=Zqu4lf9LEdI0JPVj8jo6iyJKhAc3Vf1Ky5bh/jyecME978KCvUvdi6l4PsE1BNFwrI i+9HOGB31BBMkKmiAamykmx//rwpewgM4H1L99OfohOKOxhaI74dcvaq5tbfY6U+KccH j2wueHie5ZOmiFvws8m4wFIPmauC+amohBSPban3Y4XpvNqOOw8RnecAgqibx/ING8qX XU0TgfSxdEmJvHx49PyCpimd4PVTRXiuPDLsXl6uoFd2/3UN/4uVZyRiwDEO2M/XR6VW 1nuyLoMZPAjSyMHUKmFGXR8ew+jyBQS86zNI73sYoi+GnIHKpj79UeRWfb1JgnPu9tOC jTnw== 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=50YKaMUXZTtrepHYaXBxTyw7j/sLoX4pes7YMM1sdIA=; b=HJvQIwA+yzBaqNDrJR0sLtFmpH4HM60H/x6fsJphqegRHjp0VxOsklhDQpCDTUA6BG gv/rcZIKO0uKpQpbs9erDgQQE/KPmDTgeIGu8aA7aWaFZsvoA6gkK3RN4CaXR/vMkP8D Xf9VDF4MLAI46yH+NMw3iBuJmHIDV24S00o2hvDMe+HNF7ul7h5tSUWJoS1sh+g3efaK 416D/CnL6m5wA0nAYgSFqz8PgbT78rX2KfH4BBsoXK35mfvNeuWFMz+62I/dmCXu4VVd gkdNWYZekFB0P4FqNu0tA4Tj8k9a7H4hn8+lmRIFPqzWadoMzRFvcYatH9lJBcg2UzeZ OGhw== X-Gm-Message-State: AGRZ1gLjtgr3B9u9JvcRr1UVKbZ6UdvV+OfZNzv+OuRNFZY2rb6vl/YW 6LF7IqDaiTsVaImt2ByjRlo= X-Google-Smtp-Source: AJdET5eOnG5jnq5AI+JLmbs8efVFFw9CoUwubLYmzm7ARmwiWtyezKpVw1jfAKBmdODus7eKY6NfVw== X-Received: by 2002:a0c:ae76:: with SMTP id z51-v6mr7098225qvc.108.1541083426113; Thu, 01 Nov 2018 07:43:46 -0700 (PDT) Received: from renatolg ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id l123-v6sm5729208qkd.95.2018.11.01.07.43.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Nov 2018 07:43:45 -0700 (PDT) Date: Thu, 1 Nov 2018 11:43:41 -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, 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 v3 3/3] staging: iio: ad7780: remove unnecessary stashed voltage 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 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 drivers/staging/iio/adc/ad7780.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index f2a11e9424cd..f250370efcf7 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; }; @@ -190,9 +189,7 @@ static int ad7780_probe(struct spi_device *spi) 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 + if (!voltage_uv) dev_warn(&spi->dev, "Reference voltage unspecified\n"); spi_set_drvdata(spi, indio_dev);