From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752364AbbFNPzw (ORCPT ); Sun, 14 Jun 2015 11:55:52 -0400 Received: from saturn.retrosnub.co.uk ([178.18.118.26]:45057 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751549AbbFNPzl (ORCPT ); Sun, 14 Jun 2015 11:55:41 -0400 Message-ID: <557DA3FA.4050300@kernel.org> Date: Sun, 14 Jun 2015 16:55:38 +0100 From: Jonathan Cameron User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Lars-Peter Clausen , Gergely Imreh CC: michal.simek@xilinx.com, linux-iio@vger.kernel.org, Linux ARM Kernel , linux-kernel@vger.kernel.org, ola@adapteva.com Subject: Re: [PATCH 1/1] iio:adc: XADC: Set offset explicitly to zero on voltage channels References: <1434010946-8118-1-git-send-email-imrehg@gmail.com> <557C76D2.7030306@kernel.org> <557DA18F.5090805@metafoo.de> In-Reply-To: <557DA18F.5090805@metafoo.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/06/15 16:45, Lars-Peter Clausen wrote: > On 06/14/2015 05:15 AM, Gergely Imreh wrote: >> On 14 June 2015 at 02:30, Jonathan Cameron wrote: >>> On 11/06/15 09:22, Gergely Imreh wrote: >>>> The Xilinx XADC driver has both a temperature channel and 8 voltage >>>> channels. The voltage channels have no offset, but actually were still >>>> set the same offset as the temperature channel. This did not cause >>>> problems in /sys/bus/iio/ but can cause problems with other drivers >>>> using iio data. For example iio-hwmon did return wrong voltage values >>>> because of the offset. >>>> >>>> Change tested with the Parallella board. >>>> >>>> Signed-off-by: Gergely Imreh >>> Well spotted on the bug, but I think we are better off fixing this at the >>> true source of the problem which is in drivers/iio/inkern.c >>> iio_convert_raw_to_processed_unlocked which does a call to >>> iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET) then uses >>> the error return to check if the offset parameter is available. It should >>> be checking that before making this call with a call to iio_channel_has_info. >>> >>> I don't suppose you could prepare a patch fixing that as you found the problem? >> >> I'll check it out, and send an updated patch! Thanks for the pointers >> to the core of the issue. > > The issue was already fixed a while ago, see this patch: > http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=65de7654d39c70c2b942f801cea01590cf7e3458 > > Starting with that commit iio_channel_read() returns an error when > the attribute is not available, which causes > iio_convert_raw_to_processed_unlocked() to skip the offset if it is > not available. > oops. Good spot. I'd completely forgotten about that and failed to spot the check when looking at the code yesterday. Glad you were keeping an eagle eye on things ;) J > - Lars From mboxrd@z Thu Jan 1 00:00:00 1970 From: jic23@kernel.org (Jonathan Cameron) Date: Sun, 14 Jun 2015 16:55:38 +0100 Subject: [PATCH 1/1] iio:adc: XADC: Set offset explicitly to zero on voltage channels In-Reply-To: <557DA18F.5090805@metafoo.de> References: <1434010946-8118-1-git-send-email-imrehg@gmail.com> <557C76D2.7030306@kernel.org> <557DA18F.5090805@metafoo.de> Message-ID: <557DA3FA.4050300@kernel.org> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 14/06/15 16:45, Lars-Peter Clausen wrote: > On 06/14/2015 05:15 AM, Gergely Imreh wrote: >> On 14 June 2015 at 02:30, Jonathan Cameron wrote: >>> On 11/06/15 09:22, Gergely Imreh wrote: >>>> The Xilinx XADC driver has both a temperature channel and 8 voltage >>>> channels. The voltage channels have no offset, but actually were still >>>> set the same offset as the temperature channel. This did not cause >>>> problems in /sys/bus/iio/ but can cause problems with other drivers >>>> using iio data. For example iio-hwmon did return wrong voltage values >>>> because of the offset. >>>> >>>> Change tested with the Parallella board. >>>> >>>> Signed-off-by: Gergely Imreh >>> Well spotted on the bug, but I think we are better off fixing this at the >>> true source of the problem which is in drivers/iio/inkern.c >>> iio_convert_raw_to_processed_unlocked which does a call to >>> iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET) then uses >>> the error return to check if the offset parameter is available. It should >>> be checking that before making this call with a call to iio_channel_has_info. >>> >>> I don't suppose you could prepare a patch fixing that as you found the problem? >> >> I'll check it out, and send an updated patch! Thanks for the pointers >> to the core of the issue. > > The issue was already fixed a while ago, see this patch: > http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=65de7654d39c70c2b942f801cea01590cf7e3458 > > Starting with that commit iio_channel_read() returns an error when > the attribute is not available, which causes > iio_convert_raw_to_processed_unlocked() to skip the offset if it is > not available. > oops. Good spot. I'd completely forgotten about that and failed to spot the check when looking at the code yesterday. Glad you were keeping an eagle eye on things ;) J > - Lars