From: Bart Van Assche Date: Wed, 14 Aug 2013 15:33:35 +0000 (+0000) Subject: libfc: Micro-optimize fc_setup_exch_mgr() X-Git-Tag: next-20131105~12^2~1^2~13 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a84ea8c7e839a73dab4bfc755f7f52e947690dab;p=karo-tx-linux.git libfc: Micro-optimize fc_setup_exch_mgr() Convert a loop into an ilog2() call. Although this code is not performance sensitive this conversion makes this code easier to read. Signed-off-by: Bart Van Assche Cc: Neil Horman Signed-off-by: Robert Love --- diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c index cb2b900c011d..d0be52ab62c8 100644 --- a/drivers/scsi/libfc/fc_exch.c +++ b/drivers/scsi/libfc/fc_exch.c @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -2530,13 +2531,8 @@ int fc_setup_exch_mgr(void) * cpu on which exchange originated by simple bitwise * AND operation between fc_cpu_mask and exchange id. */ - fc_cpu_mask = 1; - fc_cpu_order = 0; - while (fc_cpu_mask < nr_cpu_ids) { - fc_cpu_mask <<= 1; - fc_cpu_order++; - } - fc_cpu_mask--; + fc_cpu_order = ilog2(roundup_pow_of_two(nr_cpu_ids)); + fc_cpu_mask = (1 << fc_cpu_order) - 1; fc_exch_workqueue = create_singlethread_workqueue("fc_exch_workqueue"); if (!fc_exch_workqueue)