From patchwork Thu Mar 3 11:08:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12767316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F1E5C433EF for ; Thu, 3 Mar 2022 11:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232647AbiCCLI2 (ORCPT ); Thu, 3 Mar 2022 06:08:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232638AbiCCLI2 (ORCPT ); Thu, 3 Mar 2022 06:08:28 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A23D1AF1A for ; Thu, 3 Mar 2022 03:07:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646305660; x=1677841660; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jJCu2kTAbizusS27kv0h56CpQN3omVI3FloLm80zRek=; b=S55tGkkQUe6dUv9LJE6xZRujvE/KO1wLu8rUMtB2+rYlD81SJOf1DGq9 zXNG10KAMHaBAQzC3y0UMkbye2IgndGjpWrMxJ5c+CaW33IVrC+jLu2z4 nDH0RXIHEfU6jx0zr6sIshUwJ1Jh2e1gb06CNKMIx04Ea5XifCJkMCefy GJYADyRki61H044r0qTLsiurNojFfhZkl1FpvKckkAI7ym5ADHvNKlBiP otisQOddchhj2IacGzc88WW7gLIWmOpU4vf4MfWXGFCsOjq78xT/vtLsm 3d8ToatdOl+3R/UipFxi89sHWRy6I690N1Ougcqs0iv1WR4pG+coBWZ6O w==; X-IronPort-AV: E=McAfee;i="6200,9189,10274"; a="251219894" X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="251219894" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2022 03:07:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,151,1643702400"; d="scan'208";a="576452387" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2022 03:07:37 -0800 From: Mathias Nyman To: Cc: , Linyu Yuan , Mathias Nyman Subject: [PATCH v2 5/9] usb: host: xhci: use ffs() in xhci_mem_init() Date: Thu, 3 Mar 2022 13:08:59 +0200 Message-Id: <20220303110903.1662404-6-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303110903.1662404-1-mathias.nyman@linux.intel.com> References: <20220303110903.1662404-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Linyu Yuan The for loop to find page size bit can be replaced with ffs(). Signed-off-by: Linyu Yuan Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 48114a462908..938eb2b907ab 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2391,11 +2391,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) page_size = readl(&xhci->op_regs->page_size); xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Supported page size register = 0x%x", page_size); - for (i = 0; i < 16; i++) { - if ((0x1 & page_size) != 0) - break; - page_size = page_size >> 1; - } + i = ffs(page_size); if (i < 16) xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Supported page size of %iK", (1 << (i+12)) / 1024);