Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6707732imu; Wed, 30 Jan 2019 21:16:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN7A7MvkI+/OQXZv/DwPzAKXIiDJAnqe3ReFFVl5MrFDMalEBWwOdRyEYA/BJzigmnY8TbNG X-Received: by 2002:a17:902:722:: with SMTP id 31mr33551842pli.271.1548911813192; Wed, 30 Jan 2019 21:16:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548911813; cv=none; d=google.com; s=arc-20160816; b=sJbEZau9e1pMVZRC2yeFSE0B/twc6sBEGaNVrs0lFmoCv4qbZKaquxtVJrjIK3m4Zr 2ZMMdoYxn4Z+D5y3U9LlYSqj+f2ajdB2Ur78c04JOSIea8pmo1NABzrLYroSZzL/gnup ugYwyiDR1CYc7BTeZ9bZ3BXlS3r7bDIlS0yB2H7EuOh5mPlyV9Xk0Px2GMLKaUqAOFNI HcndNhMl91ZdXZnfsUei63GhcKK/Vu/0IIcPV1ju/BuEp+9PZLJ1CD6gQRv8bCYjMiSf 1nZEHp2KlAj3ekIkR6YEzaqD4Ne1gNuzLBZwdocbGQWVlSAMsU2eJtlvQ5j6O/Q9jumQ Qeqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=WbexUhY9aqcT+1SE9D/xYA5ED9xHab81qjVL0E3Ao0k=; b=SEJ04mvqs5P5KOGAvjCZbEX1tHnJiwOaO0qgTZOXoFOudLGj5iVFZe68csAAsLiXbx AAq/f31HG3IHbmGIaynrcLYGqYys6e9e2Ye1O6WUxmqxELzADgIEKL3epconncQsrM8c HjJVde0HB+heoO+sF5RQ11jngCkl7rIwYSJmF1HZI98xHCcnlgXG5k7x4eVYNtJ3gM/W C1VYM5zgkp/PKoe+H8/TFhL3ZyK6QpfhNiwUoJi9J3/sEEtkCmXy6F8BIJAJBb1AewgZ 7sl30WUDFQBOI7LAH93LtSvuAmQVFJ4dKIgaXetbJ9RNvN/WZEAeGtYXUeB72Y4XY0M5 IiQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B2ScClUQ; 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 g69si3554904pfg.225.2019.01.30.21.16.38; Wed, 30 Jan 2019 21:16:53 -0800 (PST) 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=B2ScClUQ; 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 S1726488AbfAaFP6 (ORCPT + 99 others); Thu, 31 Jan 2019 00:15:58 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:39476 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbfAaFP6 (ORCPT ); Thu, 31 Jan 2019 00:15:58 -0500 Received: by mail-yw1-f67.google.com with SMTP id k188so811880ywa.6; Wed, 30 Jan 2019 21:15:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WbexUhY9aqcT+1SE9D/xYA5ED9xHab81qjVL0E3Ao0k=; b=B2ScClUQNBBiaRyChUU0FpZdhHExy5iO5jHeEfHzFL2Lk6BNLNq2uEZzHuhU5pOjAk Vs13m3x5b+8ZzQY0dEVlvTHVJebJhpvPzzm6Ksw08F+R85/+6hSdNqx8ILYKIpBWdzIF tWqpt2/2OgSr7WJ/6/WSwtRfD5g8L5n1ulGwxwfpNOmC4DMbNI+LRoZs0OIljNrqnk/y Z+prA72Tv4FGFCD22Pk5s0WBc9/GHo5xKabje3Ky3kqzMdKIy5cDeetwb3TGrXGf8Jna 1ovNITaLhXSAmjgt4oRA1RICHxv7q+a4QZnqbMdeBErPOaaZYzBdAepNquDHktObb3uH tRvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WbexUhY9aqcT+1SE9D/xYA5ED9xHab81qjVL0E3Ao0k=; b=XVw1CgKAGickIjvT69OhjFN89evVixyAk3xKCR4y1eKyNjqAUDDNV1v4biG4FUzmfz MC0+98P5tO2gSFiEFUGWXnEnkT/zn1Bw0I+jJqGPf2jtlUI4ByLkWtr3Njl3kIEnFWaP qBtwPlNYqjJy88ZLtc25Wm3lpF4vi9L6ugOUAC2TPIiecm1Y9ojJt0eanS5Of2+XZDyK eRWw3rnU7YCdvjteK4s5xCkHwz5hJRW8+grilOQ6K5U8XN/f0Cl95PaAMJFvBePktoLB F3HfOM1hN3iYXAX3KyVkKd4xt8JYPp+wyHIEXS9pbEazXHNvbHs0/zPBBDpMNLn4FUNG Pvrw== X-Gm-Message-State: AJcUukcoIdVhK564/h80N/7mKYHrQ3OVPT8PoXkfWm+jt1WJddWgSj72 16HNjMiPtvmQta5BQKsj2MHCd/lUUDqRZQAsr1Y= X-Received: by 2002:a81:a87:: with SMTP id 129mr32238076ywk.195.1548911757198; Wed, 30 Jan 2019 21:15:57 -0800 (PST) MIME-Version: 1.0 References: <1548440422-27943-1-git-send-email-justinpopo6@gmail.com> <20190126183011.00f03cc3@archlinux> In-Reply-To: <20190126183011.00f03cc3@archlinux> From: Justin Chen Date: Wed, 30 Jan 2019 21:15:45 -0800 Message-ID: Subject: Re: [PATCH v2] iio: adc: ti-ads7950: inconsistency with spi msg To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, knaack.h@gmx.de, lars@metafoo.de, linux-kernel@vger.kernel.org, Florian Fainelli , Mark Brown Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 26, 2019 at 10:30 AM Jonathan Cameron wrote: > > On Fri, 25 Jan 2019 10:20:22 -0800 > justinpopo6@gmail.com wrote: > > > From: Justin Chen > > > > To read a channel we require 3 cycles to send, process, and receive > > the data. The transfer buffer for the third transaction is left blank. > > This leaves it up to the SPI driver to decide what to do. > Interesting. I think that means you may have a bug in your SPI driver. > The pointer in question is always left set to NULL in the adc > driver (not explicitly but it will be because ultimately comes from > a kzalloc). > > Documentation for an SPI message makes it clear that NULL is > allowed. From include/linux/spi/spi.h > > "* Those segments always read the same number of bits as they > * write; but one or the other is easily ignored by passing a null buffer > * pointer. " > > Hmm. It does say 'ignored'. My assumption has always been that > means it would be filled with zeros, but maybe I'm wrong. > > Mark? > I looked more into this and other SPI drivers do fill it with zeros. I'll submit a patch for the SPI driver instead and see what the SPI maintainers say. Thanks, Justin > > > > In one particular case, if the tx buffer is not set the spi driver > > sets it to 0xff. This puts the ADC in a alarm programming state, > > therefore the following read to a channel becomes erroneous. > > > > Instead of leaving us to the mercy of the SPI driver, we send the > > ADC cmd on the third transaction to prevent inconsistent behavior. > > > > Fixes: 902c4b2446d4 ("iio: adc: New driver for TI ADS7950 chips") > > Signed-off-by: Justin Chen > > --- > > drivers/iio/adc/ti-ads7950.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c > > index 0ad6359..1255d8b 100644 > > --- a/drivers/iio/adc/ti-ads7950.c > > +++ b/drivers/iio/adc/ti-ads7950.c > > @@ -422,6 +422,7 @@ static int ti_ads7950_probe(struct spi_device *spi) > > st->scan_single_xfer[1].tx_buf = &st->single_tx; > > st->scan_single_xfer[1].len = 2; > > st->scan_single_xfer[1].cs_change = 1; > > + st->scan_single_xfer[2].tx_buf = &st->single_tx; > > st->scan_single_xfer[2].rx_buf = &st->single_rx; > > st->scan_single_xfer[2].len = 2; > > >