Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp6914687imb; Sat, 9 Mar 2019 09:49:04 -0800 (PST) X-Google-Smtp-Source: APXvYqw0LHOyBEI1vgDUBHg+mDHCx/u/2tsvfD1XGPA/3rOBiWtUlu7U5RAaO34y6ePj4FIqdaeH X-Received: by 2002:a65:6642:: with SMTP id z2mr22613820pgv.196.1552153744905; Sat, 09 Mar 2019 09:49:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552153744; cv=none; d=google.com; s=arc-20160816; b=oBWNBnbE4YnjyzgZVm52uCROvjvvtVCvJuKH2G2soNlLazLStN+Cd7mw5HBzECzY6U WEv6DHddy37bSE90ZlCfScgw8NfKWsOixTvMTExYLpandBGWWNkLhkpfj/zpAQta8mOk FAfvgcEnt/tpvAhmPoxbdzTli3up+7DjuBcViSwJiz7zVQJqt1m0YWqxnKh1jktnMC+h PiN3CLG1A5vIhPtGdAmwZoZmUONCfQGNHZP08PoS95suuzcMWE1fhRxdOc7xuYbQpOWj 0EAxAtWZNY91Dkav9Elqb4/8UX35HcgqDAdicbOHixrIHF8a9nmKzPkzHDG6s7nP6ca8 nkxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=GFLBdn/vPWt1O+mFHK3e3Q8hCBVxQKFtBEwICACQ2CU=; b=UW3WX/aSf0m92yrobeuPmYWhiI5nDwBr6UOBT7joOd8andge4vyyLF9Jafhi3NJHLt RQKNg+aM5MBAbGo5+539ICAs6q0fryrzHP49p4rCXTtc4YpgDzQpYMuFnCgR7kbzVz4Q j1lAkwT47wUvF0gCmnWhv4d5xo+URXG7kC9na8IOnV9fH8xXOCOGBxECNtwfd4GO0XV6 MIwtJzULz58EP8mg/sa5RpkSOoCsRKJgJ5Fyiq0TI8uIAy+YC0u0rx02HCOHm7tWx4Cg e40M5KBxCSRE7euyDXsSmcrkiHfIEkiaGmXXsIRpDHBQPtoW67/woMmLtNFc18vJrHRe R3LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o9pFD+2z; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si612435pgp.527.2019.03.09.09.48.34; Sat, 09 Mar 2019 09:49:04 -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=@kernel.org header.s=default header.b=o9pFD+2z; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726469AbfCIRsH (ORCPT + 99 others); Sat, 9 Mar 2019 12:48:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:59036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726379AbfCIRsH (ORCPT ); Sat, 9 Mar 2019 12:48:07 -0500 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 34CE3207E0; Sat, 9 Mar 2019 17:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552153686; bh=K1bxJb8OW+tClNhftMqE0139mWDhsgtgRDTEGBocZZU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=o9pFD+2zSZwyzZeA4B0MlFCbqrEzBA2/hagiv9TeuGCZRS0dmRhcOJUp0IGo1tbV9 VnXNHDFtNuZjT/yh+MSg3kcPb8qIM1gktNZY3PhuTBmDVzbaOaG6c0CqNgTSHYRx0G We+JnJNl42S1jxdjuhRNFdD5VLyeADYs9fRC/Nw4= Date: Sat, 9 Mar 2019 17:47:59 +0000 From: Jonathan Cameron To: Renato Lui Geh Cc: "Ardelean, Alexandru" , "kernel-usp@googlegroups.com" , "lars@metafoo.de" , "robh+dt@kernel.org" , "knaack.h@gmx.de" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , "Hennerich, Michael" , "linux-iio@vger.kernel.org" , "devel@driverdev.osuosl.org" , "mark.rutland@arm.com" , "giuliano.belinassi@usp.br" , "pmeerw@pmeerw.net" , "gregkh@linuxfoundation.org" , "Popa, Stefan Serban" Subject: Re: [PATCH v4 4/9] staging:iio:ad7780: add chip ID values and mask Message-ID: <20190309174759.2c6b1435@archlinux> In-Reply-To: <20190309001928.uhwia4ujvqqwawlg@renatolg> References: <90c573cd53bb54d49de6ac270bcff66880ccfeb5.1551358569.git.renatogeh@gmail.com> <190e26b19b8ed6559b92d3a000d852bbb0099a52.camel@analog.com> <20190303140107.ljjo3flatwmd44ya@renatolg> <20190303145347.41d49646@archlinux> <13ef212f8aeebd0c893be253cb4834a3e4d741b8.camel@analog.com> <20190309001928.uhwia4ujvqqwawlg@renatolg> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 8 Mar 2019 21:19:29 -0300 Renato Lui Geh wrote: > On 03/04, Ardelean, Alexandru wrote: > >On Sun, 2019-03-03 at 14:53 +0000, Jonathan Cameron wrote: > >> [External] > >> > >> > >> On Sun, 3 Mar 2019 11:01:09 -0300 > >> Renato Lui Geh wrote: > >> > >> > On 03/01, Ardelean, Alexandru wrote: > >> > > On Thu, 2019-02-28 at 11:24 -0300, Renato Lui Geh wrote: > >> > > > > >> > > > > >> > > > The ad7780 supports both the ad778x and ad717x families. Each chip > >> > > > has > >> > > > a corresponding ID. This patch provides a mask for extracting ID > >> > > > values > >> > > > from the status bits and also macros for the correct values for the > >> > > > ad7170, ad7171, ad7780 and ad7781. > >> > > > > >> > > > Signed-off-by: Renato Lui Geh > >> > > > --- > >> > > > drivers/staging/iio/adc/ad7780.c | 8 ++++++-- > >> > > > 1 file changed, 6 insertions(+), 2 deletions(-) > >> > > > > >> > > > diff --git a/drivers/staging/iio/adc/ad7780.c > >> > > > b/drivers/staging/iio/adc/ad7780.c > >> > > > index 56c49e28f432..ad7617a3a141 100644 > >> > > > --- a/drivers/staging/iio/adc/ad7780.c > >> > > > +++ b/drivers/staging/iio/adc/ad7780.c > >> > > > @@ -26,10 +26,14 @@ > >> > > > #define AD7780_RDY BIT(7) > >> > > > #define AD7780_FILTER BIT(6) > >> > > > #define AD7780_ERR BIT(5) > >> > > > -#define AD7780_ID1 BIT(4) > >> > > > -#define AD7780_ID0 BIT(3) > >> > > > #define AD7780_GAIN BIT(2) > >> > > > > >> > > > +#define AD7170_ID 0 > >> > > > +#define AD7171_ID 1 > >> > > > +#define AD7780_ID 1 > >> > > > +#define AD7781_ID 0 > >> > > > + > >> > > > +#define AD7780_ID_MASK (BIT(3) | BIT(4)) > >> > > > >> > > This also doesn't have any functionality change. > >> > > The AD7170_ID, AD7171_ID, AD7780_ID & AD7781_ID IDs are also unused > >> > > (maybe > >> > > in a later patch they are ?). > >> > > >> > They aren't. I added them following a previous review suggestion. > >> > Should > >> > I remove them? > >> > >> Can we check them? It's always useful to confirm that the device is > >> the one you think it is. Then we can either use what is there > >> with a suitable warning, or if that is tricky just fault out as the > >> dt is giving us the wrong part number. > >> > >> J > > > >I guess `dev_warn_ratelimited()` could be used to make sure syslog isn't > >spammed-to-death when doing multiple conversions, and the ID isn't correct. > >Since these IDs are read after you get a sample, I'm a bit fearful of log- > >spam. > > > >I wouldn't throw an error in the ad7780_postprocess_sample() for this, but > >warning [with rate-limit] sounds reasonable. > > Looking at dev_warn_ratelimited's definition (and its use in other parts > of the kernel), I see that we'd need the device to be stored somewhere > (perhaps in ad7780_state?) in order for us to pass it as argument to > dev_warn from within postprocess_sample. Should this be stored in > ad7780_state? Or can I get the spi_device some other way? Ah. I was being lazy and hadn't looked at the datasheet. If they are that nasty to get to, don't bother checking them. Mostly we can assume people don't claim to have the wrong compatible device. Jonathan > > > >> > >> > > > >> > > I would also leave the AD7780_ID1 & AD7780_ID0 definitions in place, > >> > > since > >> > > they're easier matched with the datasheet. > >> > > > >> > > > > >> > > > #define AD7780_PATTERN_GOOD 1 > >> > > > #define AD7780_PATTERN_MASK GENMASK(1, 0) > >> > > > -- > >> > > > 2.21.0 > >> > > > > >> > >>