Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp212297pxv; Wed, 30 Jun 2021 03:59:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzurQTxoF00MLQC958KEqbkHyNOdilDiA5cnvvFEapgwxIJu6NMgE3lQO8mUqIIsrgrQRs9 X-Received: by 2002:aa7:d812:: with SMTP id v18mr46679533edq.159.1625050769759; Wed, 30 Jun 2021 03:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625050769; cv=none; d=google.com; s=arc-20160816; b=TP0Z+F/EPGAOZ2QPmr3k0PQpGPyVkj9X0fJ15iIwCdV5a2h+74gQ78gsjwerHgvTzZ 9+SEvalaqXgCLU8ZcgyJLe0kWwcJT94RCYU2zajoN1SXK1jm7jHTXFixJQBYNIUnC+8k I0ZnDtSGSOKgCLUnpPY6qOhDDoqcn25oe1kT1lQg479h5aVPJH3r2jke+CKNqmEkr7JZ RDFcq4WczQHYI7mifNg+b5giKBWnH++eBs6fQv/lNz8PLNul1+US2VoAT0OnN/OCfWnF +r2oF5+cwM3lxH+SLUUeY7cf4hHnACkGzXrt07w82lCgMWtkXvetvlhyveY5goV20RpM 1Mgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=B7yB0Kz8U8RqmovffAAqMo4a0BMMsQWTcAiA/gK2CWI=; b=bT5OCEt9MBEpqKqIRSo6edDZNnlhN+rCKIpnd9M6h+AxIL24y/EX10cQyzhi1N/M0j YObTr06MDSgQPmzmZUXDK/YSxuJjmLIuOv1tCaEvuWsz3pNlljeeIpt0UvJZMeqeRQxy MmbJM0motJT+F4JJrE0mwflQFkUsreuohQMhTwotMeHLNIHdbeyJzT1CJTO8aJ84uglr 4654Vw+mxq71OJjnZecUzeJV5eexBQF3jFJwOp+u242b7ijxAYgASuJpH80wIIevwQY6 Swk/2CzpDv2BwryxdgYEcvHYHEofuEAk0whY323L/mVSbNYfMuAwVNJXBqUyKki5xYQH ERzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si20117816edq.86.2021.06.30.03.59.06; Wed, 30 Jun 2021 03:59:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234252AbhF3LAj (ORCPT + 99 others); Wed, 30 Jun 2021 07:00:39 -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-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 */