Message ID | Y+c+mwNnlPpSH49/@ubun2204.myguest.virtualbox.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1379712wrn; Fri, 10 Feb 2023 23:34:42 -0800 (PST) X-Google-Smtp-Source: AK7set9WBumEqv7fmIVyy7q+QbzeAKPyKTHCHGC0LFVaH7g8y68shYBG+2OkoeL/fGnJQolVqhdW X-Received: by 2002:a17:906:a0c:b0:87b:db29:61af with SMTP id w12-20020a1709060a0c00b0087bdb2961afmr17803105ejf.24.1676100881806; Fri, 10 Feb 2023 23:34:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676100881; cv=none; d=google.com; s=arc-20160816; b=q/pwnnjSz7NhwQGMR0bR5dmTcXAGMfqwKeOLCy4SYsoYL4MP3TfFr78UP1hR+kGiyj wzqHQKCeXzWW/HM96u+EVeIm817xIxZshn+HU6wQG6Rxq9NPv0Q7u9tXPbHmlqmjuex4 byjM+AAzeh8OEfnbnOtGBIFVRMs0SyIlfKZ8hsntPSjaRHsXR7vxi5BKroIf2Ys6p9Tq XbzZvFzxaY/bhtMAiIMc4kRphFPTnn+Y654R5KYUYysejmyzmO3MwGCXzwF71JyPS6jx Y1wCDuakL17PakgABVX7nVOeQPgK2znOhP7htKOcceCMtH+Z40X4Jgjg21Xc5YGX0i2n x1rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=lco4HpLxrCdlhOrTLcWJH7W6AtODz3kBirfkOnW4AwQ=; b=fNxQ+Cs1iAQhkN5hs1j5bfVNPMfihjh5Ju8lnDs2Mrcnvu1qAW2TDu0bu4d+MnpqV/ nxEFzTLo8oemz4iF6g+WJAv5svp8oY2vCKy0lxCVJNjUAJVWb45UwFUSkTFtHXCz/LL3 F4IPtnApaDefyFMr9wj6XC4N56ORwVwPdDTte2+VWnwwBmJNPGQJil5ywu+Mhl9XTOrO gdj/YQQdT1iCbpGJKP77VOX948Gxq+JWukp4/1Oc5IqScNRmL6hr1VIqLaalCXhd16+p Or+RX6L2OuhxcMDUSmjCM0e+jqX1yNACNpEbZdyQ+Ze3KpJvXRc1icRx7EPLLGzds4Wp mT6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=FjpVlUq7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fv34-20020a17090750a200b0089df7e8bbacsi5974202ejc.787.2023.02.10.23.34.15; Fri, 10 Feb 2023 23:34:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=FjpVlUq7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229539AbjBKHHk (ORCPT <rfc822;ybw1215001957@gmail.com> + 99 others); Sat, 11 Feb 2023 02:07:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjBKHHj (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 11 Feb 2023 02:07:39 -0500 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BA9E311D0 for <linux-kernel@vger.kernel.org>; Fri, 10 Feb 2023 23:07:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1676099233; bh=RIfix2BpIp1e0NF6h2agOCXPTL1PhRt5VacNf+Tky2s=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=FjpVlUq76bhJL/v3aoVln2M4vSQgw4Eka/+zUp6+X+Ycwji5MloFE+3Q6sPqYqeua /GzBw/zq1TM3/pXlTTcWv2xkjxmK/nWhDpBoql7keR1i1ICrO1EtfqTmlowNfW52xq k3c8R5hJZYVrrkL71l2BrPRia4RIlnpSsOz7cVk4= Received: by b-2.in.mailobj.net [192.168.90.12] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sat, 11 Feb 2023 08:07:13 +0100 (CET) X-EA-Auth: gHMncWwrRzH3mBBPy4G5q3D2TK5uws+5aKfERZVMvxXMLR5um+/vvukcB+73UqH/MgSb1XCFOVEm3i0ZsB0fAV1nre4hqvwe Date: Sat, 11 Feb 2023 12:37:07 +0530 From: Deepak R Varma <drv@mailo.com> To: Antoniu Miclaus <antoniu.miclaus@analog.com>, Lars-Peter Clausen <lars@metafoo.de>, Michael Hennerich <Michael.Hennerich@analog.com>, Jonathan Cameron <jic23@kernel.org>, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar <ssengar@microsoft.com>, Praveen Kumar <kumarpraveen@linux.microsoft.com>, Deepak R Varma <drv@mailo.com> Subject: [PATCH] iio: frequency: adf4377: remove duplicate/repeating constant Message-ID: <Y+c+mwNnlPpSH49/@ubun2204.myguest.virtualbox.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757519158174822065?= X-GMAIL-MSGID: =?utf-8?q?1757519158174822065?= |
Series |
iio: frequency: adf4377: remove duplicate/repeating constant
|
|
Commit Message
Deepak R Varma
Feb. 11, 2023, 7:07 a.m. UTC
Constant ADF4377_0000_SOFT_RESET_R_MSK is unnecessarily or'ed with
itself. Remove the redundant constant from the expression.
Issue identified using doublebitand.cocci Coccinelle semantic patch.
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
drivers/iio/frequency/adf4377.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
Le 11/02/2023 à 08:07, Deepak R Varma a écrit : > Constant ADF4377_0000_SOFT_RESET_R_MSK is unnecessarily or'ed with > itself. Remove the redundant constant from the expression. > Issue identified using doublebitand.cocci Coccinelle semantic patch. > > Signed-off-by: Deepak R Varma <drv@mailo.com> > --- > drivers/iio/frequency/adf4377.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c > index 26abecbd51e0..caefd7ea6b14 100644 > --- a/drivers/iio/frequency/adf4377.c > +++ b/drivers/iio/frequency/adf4377.c > @@ -495,8 +495,8 @@ static int adf4377_soft_reset(struct adf4377_state *st) > return ret; > > return regmap_read_poll_timeout(st->regmap, 0x0, read_val, > - !(read_val & (ADF4377_0000_SOFT_RESET_R_MSK | > - ADF4377_0000_SOFT_RESET_R_MSK)), 200, 200 * 100); > + !(read_val & ADF4377_0000_SOFT_RESET_R_MSK), > + 200, 200 * 100); Based on the code just above, it is likely that one is expected to be ADF4377_0000_SOFT_RESET_MSK. CJ > } > > static int adf4377_get_freq(struct adf4377_state *st, u64 *freq)
On Sat, Feb 11, 2023 at 03:57:51PM +0100, Christophe JAILLET wrote: > Le 11/02/2023 à 08:07, Deepak R Varma a écrit : > > Constant ADF4377_0000_SOFT_RESET_R_MSK is unnecessarily or'ed with > > itself. Remove the redundant constant from the expression. > > Issue identified using doublebitand.cocci Coccinelle semantic patch. > > > > Signed-off-by: Deepak R Varma <drv@mailo.com> > > --- > > drivers/iio/frequency/adf4377.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c > > index 26abecbd51e0..caefd7ea6b14 100644 > > --- a/drivers/iio/frequency/adf4377.c > > +++ b/drivers/iio/frequency/adf4377.c > > @@ -495,8 +495,8 @@ static int adf4377_soft_reset(struct adf4377_state *st) > > return ret; > > return regmap_read_poll_timeout(st->regmap, 0x0, read_val, > > - !(read_val & (ADF4377_0000_SOFT_RESET_R_MSK | > > - ADF4377_0000_SOFT_RESET_R_MSK)), 200, 200 * 100); > > + !(read_val & ADF4377_0000_SOFT_RESET_R_MSK), > > + 200, 200 * 100); > > Based on the code just above, it is likely that one is expected to be > ADF4377_0000_SOFT_RESET_MSK. Hello CJ, I agree, that appears to be a close possibility. I also tried looking to the data sheet, but could not conclude. How can I make sure if the other one should be ADF4377_0000_SOFT_RESET_MSK? Thank you, ./drv > > CJ > > > } > > static int adf4377_get_freq(struct adf4377_state *st, u64 *freq) >
Le 11/02/2023 à 17:20, Deepak R Varma a écrit : > On Sat, Feb 11, 2023 at 03:57:51PM +0100, Christophe JAILLET wrote: >> Le 11/02/2023 à 08:07, Deepak R Varma a écrit : >>> Constant ADF4377_0000_SOFT_RESET_R_MSK is unnecessarily or'ed with >>> itself. Remove the redundant constant from the expression. >>> Issue identified using doublebitand.cocci Coccinelle semantic patch. >>> >>> Signed-off-by: Deepak R Varma <drv-asAA5fHt7EIAvxtiuMwx3w@public.gmane.org> >>> --- >>> drivers/iio/frequency/adf4377.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c >>> index 26abecbd51e0..caefd7ea6b14 100644 >>> --- a/drivers/iio/frequency/adf4377.c >>> +++ b/drivers/iio/frequency/adf4377.c >>> @@ -495,8 +495,8 @@ static int adf4377_soft_reset(struct adf4377_state *st) >>> return ret; >>> return regmap_read_poll_timeout(st->regmap, 0x0, read_val, >>> - !(read_val & (ADF4377_0000_SOFT_RESET_R_MSK | >>> - ADF4377_0000_SOFT_RESET_R_MSK)), 200, 200 * 100); >>> + !(read_val & ADF4377_0000_SOFT_RESET_R_MSK), >>> + 200, 200 * 100); >> >> Based on the code just above, it is likely that one is expected to be >> ADF4377_0000_SOFT_RESET_MSK. > > Hello CJ, > I agree, that appears to be a close possibility. I also tried looking to the > data sheet, but could not conclude. > How can I make sure if the other one should be ADF4377_0000_SOFT_RESET_MSK? > > Thank you, > ./drv I don't have the hardware, but based on the datasheet, table 43, ADF4377_0000_SOFT_RESET_R_MSK is a repeat of ADF4377_0000_SOFT_RESET_MSK. My understanding is that the regmap_update_bits() a few lines above sets bits to request the chip to reset. Both bits have the same meaning and I guess that writing only one would be enough or the chip require both to be written for some kind of "security" feature maybe. Anyway, on reset, both are zeroed. That is what is tested by regmap_read_poll_timeout(). So the code should work fine as-is, but to keep the logic, I would definitively use ADF4377_0000_SOFT_RESET_MSK | ADF4377_0000_SOFT_RESET_R_MSK. Finally, the driver is new and the author is in copy, so I guess that he would be in the best position to confirm all that. CJ > >> >> CJ >> >>> } >>> static int adf4377_get_freq(struct adf4377_state *st, u64 *freq) >> > > >
diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c index 26abecbd51e0..caefd7ea6b14 100644 --- a/drivers/iio/frequency/adf4377.c +++ b/drivers/iio/frequency/adf4377.c @@ -495,8 +495,8 @@ static int adf4377_soft_reset(struct adf4377_state *st) return ret; return regmap_read_poll_timeout(st->regmap, 0x0, read_val, - !(read_val & (ADF4377_0000_SOFT_RESET_R_MSK | - ADF4377_0000_SOFT_RESET_R_MSK)), 200, 200 * 100); + !(read_val & ADF4377_0000_SOFT_RESET_R_MSK), + 200, 200 * 100); } static int adf4377_get_freq(struct adf4377_state *st, u64 *freq)