Skip to contentSkip to conversation

Remove uses and definition of IS_PO2

PATCH Superseded Aya Mahfouz 1 participant 6 messages Oct 18, 2015 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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

This is the second version of the patch set. The commit messages were changed and a new patch was added for a use of IS_PO2 indicated by kbuild test robot.

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      | 4 +++-
 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c     | 5 ++++-
 drivers/staging/lustre/lustre/libcfs/hash.c          | 4 +++-
 drivers/staging/lustre/lustre/libcfs/workitem.c      | 4 +++-
 5 files changed, 13 insertions(+), 11 deletions(-)
Signature · 6 lines
2.4.2


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

PATCH v2 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

 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +4 -1
index 57b997d..3e7e97e 100644
@@ -50,6 +50,9 @@
  */
 
 #define DEBUG_SUBSYSTEM S_LDLM
+
+#include <linux/log2.h>
+
 #include "../../include/linux/libcfs/libcfs.h"
 #include "../include/lustre_dlm.h"
 #include "../include/obd_support.h"
@@ -149,7 +152,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 v2 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

 drivers/staging/lustre/lustre/libcfs/hash.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/libcfs/hash.c +3 -1
index 6f4c7d4..4b5e79a 100644
@@ -109,6 +109,8 @@
 
 #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;
@@ -1785,7 +1787,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
#3 lore raw

PATCH v2 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

 drivers/staging/lustre/lustre/libcfs/workitem.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/libcfs/workitem.c +3 -1
index e1143a5..377e1ea 100644
@@ -41,6 +41,8 @@
 
 #define DEBUG_SUBSYSTEM S_LNET
 
+#include <linux/log2.h>
+
 #include "../../include/linux/libcfs/libcfs.h"
 
 #define CFS_WS_NAME_LEN	 16
@@ -325,7 +327,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
#4 lore raw

PATCH v2 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

 drivers/staging/lustre/lnet/selftest/selftest.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/lustre/lnet/selftest/selftest.h +3 -1
index 8a77d3f..2846f26 100644
@@ -43,6 +43,8 @@
 
 #define LNET_ONLY
 
+#include <linux/log2.h>
+
 #include "../../include/linux/libcfs/libcfs.h"
 #include "../../include/linux/lnet/lnet.h"
 #include "../../include/linux/lnet/lib-lnet.h"
@@ -585,7 +587,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
#5 lore raw

PATCH v2 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

 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 385ced1..c78a147 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