From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20469C11F65 for ; Wed, 30 Jun 2021 10:58:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F086F61C9F for ; Wed, 30 Jun 2021 10:58:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234146AbhF3LAk (ORCPT ); Wed, 30 Jun 2021 07:00:40 -0400 Received: from smtprelay0226.hostedemail.com ([216.40.44.226]:56216 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229882AbhF3LAi (ORCPT ); Wed, 30 Jun 2021 07:00:38 -0400 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 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 */