Skip to contentSkip to conversation

Remove uses and definition of IS_PO2

PATCH New Aya Mahfouz 2 participants 9 messages Oct 29, 2015 – Nov 7, 2015 Staging

lore
Share & tools
lore
#0 lore raw

v3 cover Remove uses and definition of IS_PO2

Concerned with the removal of IS_PO2 by replacing its uses with is_power_of_2 and then removing the definition.

The second version handled warnings indicated by kbuild test robot. The third version handled checkpatch.pl warnings indicated by Sudip Mukherjee.

Aya Mahfouz (5):
staging: lustre: ldlm_extent.c: replace IS_PO2 by is_power_of_2
staging: lustre: hash.c: Replace IS_PO2 by is_power_of_2
staging: lustre: workitem.c: replace IS_PO2 by is_power_of_2
staging: lustre: selftest.h: replace IS_PO2 by is_power_of_2
staging: lustre: libcfs.h: remove IS_PO2 and __is_po2

 drivers/staging/lustre/include/linux/libcfs/libcfs.h | 7 -------
 drivers/staging/lustre/lnet/selftest/selftest.h      | 2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c     | 2 +-
 drivers/staging/lustre/lustre/libcfs/hash.c          | 3 ++-
 drivers/staging/lustre/lustre/libcfs/workitem.c      | 2 +-
 5 files changed, 5 insertions(+), 11 deletions(-)
Signature · 6 lines
2.4.2


-- 
Kind Regards,
Aya Saif El-yazal Mahfouz
#1 lore raw

PATCH v3 1/5 staging: lustre: ldlm_extent.c: replace IS_PO2 by is_power_of_2

Replaces IS_PO2 by is_power_of_2. It is more accurate to use is_power_of_2 since it returns 1 for numbers that are powers of 2 only whereas IS_PO2 returns 1 for 0 and numbers that are powers of 2.

---
v2:
-changed commit message
v3:
-no change

 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +1 -1
index c787888..9c70f31 100644
@@ -149,7 +149,7 @@ static inline int lock_mode_to_index(ldlm_mode_t mode)
 	int index;
 
 	LASSERT(mode != 0);
-	LASSERT(IS_PO2(mode));
+	LASSERT(is_power_of_2(mode));
 	for (index = -1; mode; index++)
 		mode >>= 1;
 	LASSERT(index < LCK_MODE_NUM);
Signature · 6 lines
2.4.2


-- 
Kind Regards,
Aya Saif El-yazal Mahfouz
#2 lore raw

PATCH v3 2/5 staging: lustre: hash.c: Replace IS_PO2 by is_power_of_2

In reply to Aya Mahfouz

Replaces IS_PO2 by is_power_of_2. It is more accurate to use is_power_of_2 since it returns 1 for numbers that are powers of 2 only whereas IS_PO2 returns 1 for 0 and numbers that are powers of 2.

---
v2:
-changed commit message
-added Andreas Reviewed by tag
v3:
-fixed checkpatch.pl warning

 drivers/staging/lustre/lustre/libcfs/hash.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/libcfs/hash.c +2 -1
index 0308744..ec26916 100644
@@ -109,6 +109,7 @@
 
 #include "../../include/linux/libcfs/libcfs.h"
 #include <linux/seq_file.h>
+#include <linux/log2.h>
 
 #if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1
 static unsigned int warn_on_depth = 8;
@@ -1794,7 +1795,7 @@ cfs_hash_rehash_cancel_locked(struct cfs_hash *hs)
 	for (i = 2; cfs_hash_is_rehashing(hs); i++) {
 		cfs_hash_unlock(hs, 1);
 		/* raise console warning while waiting too long */
-		CDEBUG(IS_PO2(i >> 3) ? D_WARNING : D_INFO,
+		CDEBUG(is_power_of_2(i >> 3) ? D_WARNING : D_INFO,
 		       "hash %s is still rehashing, rescheded %d\n",
 		       hs->hs_name, i - 1);
 		cond_resched();
Signature · 6 lines
2.4.2


-- 
Kind Regards,
Aya Saif El-yazal Mahfouz
maintainer
#3 lore raw

PATCH v3 2/5 staging: lustre: hash.c: Replace IS_PO2 by is_power_of_2

Quoted 14 lines · Aya Mahfouz

Replaces IS_PO2 by is_power_of_2. It is more accurate to use is_power_of_2 since it returns 1 for numbers that are powers of 2 only whereas IS_PO2 returns 1 for 0 and numbers that are powers of 2.

---
v2:
-changed commit message
-added Andreas Reviewed by tag
v3:
-fixed checkpatch.pl warning

Quoted 2 lines
 drivers/staging/lustre/lustre/libcfs/hash.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

This doesn't apply to my tree, can you please refresh it and resend?

thanks,

greg k-h

#4 lore raw

PATCH v3 3/5 staging: lustre: workitem.c: replace IS_PO2 by is_power_of_2

In reply to Aya Mahfouz

Replaces IS_PO2 by is_power_of_2. It is more accurate to use is_power_of_2 since it returns 1 for numbers that are powers of 2 only whereas IS_PO2 returns 1 for 0 and numbers that are powers of 2.

---
v2:
-changed commit message
-added Andreas Reviewed by tag
v3:
-no change

 drivers/staging/lustre/lustre/libcfs/workitem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/libcfs/workitem.c +1 -1
index e1143a5..268dd68 100644
@@ -325,7 +325,7 @@ cfs_wi_sched_destroy(struct cfs_wi_sched *sched)
 
 	spin_lock(&cfs_wi_data.wi_glock);
 	while (sched->ws_nthreads > 0) {
-		CDEBUG(IS_PO2(++i) ? D_WARNING : D_NET,
+		CDEBUG(is_power_of_2(++i) ? D_WARNING : D_NET,
 		       "waiting for %d threads of WI sched[%s] to terminate\n",
 		       sched->ws_nthreads, sched->ws_name);
 
Signature · 6 lines
2.4.2


-- 
Kind Regards,
Aya Saif El-yazal Mahfouz
#5 lore raw

PATCH v3 4/5 staging: lustre: selftest.h: replace IS_PO2 by is_power_of_2

In reply to Aya Mahfouz

Replaces IS_PO2 by is_power_of_2. It is more accurate to use is_power_of_2 since it returns 1 for numbers that are powers of 2 only whereas IS_PO2 returns 1 for 0 and numbers that are powers of 2.

---
v2:
-added new patch in patch set for selftest.h
v3:
-fixed checkpatch.pl warning

 drivers/staging/lustre/lnet/selftest/selftest.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lnet/selftest/selftest.h +1 -1
index 8a77d3f..15b3b34 100644
@@ -585,7 +585,7 @@ swi_state2str (int state)
 do {									\
 	int __I = 2;							\
 	while (!(cond)) {						\
-		CDEBUG(IS_PO2(++__I) ? D_WARNING : D_NET,		\
+		CDEBUG(is_power_of_2(++__I) ? D_WARNING : D_NET,	\
 		       fmt, ## __VA_ARGS__);				\
 		spin_unlock(&(lock));					\
 									\
Signature · 6 lines
2.4.2


-- 
Kind Regards,
Aya Saif El-yazal Mahfouz
#6 lore raw

PATCH v3 5/5 staging: lustre: libcfs.h: remove IS_PO2 and __is_po2

In reply to Aya Mahfouz

Removes IS_PO2 and __is_po2 since the uses of IS_PO2 have been replaced by is_power_of_2

---
v2:
-became patch number 5 in the series
v3:
-no change

 drivers/staging/lustre/include/linux/libcfs/libcfs.h | 7 -------
 1 file changed, 7 deletions(-)
drivers/staging/lustre/include/linux/libcfs/libcfs.h +0 -7
index 4d74e8a..7f76b20 100644
@@ -42,13 +42,6 @@
 
 #include "curproc.h"
 
-static inline int __is_po2(unsigned long long val)
-{
-	return !(val & (val - 1));
-}
-
-#define IS_PO2(val) __is_po2((unsigned long long)(val))
-
 #define LOWEST_BIT_SET(x)       ((x) & ~((x) - 1))
 
 /*
Signature · 6 lines
2.4.2


-- 
Kind Regards,
Aya Saif El-yazal Mahfouz
maintainer
#7 lore raw

PATCH v3 5/5 staging: lustre: libcfs.h: remove IS_PO2 and __is_po2

Quoted 4 lines · Aya Mahfouz

Removes IS_PO2 and __is_po2 since the uses of IS_PO2 have been replaced by is_power_of_2

Quoted 8 lines

---
v2:
-became patch number 5 in the series
v3:
-no change

 drivers/staging/lustre/include/linux/libcfs/libcfs.h | 7 -------
 1 file changed, 7 deletions(-)

I can't take this yet, as your patch 2/5 didn't apply :(

#8 lore raw

PATCH v3 5/5 staging: lustre: libcfs.h: remove IS_PO2 and __is_po2

Quoted 11 lines · Greg KH
Quoted 10 lines · Aya Mahfouz

Removes IS_PO2 and __is_po2 since the uses of IS_PO2 have been replaced by is_power_of_2

---
v2:
-became patch number 5 in the series
v3:
-no change

Quoted 4 lines
Quoted 2 lines
 drivers/staging/lustre/include/linux/libcfs/libcfs.h | 7 -------
 1 file changed, 7 deletions(-)

I can't take this yet, as your patch 2/5 didn't apply :(

No, problems. I understand that it is hard for these patches to apply as is given that they are quite old. I will recheck if there are new uses of them and resend this patch alone or in another patchset.

Thanks,

Signature · 2 lines
Kind Regards,
Aya Saif El-yazal Mahfouz