Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3757121ybz; Mon, 20 Apr 2020 08:55:03 -0700 (PDT) X-Google-Smtp-Source: APiQypLfKHdIH5VYZS908j5AerQW9O13SwZdw6aIqjLkO4/7f9scLxzANRlebDj2klR9hQTKYJSV X-Received: by 2002:a17:906:468c:: with SMTP id a12mr17415530ejr.149.1587398103455; Mon, 20 Apr 2020 08:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587398103; cv=none; d=google.com; s=arc-20160816; b=thYA9Tq01KTmkkgxitA+7qjqQUIvDHAg0iUB1AfsM2gtMIrr09yidJt6y4DN/JZRl9 7KciwXQU3uU02iNKa9GKrIAR9mqaL/QcoqiWWb4CoEw2/2f5yqvXVcS0GnocBdiuq2cF hvWud1ItGLoutKpnLnPoa+IdsUfd81wCWDBG0X79QJLOwcc0rMpbqf9yAD86Cn4etGNX lwlH9npRwjRJ8/97pUkchw4MJxxfIKTL/gYgLIWSXa1fpO3dJ85DdvwCboN8W71X5IAd Lb/kqnhXr9ovyhOPffHCMZlyJq9VNS2XeOC1ZjkBTj//9WELN+TEsY9EKEBOQgWMaH0I saqQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=f/+ORcB7haaQa2NM7/NE+Ig6v61OzcWtFsPPyt8Jxpo=; b=isSjQxQAtIgFsIv6ChVnrXL7DRl/Q87PP5SHxcM1RYZMuoCB7S64SD3DujrJCIBihD t3yeRHHKlmC/EakmvmWkDe3wYfQYXaGROXBx1Ky4/WcBMlu2lrFETDgyZU8k3G6Ga3t+ XrkLuvfP/OyK4mHjTsYVmuI6SecETfOmdY7kcP5Zt3g7Gos1hF1quFL3fC7igvhnzCsi 2t8o6bdRZBc8BclJqXjcd5hos8LSLfcFyGR5ChDCN/RaXXxHMoebZDqG9KJOhktFniHi RDsb+25Rzp9th6WjwQP5sW0bRdglpT7brx0gtwjdwZStMeitfJr6qzcWXycT3gQb0yuE B8+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=lsYROrcI; 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 dn10si1105894ejc.357.2020.04.20.08.54.39; Mon, 20 Apr 2020 08:55:03 -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=@gmx.net header.s=badeba3b8450 header.b=lsYROrcI; 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 S1728946AbgDTPxY (ORCPT + 99 others); Mon, 20 Apr 2020 11:53:24 -0400 Received: from mout.gmx.net ([212.227.17.20]:50781 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725875AbgDTPxW (ORCPT ); Mon, 20 Apr 2020 11:53:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1587397991; bh=KuLTOA1QfKC7SolQCPu3ppRZXOTYJZ4TqJ92c1D3IBc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=lsYROrcIVALwszh4JGY7//1JDV/dYHZVCrNOvlENoljDvWymYVCFrlGadL1v7Tdya pWVmYWeJx4qoFV6DvI3lsbox9aZgLMnsnP23qjm3lMM2pWM/uIwmZobjWIMK6ETnUZ NZxCoiz11VbUDlLi9ZEeo1lCOaNu19hS/egimwD0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([83.52.229.196]) by mail.gmx.com (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1Mg6dy-1ik6B71neo-00haeP; Mon, 20 Apr 2020 17:53:11 +0200 From: Oscar Carter To: Forest Bond , Greg Kroah-Hartman Cc: Dan Carpenter , Malcolm Priestley , Oscar Carter , Quentin Deslandes , "John B . Wyatt IV" , Colin Ian King , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] staging: vt6656: Use fls instead of for loop in vnt_update_top_rates Date: Mon, 20 Apr 2020 17:52:46 +0200 Message-Id: <20200420155246.4925-1-oscar.carter@gmx.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:IL+LvGI/q4eU0/MdCc2loxlURjvQbUcZBHvz8+25JV+3eDsU4Hv Nf+tMGvAGg+KnihorlU5Z2wztRX7f92DdtoW+XLGwdYyHjTMzMMxmsv2TuUJPHW8Cwmcq2U gE45I8AiGza7F9Y3vQMdk2jDcd9oK05EqJvWYrGnWysIyWsFyC2koMdRq8LmiCEZO5Od9C4 bWtRc47NjjqmepdI/zVAA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:h4R5DqqVr00=:0rmCVwASIJghwwOz0wtvk7 I1toLZYyYRcyoTIMeurUEpQKeIdOFTJJrT+tRuy+yiNK0vm8eNJh8B1PdW9AI/rqAuCNtErjU 1HKwTvMXFtZaCGTDiSwBh3sRs3UC/ApQYxLna4T1uwmuF6Kk/yCGOe6POI4G5S2gALMJNUILg Y3i09Qtchos1dSB2QgHVX0jcdaduB6AUTYBicg6c+QEr8jwNgSYbVI64+uDBz02MYqe0Kwdej FgfqhaIi53H06DFYkDR1u0307OeNsa5eyys4Qqrkypblco3ObCd/EgDeiQYM2eMBRLhUQbXce IklyxpIaLN/OXmGQb9wLn7MiQumlLoIPjRauHkbfXrzHEg9+vAlkNhjJv81Y/g/aCGE/ey+uc cRiKeff4Tgtx65o7CVJr94sVMYj5YkxvxBsXqC78yKznEB1x7xTpA0daBjpsm9kkZCWEIwiCH zmtWNmLFx9BlHHcNCg3uM9r/brV1bAJI0HU6aWuESf9XvPVQl3t1LNm0iMhLBe7PuqR9KVhU3 6VM99L88S0KUe58uri4vtmAULAIM6Zhr063hrkrWIsdDB9IRXa7PNlGGWpSO/wddg9uNu37j8 8/xH9qCOvg7pdEESBtnWY9M3FshKf9ef9pnxZ2rhMM5X9ESmNViQrR0712lPRsilRCuPCyWqx 8iJaKuCIMj6vFuXR8wIHG6RsKssj8M5aoRcqDuardOAbxqf3MFAnAzFU+Wfw6u3cD7XmaM08w wrBGg9S987XQjFyjREK6eEs9uk3g8jgLnG/6QVqEKi8ImFTfvsTgAhwgWd3BPXv7Ko/E4zTG1 gRv0NIZllCv0mpPYZ1Fv9IFAvr2QVeAAPiM82ErkYN4qjlz0SMTXVXNiMKz5UtjKypXWOfM3W GGDkUKDu1sMcdl4nNk+7n9RenRB9mBRRTAVDHKExIFCvkE0WTm8I/J8TDer3rf4EDgDdp8Qis yuhkrUf9OJYvFy9CDM1gXeYWuSUnOMFzdWCx49qvR+a0QOxULerP/noHsyy1BsVHhK3OoVI6E BMPTfAJNDIX2m6afADv6K3W/YFWDXWedGjMx7jdC8rXNpDk3gPLKWS5AIN3SH4aKx+i64M+zk LiLkqL0mmFf7JziZdhRaDUGyWMjUcYxhrNiS82cLchq4EwD6wsski2gnw/h00LQx7flVwu3hn 8KE1xPqpfWFYBR8VVpv8fXY3B585mjW0zJJtBMVCXwopT7DCYrxeDKKPL7SJrB71A57iOzhBt vH3IgD75EQXxe+zLU Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace the for loops of the vnt_update_top_rates function by the fls function. The purpose of the two for loops is to find the most significant bit set in a range of bits. So, they can be replace by the fls function (find last set) with a previous mask to define the range. This way avoid the iteration over unnecessary for loops. The header "linux/bits.h" can be remove as it is included in the header "linux/bitops.h". Signed-off-by: Oscar Carter =2D-- Changelog v1 -> v2 - Replace the expression pos-- with the expresion (pos - 1) as Dan Carpenter suggested. drivers/staging/vt6656/card.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index f8bfadd4b506..2478edee756a 100644 =2D-- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -26,7 +26,7 @@ * */ -#include +#include #include "device.h" #include "card.h" #include "baseband.h" @@ -223,29 +223,13 @@ void vnt_update_ifs(struct vnt_private *priv) void vnt_update_top_rates(struct vnt_private *priv) { - u8 top_ofdm =3D RATE_24M, top_cck =3D RATE_1M; - u8 i; + int pos; - /*Determines the highest basic rate.*/ - for (i =3D RATE_54M; i >=3D RATE_6M; i--) { - if (priv->basic_rates & BIT(i)) { - top_ofdm =3D i; - break; - } - } - - priv->top_ofdm_basic_rate =3D top_ofdm; - - for (i =3D RATE_11M;; i--) { - if (priv->basic_rates & BIT(i)) { - top_cck =3D i; - break; - } - if (i =3D=3D RATE_1M) - break; - } + pos =3D fls(priv->basic_rates & GENMASK(RATE_54M, RATE_6M)); + priv->top_ofdm_basic_rate =3D pos ? (pos - 1) : RATE_24M; - priv->top_cck_basic_rate =3D top_cck; + pos =3D fls(priv->basic_rates & GENMASK(RATE_11M, RATE_1M)); + priv->top_cck_basic_rate =3D pos ? (pos - 1) : RATE_1M; } int vnt_ofdm_min_rate(struct vnt_private *priv) =2D- 2.20.1