From: Felipe Balbi <felipe.balbi@linux.intel.com>
To: Mathias Nyman <mathias.nyman@linux.intel.com>,
Andrey Smirnov <andrew.smirnov@gmail.com>,
linux-usb@vger.kernel.org
Cc: Mathias Nyman <mathias.nyman@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Subject: xhci: Use ffs() to find page size in xhci_mem_init()
Date: Thu, 07 Feb 2019 11:06:00 +0200 [thread overview]
Message-ID: <87mun8klxj.fsf@linux.intel.com> (raw)
Hi,
Mathias Nyman <mathias.nyman@linux.intel.com> writes:
> On 07.02.2019 02:03, Andrey Smirnov wrote:
>> Get page size order using ffs() instead of open coding it with a loop.
>>
>> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
>> Cc: Mathias Nyman <mathias.nyman@intel.com>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: linux-usb@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> ---
>> 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 36a3eb8849f1..44b43c3d819f 100644
>> --- a/drivers/usb/host/xhci-mem.c
>> +++ b/drivers/usb/host/xhci-mem.c
>> @@ -2362,11 +2362,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);
>
> Hi
>
> using ffs() is a welcome change, but it will give different a result than the loop.
>
> *old loop
> valid page_size value if i < 16
> *ffs()
> valid page_size value if i >= 1 and i < 17
off-by-one, just use i = ffs() - 1. Or use __ffs().
next reply other threads:[~2019-02-07 9:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-07 9:06 Felipe Balbi [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-02-07 21:06 xhci: Use ffs() to find page size in xhci_mem_init() Andrey Smirnov
2019-02-07 11:54 Mathias Nyman
2019-02-07 10:58 Felipe Balbi
2019-02-07 10:46 Mathias Nyman
2019-02-07 9:04 Mathias Nyman
2019-02-07 0:03 Andrey Smirnov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mun8klxj.fsf@linux.intel.com \
--to=felipe.balbi@linux.intel.com \
--cc=andrew.smirnov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=mathias.nyman@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).