From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtprelay.hostedemail.com (smtprelay0065.hostedemail.com [216.40.44.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D90D72 for ; Thu, 1 Jul 2021 03:23:31 +0000 (UTC) Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave07.hostedemail.com (Postfix) with ESMTP id CE68C1812C266 for ; Wed, 30 Jun 2021 10:58:15 +0000 (UTC) Received: from omf06.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id 03D2F18096A36; Wed, 30 Jun 2021 10:58:09 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf06.hostedemail.com (Postfix) with ESMTPA id 6F18E2448BB; Wed, 30 Jun 2021 10:58:07 +0000 (UTC) Message-ID: Subject: Re: [RFC 13/19] staging: qlge: rewrite do while loop as for loop in qlge_sem_spinlock From: Joe Perches To: Coiby Xu , Dan Carpenter Cc: linux-staging@lists.linux.dev, netdev@vger.kernel.org, Benjamin Poirier , Shung-Hsi Yu , Manish Chopra , "supporter:QLOGIC QLGE 10Gb ETHERNET DRIVER" , Greg Kroah-Hartman , open list Date: Wed, 30 Jun 2021 03:58:06 -0700 In-Reply-To: <20210624112245.zgvkcxyu7hzrzc23@Rk> References: <20210621134902.83587-1-coiby.xu@gmail.com> <20210621134902.83587-14-coiby.xu@gmail.com> <20210622072036.GK1861@kadam> <20210624112245.zgvkcxyu7hzrzc23@Rk> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.0-1 Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.39 X-Rspamd-Server: rspamout05 X-Rspamd-Queue-Id: 6F18E2448BB X-Stat-Signature: byo61h9tdyfet1zjamufshpd8jh1i6zk X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19+Me1uZrs5Ho696/FTg+x3rB2212tX89w= X-HE-Tag: 1625050687-621425 On Thu, 2021-06-24 at 19:22 +0800, Coiby Xu wrote: > On Tue, Jun 22, 2021 at 10:20:36AM +0300, Dan Carpenter wrote: > > On Mon, Jun 21, 2021 at 09:48:56PM +0800, Coiby Xu wrote: > > > Since wait_count=30 > 0, the for loop is equivalent to do while > > > loop. This commit also replaces 100 with UDELAY_DELAY. [] > > > diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c [] > > > @@ -140,12 +140,13 @@ static int qlge_sem_trylock(struct qlge_adapter *qdev, u32 sem_mask) > > >  int qlge_sem_spinlock(struct qlge_adapter *qdev, u32 sem_mask) > > >  { > > >   unsigned int wait_count = 30; > > > + int count; > > > > > > - do { > > > + for (count = 0; count < wait_count; count++) { > > >   if (!qlge_sem_trylock(qdev, sem_mask)) > > >   return 0; > > > - udelay(100); > > > - } while (--wait_count); > > > + udelay(UDELAY_DELAY); > > > > This is an interesting way to silence the checkpatch udelay warning. ;) > > I didn't know this could silence the warning :) It also seems odd to have unsigned int wait_count and int count. Maybe just use 30 in the loop without using wait_count at all. I also think using UDELAY_DELAY is silly and essentially misleading as it's also used as an argument value for mdelay $ git grep -w UDELAY_DELAY drivers/staging/qlge/qlge.h:#define UDELAY_DELAY 100 drivers/staging/qlge/qlge_main.c: udelay(UDELAY_DELAY); drivers/staging/qlge/qlge_main.c: udelay(UDELAY_DELAY); drivers/staging/qlge/qlge_mpi.c: mdelay(UDELAY_DELAY); drivers/staging/qlge/qlge_mpi.c: mdelay(UDELAY_DELAY); drivers/staging/qlge/qlge_mpi.c: mdelay(UDELAY_DELAY); /* 100ms */