Re: [LINUX-KERNEL] C++ in linux kernel

2008-02-11 Thread vignesh babu bm
http://www.vmware.com/download/server/open_source.html

On Feb 11, 2008 5:07 PM, rohit h <[EMAIL PROTECTED]> wrote:
>
> On Feb 8, 2008 9:24 PM, Jan Engelhardt <[EMAIL PROTECTED]> wrote:
> >
> > On Feb 9 2008 00:14, Joonwoo Park wrote:
> > >2008/2/8, rohit h <[EMAIL PROTECTED]>:
> > >> Hi,
> > >>  I am a kernel newbie.
> > >>  I tried to insmod a C++ module containing classes, inheritance.
> > >>  I am getting 'unresolved symbol' error when I use the 'new' keyword.
> > >>  What could the problem be?
> > >>
> > >>  What kind of runtime support is needed ( arm linux kernel)? Is a
> > >> patch available for it?
> > >>
> > >Please take a look at click modular router which is using c++ as a
> > >linux kernel module.
> > >http://www.read.cs.ucla.edu/click/
> > >The lib/glue.cc provides custom operator new.
> >
> > Uh, let's not make the world worse :)
> > Just call malloc from C++, and carefully select what C++ features
> > you are going to use. The VMware source for example does it right.
> >
>
> From the links given, I dig that following C++ features need runtime support:
>   a. Pure virtual functions
>   b. Global objects  : Needs compiler dependent changes
>   c. new & delete : Can use kmalloc / kfree instead
>   d. Run time type info
>   e. Exceptions
> I guess features d & e need considerable effort.
> Apart from these, am I free to use other C++ features?
> Where could I see the VMWare sources?
>
>
>
> > Compiling the kernel module with g++ is not a simple work, you may
> > need big patch for kernel itself.
>
> I don't want to compile entire kernel.
> I only want to compile my module with g++ and insmod it.
> Any hint on how to write the Makefile.
>
> Thanks in advance,
> Rohit
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>



-- 
--
"Why is it that every time I'm with you, makes me believe in magic?"
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [LINUX-KERNEL] C++ in linux kernel

2008-02-11 Thread vignesh babu bm
http://www.vmware.com/download/server/open_source.html

On Feb 11, 2008 5:07 PM, rohit h [EMAIL PROTECTED] wrote:

 On Feb 8, 2008 9:24 PM, Jan Engelhardt [EMAIL PROTECTED] wrote:
 
  On Feb 9 2008 00:14, Joonwoo Park wrote:
  2008/2/8, rohit h [EMAIL PROTECTED]:
   Hi,
I am a kernel newbie.
I tried to insmod a C++ module containing classes, inheritance.
I am getting 'unresolved symbol' error when I use the 'new' keyword.
What could the problem be?
  
What kind of runtime support is needed ( arm linux kernel)? Is a
   patch available for it?
  
  Please take a look at click modular router which is using c++ as a
  linux kernel module.
  http://www.read.cs.ucla.edu/click/
  The lib/glue.cc provides custom operator new.
 
  Uh, let's not make the world worse :)
  Just call malloc from C++, and carefully select what C++ features
  you are going to use. The VMware source for example does it right.
 

 From the links given, I dig that following C++ features need runtime support:
   a. Pure virtual functions
   b. Global objects  : Needs compiler dependent changes
   c. new  delete : Can use kmalloc / kfree instead
   d. Run time type info
   e. Exceptions
 I guess features d  e need considerable effort.
 Apart from these, am I free to use other C++ features?
 Where could I see the VMWare sources?



  Compiling the kernel module with g++ is not a simple work, you may
  need big patch for kernel itself.

 I don't want to compile entire kernel.
 I only want to compile my module with g++ and insmod it.
 Any hint on how to write the Makefile.

 Thanks in advance,
 Rohit



 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to [EMAIL PROTECTED]
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/




-- 
--
Why is it that every time I'm with you, makes me believe in magic?
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: wierd file perms

2007-10-14 Thread vignesh babu
ls --version
ls (GNU coreutils) 5.97

An fsck did it :) and had the source restored by checkout -f

Think Jan is right, there is a diff between the two...

On 10/15/07, Mark Lord <[EMAIL PROTECTED]> wrote:
> Jan Engelhardt wrote:
> > On Oct 14 2007 09:27, Mark Lord wrote:
> >> Jan-Benedict Glaw wrote:
> >>> On Sat, 2007-10-13 22:40:23 +0530, vignesh babu <[EMAIL PROTECTED]>
> >>> wrote:
> >>>> I was surprised and did an ls -l on the files and guess what I found:
> >>>>
> >>>> total 0
> >>>> ?- ? ? ? ?? fcntl.c
> >>>> ?- ? ? ? ?? fifo.c
> >>>> ?- ? ? ? ?? filesystems.c
> >>>> ?- ? ? ? ?? file_table.c
> >>>> ?- ? ? ? ?? freevxfs
> >>>>
> >>>> So end result is that, Im not able to delete the files or change perms
> >>>> or ownership even as root.
> >>> Most probably, your filesystem is broken and needs a fsck.
> >> No, this is perfectly normal behaviour, for when a directory
> >> has READ permissions but not EXECUTE permissions.
> >
> > Er, close.
> >
> >   16:02 ichi:/dev/shm > md a
> >   16:02 ichi:/dev/shm > touch a/b
> >   16:02 ichi:/dev/shm > chmod 644 a
> >   16:02 ichi:/dev/shm > ls -l a
> >   /bin/ls: cannot access a/b: Permission denied
> >   total 0
> >   -? ? ? ? ?? b
> >   16:02 ichi:/dev/shm > ls --version
> >   ls (GNU coreutils) 6.9
> >
> >
> > There is a difference ..  "-?" vs "?-".
>
> That's just a version difference for GNU ls.
> Here, with ls (GNU coreutils) 5.97 it gives this:
>
> ?- ? ? ? ?? a/b
>
>
>


-- 

--
"Why is it that every time I'm with you, makes me believe in magic?"
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: wierd file perms

2007-10-14 Thread vignesh babu
ls --version
ls (GNU coreutils) 5.97

An fsck did it :) and had the source restored by checkout -f

Think Jan is right, there is a diff between the two...

On 10/15/07, Mark Lord [EMAIL PROTECTED] wrote:
 Jan Engelhardt wrote:
  On Oct 14 2007 09:27, Mark Lord wrote:
  Jan-Benedict Glaw wrote:
  On Sat, 2007-10-13 22:40:23 +0530, vignesh babu [EMAIL PROTECTED]
  wrote:
  I was surprised and did an ls -l on the files and guess what I found:
 
  total 0
  ?- ? ? ? ?? fcntl.c
  ?- ? ? ? ?? fifo.c
  ?- ? ? ? ?? filesystems.c
  ?- ? ? ? ?? file_table.c
  ?- ? ? ? ?? freevxfs
 
  So end result is that, Im not able to delete the files or change perms
  or ownership even as root.
  Most probably, your filesystem is broken and needs a fsck.
  No, this is perfectly normal behaviour, for when a directory
  has READ permissions but not EXECUTE permissions.
 
  Er, close.
 
16:02 ichi:/dev/shm  md a
16:02 ichi:/dev/shm  touch a/b
16:02 ichi:/dev/shm  chmod 644 a
16:02 ichi:/dev/shm  ls -l a
/bin/ls: cannot access a/b: Permission denied
total 0
-? ? ? ? ?? b
16:02 ichi:/dev/shm  ls --version
ls (GNU coreutils) 6.9
 
 
  There is a difference ..  -? vs ?-.

 That's just a version difference for GNU ls.
 Here, with ls (GNU coreutils) 5.97 it gives this:

 ?- ? ? ? ?? a/b





-- 

--
Why is it that every time I'm with you, makes me believe in magic?
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


wierd file perms

2007-10-13 Thread vignesh babu
Hi all,

Was having trouble with the latest source-in compiling it and did an
mrproper which fixed things...well-temporarily.

I was hitting another issue with permissions-as root :(

I was surprised and did an ls -l on the files and guess what I found:

total 0
?- ? ? ? ?? fcntl.c
?- ? ? ? ?? fifo.c
?- ? ? ? ?? filesystems.c
?- ? ? ? ?? file_table.c
?- ? ? ? ?? freevxfs

So end result is that, Im not able to delete the files or change perms
or ownership even as root.

Can some one help please?

How did this even happen?

I could compile without any issues till yesterday and todays update
seems to have caused this...

Not really sure if it is just a local phenomenon
-- 

--
"Why is it that every time I'm with you, makes me believe in magic?"
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


wierd file perms

2007-10-13 Thread vignesh babu
Hi all,

Was having trouble with the latest source-in compiling it and did an
mrproper which fixed things...well-temporarily.

I was hitting another issue with permissions-as root :(

I was surprised and did an ls -l on the files and guess what I found:

total 0
?- ? ? ? ?? fcntl.c
?- ? ? ? ?? fifo.c
?- ? ? ? ?? filesystems.c
?- ? ? ? ?? file_table.c
?- ? ? ? ?? freevxfs

So end result is that, Im not able to delete the files or change perms
or ownership even as root.

Can some one help please?

How did this even happen?

I could compile without any issues till yesterday and todays update
seems to have caused this...

Not really sure if it is just a local phenomenon
-- 

--
Why is it that every time I'm with you, makes me believe in magic?
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[kj] is_power_of_2 in mm/slub.c

2007-08-13 Thread vignesh babu
Replacing n & (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
---
diff --git a/mm/slub.c b/mm/slub.c
index 69d02e3..1241d14 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * Lock order:
@@ -2606,7 +2607,7 @@ void __init kmem_cache_init(void)
 * around with ARCH_KMALLOC_MINALIGN
 */
BUILD_BUG_ON(KMALLOC_MIN_SIZE > 256 ||
-   (KMALLOC_MIN_SIZE & (KMALLOC_MIN_SIZE - 1)));
+   !is_power_of_2(KMALLOC_MIN_SIZE));
 
for (i = 8; i < KMALLOC_MIN_SIZE; i += 8)
size_index[(i - 1) / 8] = KMALLOC_SHIFT_LOW;

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[kj] is_power_of_2 in ntfs

2007-08-13 Thread vignesh babu
Replacing n & (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
---
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index b532a73..8152f79 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "aops.h"
 #include "attrib.h"
@@ -1574,7 +1575,7 @@ static int ntfs_read_locked_index_inode(struct inode 
*base_vi, struct inode *vi)
ntfs_debug("Index collation rule is 0x%x.",
le32_to_cpu(ir->collation_rule));
ni->itype.index.block_size = le32_to_cpu(ir->index_block_size);
-   if (ni->itype.index.block_size & (ni->itype.index.block_size - 1)) {
+   if (!is_power_of_2(ni->itype.index.block_size)) {
ntfs_error(vi->i_sb, "Index block size (%u) is not a power of "
"two.", ni->itype.index.block_size);
goto unm_err_out;
diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c
index acfed32..00b2d02 100644
--- a/fs/ntfs/logfile.c
+++ b/fs/ntfs/logfile.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "attrib.h"
 #include "aops.h"
@@ -63,9 +64,8 @@ static bool ntfs_check_restart_page_header(struct inode *vi,
logfile_log_page_size = le32_to_cpu(rp->log_page_size);
if (logfile_system_page_size < NTFS_BLOCK_SIZE ||
logfile_log_page_size < NTFS_BLOCK_SIZE ||
-   logfile_system_page_size &
-   (logfile_system_page_size - 1) ||
-   logfile_log_page_size & (logfile_log_page_size - 1)) {
+   !is_power_of_2(logfile_system_page_size) ||
+   !is_power_of_2(logfile_log_page_size)) {
    ntfs_error(vi->i_sb, "$LogFile uses unsupported page size.");
return false;
}

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[kj] is_power_of_2 in drivers/md/dm-raid1.c

2007-08-13 Thread vignesh babu
Replacing n & (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
---
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 144071e..969b398 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define DM_MSG_PREFIX "raid1"
 #define DM_IO_PAGES 64
@@ -994,7 +995,7 @@ static void free_context(struct mirror_set *ms, struct 
dm_target *ti,
 
 static inline int _check_region_size(struct dm_target *ti, uint32_t size)
 {
-   return !(size % (PAGE_SIZE >> 9) || (size & (size - 1)) ||
+   return !(size % (PAGE_SIZE >> 9) || !is_power_of_2(size) ||
 size > ti->len);
 }
 
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 83ddbfe..ad2836a 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "dm-snap.h"
 #include "dm-bio-list.h"
@@ -415,7 +416,7 @@ static int set_chunk_size(struct dm_snapshot *s, const char 
*chunk_size_arg,
chunk_size = round_up(chunk_size, PAGE_SIZE >> 9);
 
/* Check chunk_size is a power of 2 */
-   if (chunk_size & (chunk_size - 1)) {
+   if (!is_power_of_2(chunk_size)) {
*error = "Chunk size is not a power of 2";
return -EINVAL;
}
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index 51f5e07..969944a 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define DM_MSG_PREFIX "striped"
 
@@ -99,7 +100,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int 
argc, char **argv)
/*
 * chunk_size is a power of two
 */
-   if (!chunk_size || (chunk_size & (chunk_size - 1)) ||
+   if (!is_power_of_2(chunk_size) ||
(chunk_size < (PAGE_SIZE >> SECTOR_SHIFT))) {
ti->error = "Invalid chunk size";
return -EINVAL;

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[kj] is_power_of_2 in drivers/pci/pci.c

2007-08-13 Thread vignesh babu
Replacing n & (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
---
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 37c00f6..19a64a3 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include/* isa_dma_bridge_buggy */
 #include "pci.h"
 
@@ -1454,7 +1455,7 @@ int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
int cap, err = -EINVAL;
u32 stat, cmd, v, o;
 
-   if (mmrbc < 512 || mmrbc > 4096 || (mmrbc & (mmrbc-1)))
+   if (mmrbc < 512 || mmrbc > 4096 || !is_power_of_2(mmrbc))
goto out;
 
v = ffs(mmrbc) - 10;
@@ -1526,7 +1527,7 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
int cap, err = -EINVAL;
u16 ctl, v;
 
-   if (rq < 128 || rq > 4096 || (rq & (rq-1)))
+   if (rq < 128 || rq > 4096 || !is_power_of_2(rq))
    goto out;
 
v = (ffs(rq) - 8) << 12;

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[kj] is_power_of_2 in drivers/block/rd.c

2007-08-13 Thread vignesh babu
Replacing n & (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
---
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index 65150b5..81821d3 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -56,6 +56,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -422,7 +423,7 @@ static int __init rd_init(void)
int err = -ENOMEM;
 
if (rd_blocksize > PAGE_SIZE || rd_blocksize < 512 ||
-   (rd_blocksize & (rd_blocksize-1))) {
+   !is_power_of_2(rd_blocksize)) {
printk("RAMDISK: wrong blocksize %d, reverting to defaults\n",
   rd_blocksize);
rd_blocksize = BLOCK_SIZE;

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[kj] is_power_of_2 in drivers/block/rd.c

2007-08-13 Thread vignesh babu
Replacing n & (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
---
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index 65150b5..81821d3 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -56,6 +56,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -422,7 +423,7 @@ static int __init rd_init(void)
int err = -ENOMEM;
 
if (rd_blocksize > PAGE_SIZE || rd_blocksize < 512 ||
-   (rd_blocksize & (rd_blocksize-1))) {
+   !is_power_of_2(rd_blocksize)) {
printk("RAMDISK: wrong blocksize %d, reverting to defaults\n",
   rd_blocksize);
rd_blocksize = BLOCK_SIZE;

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[kj] is_power_of_2 in mm/slub.c

2007-08-13 Thread vignesh babu
Replacing n  (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu [EMAIL PROTECTED]
---
diff --git a/mm/slub.c b/mm/slub.c
index 69d02e3..1241d14 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -20,6 +20,7 @@
 #include linux/mempolicy.h
 #include linux/ctype.h
 #include linux/kallsyms.h
+#include linux/log2.h
 
 /*
  * Lock order:
@@ -2606,7 +2607,7 @@ void __init kmem_cache_init(void)
 * around with ARCH_KMALLOC_MINALIGN
 */
BUILD_BUG_ON(KMALLOC_MIN_SIZE  256 ||
-   (KMALLOC_MIN_SIZE  (KMALLOC_MIN_SIZE - 1)));
+   !is_power_of_2(KMALLOC_MIN_SIZE));
 
for (i = 8; i  KMALLOC_MIN_SIZE; i += 8)
size_index[(i - 1) / 8] = KMALLOC_SHIFT_LOW;

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[kj] is_power_of_2 in drivers/block/rd.c

2007-08-13 Thread vignesh babu
Replacing n  (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu [EMAIL PROTECTED]
---
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index 65150b5..81821d3 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -56,6 +56,7 @@
 #include linux/backing-dev.h
 #include linux/blkpg.h
 #include linux/writeback.h
+#include linux/log2.h
 
 #include asm/uaccess.h
 
@@ -422,7 +423,7 @@ static int __init rd_init(void)
int err = -ENOMEM;
 
if (rd_blocksize  PAGE_SIZE || rd_blocksize  512 ||
-   (rd_blocksize  (rd_blocksize-1))) {
+   !is_power_of_2(rd_blocksize)) {
printk(RAMDISK: wrong blocksize %d, reverting to defaults\n,
   rd_blocksize);
rd_blocksize = BLOCK_SIZE;

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[kj] is_power_of_2 in drivers/block/rd.c

2007-08-13 Thread vignesh babu
Replacing n  (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu [EMAIL PROTECTED]
---
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index 65150b5..81821d3 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -56,6 +56,7 @@
 #include linux/backing-dev.h
 #include linux/blkpg.h
 #include linux/writeback.h
+#include linux/log2.h
 
 #include asm/uaccess.h
 
@@ -422,7 +423,7 @@ static int __init rd_init(void)
int err = -ENOMEM;
 
if (rd_blocksize  PAGE_SIZE || rd_blocksize  512 ||
-   (rd_blocksize  (rd_blocksize-1))) {
+   !is_power_of_2(rd_blocksize)) {
printk(RAMDISK: wrong blocksize %d, reverting to defaults\n,
   rd_blocksize);
rd_blocksize = BLOCK_SIZE;

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[kj] is_power_of_2 in drivers/md/dm-raid1.c

2007-08-13 Thread vignesh babu
Replacing n  (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu [EMAIL PROTECTED]
---
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 144071e..969b398 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -19,6 +19,7 @@
 #include linux/time.h
 #include linux/vmalloc.h
 #include linux/workqueue.h
+#include linux/log2.h
 
 #define DM_MSG_PREFIX raid1
 #define DM_IO_PAGES 64
@@ -994,7 +995,7 @@ static void free_context(struct mirror_set *ms, struct 
dm_target *ti,
 
 static inline int _check_region_size(struct dm_target *ti, uint32_t size)
 {
-   return !(size % (PAGE_SIZE  9) || (size  (size - 1)) ||
+   return !(size % (PAGE_SIZE  9) || !is_power_of_2(size) ||
 size  ti-len);
 }
 
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 83ddbfe..ad2836a 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -17,6 +17,7 @@
 #include linux/module.h
 #include linux/slab.h
 #include linux/vmalloc.h
+#include linux/log2.h
 
 #include dm-snap.h
 #include dm-bio-list.h
@@ -415,7 +416,7 @@ static int set_chunk_size(struct dm_snapshot *s, const char 
*chunk_size_arg,
chunk_size = round_up(chunk_size, PAGE_SIZE  9);
 
/* Check chunk_size is a power of 2 */
-   if (chunk_size  (chunk_size - 1)) {
+   if (!is_power_of_2(chunk_size)) {
*error = Chunk size is not a power of 2;
return -EINVAL;
}
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index 51f5e07..969944a 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -11,6 +11,7 @@
 #include linux/blkdev.h
 #include linux/bio.h
 #include linux/slab.h
+#include linux/log2.h
 
 #define DM_MSG_PREFIX striped
 
@@ -99,7 +100,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int 
argc, char **argv)
/*
 * chunk_size is a power of two
 */
-   if (!chunk_size || (chunk_size  (chunk_size - 1)) ||
+   if (!is_power_of_2(chunk_size) ||
(chunk_size  (PAGE_SIZE  SECTOR_SHIFT))) {
ti-error = Invalid chunk size;
return -EINVAL;

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[kj] is_power_of_2 in drivers/pci/pci.c

2007-08-13 Thread vignesh babu
Replacing n  (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu [EMAIL PROTECTED]
---
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 37c00f6..19a64a3 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -17,6 +17,7 @@
 #include linux/module.h
 #include linux/spinlock.h
 #include linux/string.h
+#include linux/log2.h
 #include asm/dma.h   /* isa_dma_bridge_buggy */
 #include pci.h
 
@@ -1454,7 +1455,7 @@ int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
int cap, err = -EINVAL;
u32 stat, cmd, v, o;
 
-   if (mmrbc  512 || mmrbc  4096 || (mmrbc  (mmrbc-1)))
+   if (mmrbc  512 || mmrbc  4096 || !is_power_of_2(mmrbc))
goto out;
 
v = ffs(mmrbc) - 10;
@@ -1526,7 +1527,7 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
int cap, err = -EINVAL;
u16 ctl, v;
 
-   if (rq  128 || rq  4096 || (rq  (rq-1)))
+   if (rq  128 || rq  4096 || !is_power_of_2(rq))
goto out;
 
v = (ffs(rq) - 8)  12;

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[kj] is_power_of_2 in ntfs

2007-08-13 Thread vignesh babu
Replacing n  (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu [EMAIL PROTECTED]
---
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index b532a73..8152f79 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -27,6 +27,7 @@
 #include linux/pagemap.h
 #include linux/quotaops.h
 #include linux/slab.h
+#include linux/log2.h
 
 #include aops.h
 #include attrib.h
@@ -1574,7 +1575,7 @@ static int ntfs_read_locked_index_inode(struct inode 
*base_vi, struct inode *vi)
ntfs_debug(Index collation rule is 0x%x.,
le32_to_cpu(ir-collation_rule));
ni-itype.index.block_size = le32_to_cpu(ir-index_block_size);
-   if (ni-itype.index.block_size  (ni-itype.index.block_size - 1)) {
+   if (!is_power_of_2(ni-itype.index.block_size)) {
ntfs_error(vi-i_sb, Index block size (%u) is not a power of 
two., ni-itype.index.block_size);
goto unm_err_out;
diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c
index acfed32..00b2d02 100644
--- a/fs/ntfs/logfile.c
+++ b/fs/ntfs/logfile.c
@@ -26,6 +26,7 @@
 #include linux/highmem.h
 #include linux/buffer_head.h
 #include linux/bitops.h
+#include linux/log2.h
 
 #include attrib.h
 #include aops.h
@@ -63,9 +64,8 @@ static bool ntfs_check_restart_page_header(struct inode *vi,
logfile_log_page_size = le32_to_cpu(rp-log_page_size);
if (logfile_system_page_size  NTFS_BLOCK_SIZE ||
logfile_log_page_size  NTFS_BLOCK_SIZE ||
-   logfile_system_page_size 
-   (logfile_system_page_size - 1) ||
-   logfile_log_page_size  (logfile_log_page_size - 1)) {
+   !is_power_of_2(logfile_system_page_size) ||
+   !is_power_of_2(logfile_log_page_size)) {
ntfs_error(vi-i_sb, $LogFile uses unsupported page size.);
return false;
}

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH]is_power_of_2-ufs/super.c

2007-06-25 Thread vignesh babu
Thanks Hannes, Im on it...

On Mon, 2007-06-25 at 14:13 +0200, Johannes Weiner wrote:
> egrep -R '([a-zA-Z0-9_.>]+) *& *\(\1 *- *1\)' /usr/src/linux
-- 
Vignesh Babu BM 
_ 
"Why is it that every time I'm with you, makes me believe in magic?"

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH]is_power_of_2-ufs/super.c

2007-06-25 Thread vignesh babu
Thanks Hannes, Im on it...

On Mon, 2007-06-25 at 14:13 +0200, Johannes Weiner wrote:
 egrep -R '([a-zA-Z0-9_.]+) * *\(\1 *- *1\)' /usr/src/linux
-- 
Vignesh Babu BM 
_ 
Why is it that every time I'm with you, makes me believe in magic?

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH]is_power_of_2-kernel/kfifo.c

2007-06-14 Thread vignesh babu

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

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
--- 
diff --git a/kernel/kfifo.c b/kernel/kfifo.c
index cee4191..bc41ad0 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /**
  * kfifo_init - allocates a new FIFO using a preallocated buffer
@@ -41,7 +42,7 @@ struct kfifo *kfifo_init(unsigned char *buffer, unsigned int 
size,
struct kfifo *fifo;
 
/* size must be a power of 2 */
-   BUG_ON(size & (size - 1));
+   BUG_ON(!is_power_of_2(size));
 
fifo = kmalloc(sizeof(struct kfifo), gfp_mask);
if (!fifo)

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH]is_power_of_2-ufs/super.c

2007-06-14 Thread vignesh babu

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

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
--- 
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 22ff6ed..2b30116 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -87,6 +87,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "swab.h"
 #include "util.h"
@@ -854,7 +855,7 @@ magic_found:
uspi->s_fmask = fs32_to_cpu(sb, usb1->fs_fmask);
uspi->s_fshift = fs32_to_cpu(sb, usb1->fs_fshift);
 
-   if (uspi->s_fsize & (uspi->s_fsize - 1)) {
+   if (!is_power_of_2(uspi->s_fsize)) {
printk(KERN_ERR "ufs_read_super: fragment size %u is not a 
power of 2\n",
uspi->s_fsize);
goto failed;
@@ -869,7 +870,7 @@ magic_found:
uspi->s_fsize);
goto failed;
}
-   if (uspi->s_bsize & (uspi->s_bsize - 1)) {
+   if (!is_power_of_2(uspi->s_bsize)) {
printk(KERN_ERR "ufs_read_super: block size %u is not a power 
of 2\n",
uspi->s_bsize);
goto failed;

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH]is_power_of_2-ntfs

2007-06-14 Thread vignesh babu

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

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
--- 
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index b532a73..8152f79 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "aops.h"
 #include "attrib.h"
@@ -1574,7 +1575,7 @@ static int ntfs_read_locked_index_inode(struct inode 
*base_vi, struct inode *vi)
ntfs_debug("Index collation rule is 0x%x.",
le32_to_cpu(ir->collation_rule));
ni->itype.index.block_size = le32_to_cpu(ir->index_block_size);
-   if (ni->itype.index.block_size & (ni->itype.index.block_size - 1)) {
+   if (!is_power_of_2(ni->itype.index.block_size)) {
ntfs_error(vi->i_sb, "Index block size (%u) is not a power of "
"two.", ni->itype.index.block_size);
goto unm_err_out;
diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c
index acfed32..53cdb74 100644
--- a/fs/ntfs/logfile.c
+++ b/fs/ntfs/logfile.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "attrib.h"
 #include "aops.h"
@@ -63,9 +64,8 @@ static bool ntfs_check_restart_page_header(struct inode *vi,
logfile_log_page_size = le32_to_cpu(rp->log_page_size);
if (logfile_system_page_size < NTFS_BLOCK_SIZE ||
logfile_log_page_size < NTFS_BLOCK_SIZE ||
-   logfile_system_page_size &
-   (logfile_system_page_size - 1) ||
-   logfile_log_page_size & (logfile_log_page_size - 1)) {
+   !is_power_of_2(logfile_system_page_size) ||
+   !is_power_of_2(logfile_log_page_size)) {
    ntfs_error(vi->i_sb, "$LogFile uses unsupported page size.");
return false;
}

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH]is_power_of_2-ntfs

2007-06-14 Thread vignesh babu

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

Signed-off-by: vignesh babu [EMAIL PROTECTED]
--- 
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index b532a73..8152f79 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -27,6 +27,7 @@
 #include linux/pagemap.h
 #include linux/quotaops.h
 #include linux/slab.h
+#include linux/log2.h
 
 #include aops.h
 #include attrib.h
@@ -1574,7 +1575,7 @@ static int ntfs_read_locked_index_inode(struct inode 
*base_vi, struct inode *vi)
ntfs_debug(Index collation rule is 0x%x.,
le32_to_cpu(ir-collation_rule));
ni-itype.index.block_size = le32_to_cpu(ir-index_block_size);
-   if (ni-itype.index.block_size  (ni-itype.index.block_size - 1)) {
+   if (!is_power_of_2(ni-itype.index.block_size)) {
ntfs_error(vi-i_sb, Index block size (%u) is not a power of 
two., ni-itype.index.block_size);
goto unm_err_out;
diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c
index acfed32..53cdb74 100644
--- a/fs/ntfs/logfile.c
+++ b/fs/ntfs/logfile.c
@@ -26,6 +26,7 @@
 #include linux/highmem.h
 #include linux/buffer_head.h
 #include linux/bitops.h
+#include linux/log2.h
 
 #include attrib.h
 #include aops.h
@@ -63,9 +64,8 @@ static bool ntfs_check_restart_page_header(struct inode *vi,
logfile_log_page_size = le32_to_cpu(rp-log_page_size);
if (logfile_system_page_size  NTFS_BLOCK_SIZE ||
logfile_log_page_size  NTFS_BLOCK_SIZE ||
-   logfile_system_page_size 
-   (logfile_system_page_size - 1) ||
-   logfile_log_page_size  (logfile_log_page_size - 1)) {
+   !is_power_of_2(logfile_system_page_size) ||
+   !is_power_of_2(logfile_log_page_size)) {
ntfs_error(vi-i_sb, $LogFile uses unsupported page size.);
return false;
}

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH]is_power_of_2-ufs/super.c

2007-06-14 Thread vignesh babu

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

Signed-off-by: vignesh babu [EMAIL PROTECTED]
--- 
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 22ff6ed..2b30116 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -87,6 +87,7 @@
 #include linux/smp_lock.h
 #include linux/buffer_head.h
 #include linux/vfs.h
+#include linux/log2.h
 
 #include swab.h
 #include util.h
@@ -854,7 +855,7 @@ magic_found:
uspi-s_fmask = fs32_to_cpu(sb, usb1-fs_fmask);
uspi-s_fshift = fs32_to_cpu(sb, usb1-fs_fshift);
 
-   if (uspi-s_fsize  (uspi-s_fsize - 1)) {
+   if (!is_power_of_2(uspi-s_fsize)) {
printk(KERN_ERR ufs_read_super: fragment size %u is not a 
power of 2\n,
uspi-s_fsize);
goto failed;
@@ -869,7 +870,7 @@ magic_found:
uspi-s_fsize);
goto failed;
}
-   if (uspi-s_bsize  (uspi-s_bsize - 1)) {
+   if (!is_power_of_2(uspi-s_bsize)) {
printk(KERN_ERR ufs_read_super: block size %u is not a power 
of 2\n,
uspi-s_bsize);
goto failed;

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH]is_power_of_2-kernel/kfifo.c

2007-06-14 Thread vignesh babu

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

Signed-off-by: vignesh babu [EMAIL PROTECTED]
--- 
diff --git a/kernel/kfifo.c b/kernel/kfifo.c
index cee4191..bc41ad0 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -24,6 +24,7 @@
 #include linux/slab.h
 #include linux/err.h
 #include linux/kfifo.h
+#include linux/log2.h
 
 /**
  * kfifo_init - allocates a new FIFO using a preallocated buffer
@@ -41,7 +42,7 @@ struct kfifo *kfifo_init(unsigned char *buffer, unsigned int 
size,
struct kfifo *fifo;
 
/* size must be a power of 2 */
-   BUG_ON(size  (size - 1));
+   BUG_ON(!is_power_of_2(size));
 
fifo = kmalloc(sizeof(struct kfifo), gfp_mask);
if (!fifo)

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH]is_power_of_2-hfs/mdb.c

2007-06-12 Thread vignesh babu

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

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
--- 
diff --git a/fs/hfs/mdb.c b/fs/hfs/mdb.c
index b4651e1..8bda11d 100644
--- a/fs/hfs/mdb.c
+++ b/fs/hfs/mdb.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "hfs_fs.h"
 #include "btree.h"
@@ -106,7 +107,7 @@ int hfs_mdb_get(struct super_block *sb)
 
size = min(HFS_SB(sb)->alloc_blksz, (u32)PAGE_SIZE);
/* size must be a multiple of 512 */
-   while (size & (size - 1))
+   while (!is_power_of_2(size))
size -= HFS_SECTOR_SIZE;
sect = be16_to_cpu(mdb->drAlBlSt) + part_start;
/* align block size to first sector */

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH]is_power_of_2-hfs/mdb.c

2007-06-12 Thread vignesh babu

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

Signed-off-by: vignesh babu [EMAIL PROTECTED]
--- 
diff --git a/fs/hfs/mdb.c b/fs/hfs/mdb.c
index b4651e1..8bda11d 100644
--- a/fs/hfs/mdb.c
+++ b/fs/hfs/mdb.c
@@ -11,6 +11,7 @@
 #include linux/cdrom.h
 #include linux/genhd.h
 #include linux/nls.h
+#include linux/log2.h
 
 #include hfs_fs.h
 #include btree.h
@@ -106,7 +107,7 @@ int hfs_mdb_get(struct super_block *sb)
 
size = min(HFS_SB(sb)-alloc_blksz, (u32)PAGE_SIZE);
/* size must be a multiple of 512 */
-   while (size  (size - 1))
+   while (!is_power_of_2(size))
size -= HFS_SECTOR_SIZE;
sect = be16_to_cpu(mdb-drAlBlSt) + part_start;
/* align block size to first sector */

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH]is_power_of_2-ia64/mm/hugetlbpage.c

2007-06-07 Thread vignesh babu

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

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
--- 
diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index 1346b7f..d22861c 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -182,7 +183,7 @@ static int __init hugetlb_setup_sz(char *str)
tr_pages = 0x15557000UL;
 
size = memparse(str, );
-   if (*str || (size & (size-1)) || !(tr_pages & size) ||
+   if (*str || !is_power_of_2(size) || !(tr_pages & size) ||
size <= PAGE_SIZE ||
size >= (1UL << PAGE_SHIFT << MAX_ORDER)) {
printk(KERN_WARNING "Invalid huge page size specified\n");

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH]is_power_of_2-block/rd.c

2007-06-07 Thread vignesh babu

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

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
--- 
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index a1512da..e57f729 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -56,6 +56,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -422,7 +423,7 @@ static int __init rd_init(void)
int err = -ENOMEM;
 
if (rd_blocksize > PAGE_SIZE || rd_blocksize < 512 ||
-   (rd_blocksize & (rd_blocksize-1))) {
+   !is_power_of_2(rd_blocksize)) {
printk("RAMDISK: wrong blocksize %d, reverting to defaults\n",
   rd_blocksize);
rd_blocksize = BLOCK_SIZE;

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH]is_power_of_2-sparc/mm/srmmu.c

2007-06-07 Thread vignesh babu

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

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
--- 
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index e5eaa80..741d303 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -19,6 +19,7 @@
#include 
#include 
#include 
+#include 

#include 
#include 
@@ -354,7 +355,7 @@ void srmmu_free_nocache(unsigned long vaddr, int
size)
vaddr, srmmu_nocache_end);
BUG();
}
- if (size & (size-1)) {
+ if (!is_power_of_2(size)) {
printk("Size 0x%x is not a power of 2\n", size);
BUG();
}

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[no subject]

2007-06-07 Thread vignesh babu

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

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
--- 
diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index 1346b7f..d22861c 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -182,7 +183,7 @@ static int __init hugetlb_setup_sz(char *str)
tr_pages = 0x15557000UL;
 
size = memparse(str, );
-   if (*str || (size & (size-1)) || !(tr_pages & size) ||
+   if (*str || !is_power_of_2(size) || !(tr_pages & size) ||
size <= PAGE_SIZE ||
size >= (1UL << PAGE_SHIFT << MAX_ORDER)) {
printk(KERN_WARNING "Invalid huge page size specified\n");

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[no subject]

2007-06-07 Thread vignesh babu

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

Signed-off-by: vignesh babu [EMAIL PROTECTED]
--- 
diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index 1346b7f..d22861c 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -15,6 +15,7 @@
 #include linux/pagemap.h
 #include linux/slab.h
 #include linux/sysctl.h
+#include linux/log2.h
 #include asm/mman.h
 #include asm/pgalloc.h
 #include asm/tlb.h
@@ -182,7 +183,7 @@ static int __init hugetlb_setup_sz(char *str)
tr_pages = 0x15557000UL;
 
size = memparse(str, str);
-   if (*str || (size  (size-1)) || !(tr_pages  size) ||
+   if (*str || !is_power_of_2(size) || !(tr_pages  size) ||
size = PAGE_SIZE ||
size = (1UL  PAGE_SHIFT  MAX_ORDER)) {
printk(KERN_WARNING Invalid huge page size specified\n);

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH]is_power_of_2-block/rd.c

2007-06-07 Thread vignesh babu

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

Signed-off-by: vignesh babu [EMAIL PROTECTED]
--- 
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index a1512da..e57f729 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -56,6 +56,7 @@
 #include linux/backing-dev.h
 #include linux/blkpg.h
 #include linux/writeback.h
+#include linux/log2.h
 
 #include asm/uaccess.h
 
@@ -422,7 +423,7 @@ static int __init rd_init(void)
int err = -ENOMEM;
 
if (rd_blocksize  PAGE_SIZE || rd_blocksize  512 ||
-   (rd_blocksize  (rd_blocksize-1))) {
+   !is_power_of_2(rd_blocksize)) {
printk(RAMDISK: wrong blocksize %d, reverting to defaults\n,
   rd_blocksize);
rd_blocksize = BLOCK_SIZE;

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH]is_power_of_2-sparc/mm/srmmu.c

2007-06-07 Thread vignesh babu

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

Signed-off-by: vignesh babu [EMAIL PROTECTED]
--- 
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index e5eaa80..741d303 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -19,6 +19,7 @@
#include linux/fs.h
#include linux/seq_file.h
#include linux/kdebug.h
+#include linux/log2.h

#include asm/bitext.h
#include asm/page.h
@@ -354,7 +355,7 @@ void srmmu_free_nocache(unsigned long vaddr, int
size)
vaddr, srmmu_nocache_end);
BUG();
}
- if (size  (size-1)) {
+ if (!is_power_of_2(size)) {
printk(Size 0x%x is not a power of 2\n, size);
BUG();
}

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH]is_power_of_2-ia64/mm/hugetlbpage.c

2007-06-07 Thread vignesh babu

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

Signed-off-by: vignesh babu [EMAIL PROTECTED]
--- 
diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index 1346b7f..d22861c 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -15,6 +15,7 @@
 #include linux/pagemap.h
 #include linux/slab.h
 #include linux/sysctl.h
+#include linux/log2.h
 #include asm/mman.h
 #include asm/pgalloc.h
 #include asm/tlb.h
@@ -182,7 +183,7 @@ static int __init hugetlb_setup_sz(char *str)
tr_pages = 0x15557000UL;
 
size = memparse(str, str);
-   if (*str || (size  (size-1)) || !(tr_pages  size) ||
+   if (*str || !is_power_of_2(size) || !(tr_pages  size) ||
size = PAGE_SIZE ||
size = (1UL  PAGE_SHIFT  MAX_ORDER)) {
printk(KERN_WARNING Invalid huge page size specified\n);

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

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kmalloc() with size zero

2007-03-22 Thread Vignesh Babu BM
On Fri, 2007-03-23 at 07:08 +0530, Jan Engelhardt wrote:
> 
> On Mar 22 2007 16:18, Stephane Eranian wrote:
> >
> I'd say "feature", glibc's malloc also returns an address on
> malloc(0).
> 
This is implementation defined-the standard allows for return of either
null or an address.
> 
> Jan
> --
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-kernel" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 
-- 
Regards,  
Vignesh Babu BM  
_  
"Why is it that every time I'm with you, makes me believe in magic?"
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kmalloc() with size zero

2007-03-22 Thread Vignesh Babu BM
On Fri, 2007-03-23 at 07:08 +0530, Jan Engelhardt wrote:
 
 On Mar 22 2007 16:18, Stephane Eranian wrote:
 
 I'd say feature, glibc's malloc also returns an address on
 malloc(0).
 
This is implementation defined-the standard allows for return of either
null or an address.
 
 Jan
 --
 -
 To unsubscribe from this list: send the line unsubscribe
 linux-kernel in
 the body of a message to [EMAIL PROTECTED]
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/
 
 
-- 
Regards,  
Vignesh Babu BM  
_  
Why is it that every time I'm with you, makes me believe in magic?
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH] is_power_of_2 in fs/block_dev.c

2007-02-19 Thread Vignesh Babu BM
Replacing (n & (n-1)) in the context of power of 2 checks
with is_power_of_2


Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
--- 
diff --git a/fs/block_dev.c b/fs/block_dev.c
index fc7028b..e8f2a2b 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "internal.h"
 
@@ -65,7 +66,7 @@ static void kill_bdev(struct block_device *bdev)
 int set_blocksize(struct block_device *bdev, int size)
 {
/* Size must be a power of two, and between 512 and PAGE_SIZE */
-   if (size > PAGE_SIZE || size < 512 || (size & (size-1)))
+   if (size > PAGE_SIZE || size < 512 || !is_power_of_2(size))
return -EINVAL;
 
/* Size cannot be smaller than the size supported by the device */

-- 
Regards,  
Vignesh Babu BM  
_  
"Why is it that every time I'm with you, makes me believe in magic?"
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH] is_power_of_2 in fat

2007-02-19 Thread Vignesh Babu BM
Replacing (n & (n-1)) in the context of power of 2 checks
with is_power_of_2

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
--- 
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index a9e4688..8437190 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #ifndef CONFIG_FAT_DEFAULT_IOCHARSET
@@ -1216,8 +1217,7 @@ int fat_fill_super(struct super_block *sb, void *data, 
int silent,
}
logical_sector_size =
le16_to_cpu(get_unaligned((__le16 *)>sector_size));
-   if (!logical_sector_size
-   || (logical_sector_size & (logical_sector_size - 1))
+   if (!is_power_of_2(logical_sector_size)
|| (logical_sector_size < 512)
|| (PAGE_CACHE_SIZE < logical_sector_size)) {
if (!silent)
@@ -1227,8 +1227,7 @@ int fat_fill_super(struct super_block *sb, void *data, 
int silent,
goto out_invalid;
}
sbi->sec_per_clus = b->sec_per_clus;
-   if (!sbi->sec_per_clus
-   || (sbi->sec_per_clus & (sbi->sec_per_clus - 1))) {
+   if (!is_power_of_2(sbi->sec_per_clus)) {
if (!silent)
printk(KERN_ERR "FAT: bogus sectors per cluster %u\n",
       sbi->sec_per_clus);

-- 
Regards,  
Vignesh Babu BM  
_  
"Why is it that every time I'm with you, makes me believe in magic?"
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH] is_power_of_2 in fs/hfs

2007-02-19 Thread Vignesh Babu BM
Replacing (n & (n-1)) in the context of power of 2 checks 
with is_power_of_2

Signed-off-by: vignesh babu <[EMAIL PROTECTED]>
--- 
diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c
index 5fd0ed7..8a3a650 100644
--- a/fs/hfs/btree.c
+++ b/fs/hfs/btree.c
@@ -9,6 +9,7 @@
  */
 
 #include 
+#include 
 
 #include "btree.h"
 
@@ -76,7 +77,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 
id, btree_keycmp ke
tree->depth = be16_to_cpu(head->depth);
 
size = tree->node_size;
-   if (!size || size & (size - 1))
+   if (!is_power_of_2(size))
goto fail_page;
if (!tree->node_count)
goto fail_page;
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
index a9b9e87..90ebab7 100644
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include 
 
 #include "hfsplus_fs.h"
 #include "hfsplus_raw.h"
@@ -69,7 +70,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 
id)
}
 
size = tree->node_size;
-   if (!size || size & (size - 1))
+   if (!is_power_of_2(size))
goto fail_page;
if (!tree->node_count)
goto fail_page;

-- 
Regards,  
Vignesh Babu BM  
_  
"Why is it that every time I'm with you, makes me believe in magic?"
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH] is_power_of_2 in fat

2007-02-19 Thread Vignesh Babu BM
Replacing (n  (n-1)) in the context of power of 2 checks
with is_power_of_2

Signed-off-by: vignesh babu [EMAIL PROTECTED]
--- 
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index a9e4688..8437190 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -25,6 +25,7 @@
 #include linux/parser.h
 #include linux/uio.h
 #include linux/writeback.h
+#include linux/log2.h
 #include asm/unaligned.h
 
 #ifndef CONFIG_FAT_DEFAULT_IOCHARSET
@@ -1216,8 +1217,7 @@ int fat_fill_super(struct super_block *sb, void *data, 
int silent,
}
logical_sector_size =
le16_to_cpu(get_unaligned((__le16 *)b-sector_size));
-   if (!logical_sector_size
-   || (logical_sector_size  (logical_sector_size - 1))
+   if (!is_power_of_2(logical_sector_size)
|| (logical_sector_size  512)
|| (PAGE_CACHE_SIZE  logical_sector_size)) {
if (!silent)
@@ -1227,8 +1227,7 @@ int fat_fill_super(struct super_block *sb, void *data, 
int silent,
goto out_invalid;
}
sbi-sec_per_clus = b-sec_per_clus;
-   if (!sbi-sec_per_clus
-   || (sbi-sec_per_clus  (sbi-sec_per_clus - 1))) {
+   if (!is_power_of_2(sbi-sec_per_clus)) {
if (!silent)
printk(KERN_ERR FAT: bogus sectors per cluster %u\n,
   sbi-sec_per_clus);

-- 
Regards,  
Vignesh Babu BM  
_  
Why is it that every time I'm with you, makes me believe in magic?
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH] is_power_of_2 in fs/hfs

2007-02-19 Thread Vignesh Babu BM
Replacing (n  (n-1)) in the context of power of 2 checks 
with is_power_of_2

Signed-off-by: vignesh babu [EMAIL PROTECTED]
--- 
diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c
index 5fd0ed7..8a3a650 100644
--- a/fs/hfs/btree.c
+++ b/fs/hfs/btree.c
@@ -9,6 +9,7 @@
  */
 
 #include linux/pagemap.h
+#include linux/log2.h
 
 #include btree.h
 
@@ -76,7 +77,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 
id, btree_keycmp ke
tree-depth = be16_to_cpu(head-depth);
 
size = tree-node_size;
-   if (!size || size  (size - 1))
+   if (!is_power_of_2(size))
goto fail_page;
if (!tree-node_count)
goto fail_page;
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
index a9b9e87..90ebab7 100644
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -10,6 +10,7 @@
 
 #include linux/slab.h
 #include linux/pagemap.h
+#include linux/log2.h
 
 #include hfsplus_fs.h
 #include hfsplus_raw.h
@@ -69,7 +70,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 
id)
}
 
size = tree-node_size;
-   if (!size || size  (size - 1))
+   if (!is_power_of_2(size))
goto fail_page;
if (!tree-node_count)
goto fail_page;

-- 
Regards,  
Vignesh Babu BM  
_  
Why is it that every time I'm with you, makes me believe in magic?
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH] is_power_of_2 in fs/block_dev.c

2007-02-19 Thread Vignesh Babu BM
Replacing (n  (n-1)) in the context of power of 2 checks
with is_power_of_2


Signed-off-by: vignesh babu [EMAIL PROTECTED]
--- 
diff --git a/fs/block_dev.c b/fs/block_dev.c
index fc7028b..e8f2a2b 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -22,6 +22,7 @@
 #include linux/mount.h
 #include linux/uio.h
 #include linux/namei.h
+#include linux/log2.h
 #include asm/uaccess.h
 #include internal.h
 
@@ -65,7 +66,7 @@ static void kill_bdev(struct block_device *bdev)
 int set_blocksize(struct block_device *bdev, int size)
 {
/* Size must be a power of two, and between 512 and PAGE_SIZE */
-   if (size  PAGE_SIZE || size  512 || (size  (size-1)))
+   if (size  PAGE_SIZE || size  512 || !is_power_of_2(size))
return -EINVAL;
 
/* Size cannot be smaller than the size supported by the device */

-- 
Regards,  
Vignesh Babu BM  
_  
Why is it that every time I'm with you, makes me believe in magic?
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH] is_power_of_2 in ia64mm

2007-02-16 Thread Vignesh Babu BM
Replacing (n & (n-1)) in the context of power of 2 checks
with is_power_of_2


diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index 0c7e94e..0ccc70e 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -175,7 +176,7 @@ static int __init hugetlb_setup_sz(char *str)
tr_pages = 0x15557000UL;
 
size = memparse(str, );
-   if (*str || (size & (size-1)) || !(tr_pages & size) ||
+   if (*str || !is_power_of_2(size) || !(tr_pages & size) ||
size <= PAGE_SIZE ||
size >= (1UL << PAGE_SHIFT << MAX_ORDER)) {
printk(KERN_WARNING "Invalid huge page size specified\n");

-- 
Regards,  
Vignesh Babu BM  
_  
"Why is it that every time I'm with you, makes me believe in magic?"
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[KJ][PATCH] is_power_of_2 in ia64mm

2007-02-16 Thread Vignesh Babu BM
Replacing (n  (n-1)) in the context of power of 2 checks
with is_power_of_2


diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index 0c7e94e..0ccc70e 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -16,6 +16,7 @@
 #include linux/smp_lock.h
 #include linux/slab.h
 #include linux/sysctl.h
+#include linux/log2.h
 #include asm/mman.h
 #include asm/pgalloc.h
 #include asm/tlb.h
@@ -175,7 +176,7 @@ static int __init hugetlb_setup_sz(char *str)
tr_pages = 0x15557000UL;
 
size = memparse(str, str);
-   if (*str || (size  (size-1)) || !(tr_pages  size) ||
+   if (*str || !is_power_of_2(size) || !(tr_pages  size) ||
size = PAGE_SIZE ||
size = (1UL  PAGE_SHIFT  MAX_ORDER)) {
printk(KERN_WARNING Invalid huge page size specified\n);

-- 
Regards,  
Vignesh Babu BM  
_  
Why is it that every time I'm with you, makes me believe in magic?
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/