[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f7beb9aee00a1cdb8dd97a49a36abd60d58279f2.camel@perches.com>
Date: Wed, 30 Jun 2021 03:58:06 -0700
From: Joe Perches <joe@...ches.com>
To: Coiby Xu <coiby.xu@...il.com>,
Dan Carpenter <dan.carpenter@...cle.com>
Cc: linux-staging@...ts.linux.dev, netdev@...r.kernel.org,
Benjamin Poirier <benjamin.poirier@...il.com>,
Shung-Hsi Yu <shung-hsi.yu@...e.com>,
Manish Chopra <manishc@...vell.com>,
"supporter:QLOGIC QLGE 10Gb ETHERNET DRIVER"
<GR-Linux-NIC-Dev@...vell.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [RFC 13/19] staging: qlge: rewrite do while loop as for loop in
qlge_sem_spinlock
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 */
Powered by blists - more mailing lists