Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp914336oof; Tue, 25 Sep 2018 06:18:58 -0700 (PDT) X-Google-Smtp-Source: ACcGV63J32VpTgSxMlFmqKtsO0vNXCfnPqUi5pYFrM3VQr9O8P5x6MA/iSViR7Wc7yFy7cKLXQ7E X-Received: by 2002:a17:902:585:: with SMTP id f5-v6mr1223928plf.7.1537881538928; Tue, 25 Sep 2018 06:18:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537881538; cv=none; d=google.com; s=arc-20160816; b=j6YdmdkrwZCtmYVjhUrI5h6bZv0oOcfpekNnkLU24BKlU7yB+94RuUQ2wMo76vnG62 hhV6hbyfpsotKugy/tHekIPj1hpdbCMxKJZPMQGsDF1keoLtwRSMvKTmPxYeCT//zzhw gquNSdR4KstPvRN1Gmi38BQncBIE9yTdnpJfa/p2V2Jvw2EhXj+sei/UEJGqiiOFVMgr GpvCOqV4er4y8R8OFdAcMB6KgKSChd9gxmqZE+noSoqKGAS02WcykQ5hRs0ZsHQVUN5j 8qa0UfoY/bRJHWleWtMYfM4jojY0Bi8FNPPkfpqXBXShN+GZ+rb9v3QSzMJGDXdqkQpc opfQ== 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:mail-followup-to :message-id:subject:cc:to:from:date; bh=d42bB28nOepLeNQSlqgioGX+M6rEE0K6Tj8CzH71txw=; b=eys01w7ZPb7muKN4+yLkvyQGk14cbpg999k1QSo+QETh2/78BUmIz3TSE/J7seSKdo hxu7/riag52pfDZS4k+lfY1fM4ktyi6h1Sfs7F0JX09FzmxZGcR7WdVK5V0LRmO3lO14 xio3TqCx1Htw/x+jgV0j2Ocz5Y3eCmejThYHDO0MOE0LvS7wZMzxtxUuA60EcCvFY0Lq b5PtpvJH4K/xQlFtrXeptHW9oN0rXvTPs5E1BCcn+jh1UaxVxUrVguIJdoRYD0MWwmdD 7ayc02LRnSJ8abrWLMJ+WOvvQeUUERplda2Iz1+5OSViZd3MLE6eF5oWrdEZb1WcpsYX q2tA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p62-v6si456057pfg.295.2018.09.25.06.18.42; Tue, 25 Sep 2018 06:18:58 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729177AbeIYTZ7 (ORCPT + 99 others); Tue, 25 Sep 2018 15:25:59 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:32649 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728272AbeIYTZ7 (ORCPT ); Tue, 25 Sep 2018 15:25:59 -0400 X-IronPort-AV: E=Sophos;i="5.54,302,1534834800"; d="scan'208";a="18387827" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 25 Sep 2018 06:18:25 -0700 Received: from localhost (10.10.76.4) by chn-sv-exch04.mchp-main.com (10.10.76.105) with Microsoft SMTP Server id 14.3.352.0; Tue, 25 Sep 2018 06:17:58 -0700 Date: Tue, 25 Sep 2018 15:17:57 +0200 From: Ludovic Desroches To: Eugen Hristev CC: , , , , , Maxime Ripard Subject: Re: [PATCH v2 2/2] iio: adc: at91: fix wrong channel number in triggered buffer mode Message-ID: <20180925131757.gjk2t277twhji5ns@M43218.corp.atmel.com> Mail-Followup-To: Eugen Hristev , jic23@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, nicolas.ferre@microchip.com, Maxime Ripard References: <1537775504-7981-1-git-send-email-eugen.hristev@microchip.com> <1537775504-7981-2-git-send-email-eugen.hristev@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1537775504-7981-2-git-send-email-eugen.hristev@microchip.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 24, 2018 at 10:51:44AM +0300, Eugen Hristev wrote: > When channels are registered, the hardware channel number is not the > actual iio channel number. > This is because the driver is probed with a certain number of accessible > channels. Some pins are routed and some not, depending on the description of > the board in the DT. > Because of that, channels 0,1,2,3 can correspond to hardware channels > 2,3,4,5 for example. > In the buffered triggered case, we need to do the translation accordingly. > Fixed the channel number to stop reading the wrong channel. > > Fixes 0e589d5fb "ARM: AT91: IIO: Add AT91 ADC driver." > Cc: Maxime Ripard > Signed-off-by: Eugen Hristev Acked-by: Ludovic Desroches > --- > Changes in v2: > - Added 'const' spec to the declaration to avoid build warning > > drivers/iio/adc/at91_adc.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c > index e3be88e..75d2f73 100644 > --- a/drivers/iio/adc/at91_adc.c > +++ b/drivers/iio/adc/at91_adc.c > @@ -248,12 +248,14 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p) > struct iio_poll_func *pf = p; > struct iio_dev *idev = pf->indio_dev; > struct at91_adc_state *st = iio_priv(idev); > + struct iio_chan_spec const *chan; > int i, j = 0; > > for (i = 0; i < idev->masklength; i++) { > if (!test_bit(i, idev->active_scan_mask)) > continue; > - st->buffer[j] = at91_adc_readl(st, AT91_ADC_CHAN(st, i)); > + chan = idev->channels + i; > + st->buffer[j] = at91_adc_readl(st, AT91_ADC_CHAN(st, chan->channel)); > j++; > } > > -- > 2.7.4 >