linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]is_power_of_2-scsi/NCR53C9x.c
@ 2007-06-12  5:24 vignesh babu
  2007-06-12 11:50 ` [PATCH]is_power_of_2-scsi/NCR53C9x.c Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: vignesh babu @ 2007-06-12  5:24 UTC (permalink / raw)
  To: matthew; +Cc: linux-scsi, Kernel Janitors List


Replacing (n & (n-1)) in the context of power of 2 checks
with is_power_of_2

Signed-off-by: vignesh babu <vignesh.babu@wipro.com>
--- 
diff --git a/drivers/scsi/NCR53C9x.c b/drivers/scsi/NCR53C9x.c
index 8b5334c..2868b1a 100644
--- a/drivers/scsi/NCR53C9x.c
+++ b/drivers/scsi/NCR53C9x.c
@@ -33,6 +33,7 @@
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
 #include <linux/init.h>
+#include <linux/log2.h>
 
 #include "scsi.h"
 #include <scsi/scsi_host.h>
@@ -1651,7 +1652,7 @@ static inline int reconnect_target(struct NCR_ESP *esp, struct ESP_regs *eregs)
 	if(!(it & me))
 		return -1;
 	it &= ~me;
-	if(it & (it - 1))
+	if(!is_power_of_2(it))
 		return -1;
 	while(!(it & 1))
 		targ++, it >>= 1;

-- 
Vignesh Babu BM 
_____________________________________________________________ 
"Why is it that every time I'm with you, makes me believe in magic?"


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH]is_power_of_2-scsi/NCR53C9x.c
  2007-06-12  5:24 [PATCH]is_power_of_2-scsi/NCR53C9x.c vignesh babu
@ 2007-06-12 11:50 ` Matthew Wilcox
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2007-06-12 11:50 UTC (permalink / raw)
  To: vignesh babu; +Cc: linux-scsi, Kernel Janitors List

On Tue, Jun 12, 2007 at 10:54:36AM +0530, vignesh babu wrote:
> @@ -1651,7 +1652,7 @@ static inline int reconnect_target(struct NCR_ESP *esp, struct ESP_regs *eregs)
>  	if(!(it & me))
>  		return -1;
>  	it &= ~me;
> -	if(it & (it - 1))
> +	if(!is_power_of_2(it))
>  		return -1;
>  	while(!(it & 1))
>  		targ++, it >>= 1;

I think you actually want to do:

-	if(!(it & me))
-		return -1;
 	it &= ~me;
-	if(it & (it - 1))
+	if (!is_power_of_2(it))
 		return -1;

as it looks to me like the first test is checking for the n != 0 case in
is_power_of_two().

Not that it'll matter much -- AIUI, this driver is scheduled for
deletion soon.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-06-12 11:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-12  5:24 [PATCH]is_power_of_2-scsi/NCR53C9x.c vignesh babu
2007-06-12 11:50 ` [PATCH]is_power_of_2-scsi/NCR53C9x.c Matthew Wilcox

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).