Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2858908ybz; Sun, 19 Apr 2020 11:22:24 -0700 (PDT) X-Google-Smtp-Source: APiQypKvxOfJN3UG5KX3yiLZbSyaeSOI1Wq0fr/18N1YSKga+78cjDoU52rZvlulSRcNLj3wCzHB X-Received: by 2002:a17:906:11c9:: with SMTP id o9mr13104031eja.64.1587320543957; Sun, 19 Apr 2020 11:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587320543; cv=none; d=google.com; s=arc-20160816; b=nqWANTBlgdGi3BkLAmheQ2+svvgMK3Vc66Q9b9VwVfzHw4fcuu5foDQB70srewvwtc gpGHGpGDOCvM/kY/CkjyYhNxO20x5cQBL3vFNriVQ4cmhy+Sv21slMBDeKuoWlK7ybwD h3FzMHbxIK1AL1lQeNUGNv3UHWrG+f/33TNXabubsC35A3NdEYK2F0KGpcWTj+dXD9yD oHOr3HpoiSKOVnDz94jkmYjr9f+GGgtEq1uKsXtWLdYBo2aFaJB97P+Vq8uQceaTqgUO 1UI/cF8CPHITfoNysu8puRJFrPSHAd44tbDis76Xtlp0Vw1Es/oE7C4i7k1QoatPp4m4 KRJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=mX8cAWtGVYcEAdopl0xBwG41RjLtOiyjKvK1kLIQc90=; b=uEllchMx7KIt0fTcCuB7/DNJc7Yx1Vplvn3YxQEqFy9NBLlOZA23vW0AmpKucjc2pr zkOTzw7HUdzq2ZzlaIgYbglHFcnb6nOZDP0AoTXSBd38nf1mr7GDuc7v11CIB78jk9Yo JIJcd7dBsQ+U+7gnLxz7JvTf7cKGb8z4M4W4R1gOt62Kbhsedgq5KCPaJ5d9IGzEnUj2 hbe1ZbZI+bHVmZUoTX3Q9jS/KpZbsY6tVjVHilEuq/uljQi0qdw/c6/tQQc88BAuiN3A DI1kRN4PIaeRbq0HqUeAt3gibnFXdKUQTMMwIo5HH+l11UZ+S1x2BCewnkUnwXf01a6L x21Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sg1uMgVI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o30si10483127eda.0.2020.04.19.11.21.59; Sun, 19 Apr 2020 11:22:23 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sg1uMgVI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726384AbgDSRzw (ORCPT + 99 others); Sun, 19 Apr 2020 13:55:52 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:48671 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725793AbgDSRzw (ORCPT ); Sun, 19 Apr 2020 13:55:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587318951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mX8cAWtGVYcEAdopl0xBwG41RjLtOiyjKvK1kLIQc90=; b=Sg1uMgVI4IlTbWyGU4vSNxIK9gevpGRotkQ5dGNMMEpxE+sCcbG6gCAl1IEvKxjfUKNFxx b8Ku+SR4zVPeP2j9NAxs9itMhRrGMCJItDV7RLCS5t/KaNgvUL6+Ri+X7/VLZtsVEe4TKU r1enCs90MsL14WRSvMahOb6+Se78nfE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-0PbGig6FOwmZgAQBZC7YiA-1; Sun, 19 Apr 2020 13:55:47 -0400 X-MC-Unique: 0PbGig6FOwmZgAQBZC7YiA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 50C4C800D5C; Sun, 19 Apr 2020 17:55:45 +0000 (UTC) Received: from elisabeth (unknown [10.36.110.10]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C2E3A1055; Sun, 19 Apr 2020 17:55:40 +0000 (UTC) Date: Sun, 19 Apr 2020 19:55:34 +0200 From: Stefano Brivio To: Oscar Carter Cc: Forest Bond , Greg Kroah-Hartman , Malcolm Priestley , Quentin Deslandes , "John B . Wyatt IV" , Colin Ian King , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: vt6656: Refactor the vnt_ofdm_min_rate function Message-ID: <20200419195534.1463ddcd@elisabeth> In-Reply-To: <20200418134553.6415-1-oscar.carter@gmx.com> References: <20200418134553.6415-1-oscar.carter@gmx.com> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Oscar, On Sat, 18 Apr 2020 15:45:53 +0200 Oscar Carter wrote: > Replace the for loop by a ternary operator whose condition is an AND > bitmask against the priv->basic_rates variable. > > The purpose of the for loop was to check if any of bits from RATE_54M to > RATE_6M was set, but it's not necessary to check every individual bit. > The same result can be achieved using only one single mask which > comprises all the commented bits. > > This way avoid the iteration over an unnecessary for loop. > > Also change the return type to bool because it's the type that this > function returns. > > Signed-off-by: Oscar Carter > --- > drivers/staging/vt6656/card.c | 11 ++--------- > drivers/staging/vt6656/card.h | 2 +- > 2 files changed, 3 insertions(+), 10 deletions(-) > > diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c > index 9bd37e57c727..adaf93cf653a 100644 > --- a/drivers/staging/vt6656/card.c > +++ b/drivers/staging/vt6656/card.c > @@ -248,16 +248,9 @@ void vnt_update_top_rates(struct vnt_private *priv) > priv->top_cck_basic_rate = top_cck; > } > > -int vnt_ofdm_min_rate(struct vnt_private *priv) > +bool vnt_ofdm_min_rate(struct vnt_private *priv) > { > - int ii; > - > - for (ii = RATE_54M; ii >= RATE_6M; ii--) { > - if ((priv->basic_rates) & ((u16)BIT(ii))) > - return true; > - } > - > - return false; > + return priv->basic_rates & GENMASK(RATE_54M, RATE_6M) ? true : false; priv->basic_rates & GENMASK(RATE_54M, RATE_6M) is already true if non-zero and false otherwise. Note that I haven't checked if the rest is correct. -- Stefano