lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190802000041.24513-1-leonardo@linux.ibm.com>
Date:   Thu,  1 Aug 2019 21:00:41 -0300
From:   Leonardo Bras <leonardo@...ux.ibm.com>
To:     linux-kernel@...r.kernel.org
Cc:     Leonardo Bras <leonardo@...ux.ibm.com>,
        Jens Axboe <axboe@...nel.dk>, Dennis Zhou <dennis@...nel.org>,
        Hannes Reinecke <hare@...e.com>,
        Damien Le Moal <damien.lemoal@....com>,
        Tejun Heo <tj@...nel.org>,
        "Dennis Zhou (Facebook)" <dennisszhou@...il.com>,
        Johannes Thumshirn <jthumshirn@...e.de>,
        Sagi Grimberg <sagi@...mberg.me>
Subject: [PATCH 1/1] block: Use bits.h macros to improve readability

Applies some bits.h macros in order to improve readability of
linux/blk_types.h.

Signed-off-by: Leonardo Bras <leonardo@...ux.ibm.com>
---
 include/linux/blk_types.h | 55 ++++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 95202f80676c..31c8c6d274f6 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -9,6 +9,7 @@
 #include <linux/types.h>
 #include <linux/bvec.h>
 #include <linux/ktime.h>
+#include <linux/bits.h>
 
 struct bio_set;
 struct bio;
@@ -101,13 +102,13 @@ static inline bool blk_path_error(blk_status_t error)
 #define BIO_ISSUE_SIZE_BITS     12
 #define BIO_ISSUE_RES_SHIFT     (64 - BIO_ISSUE_RES_BITS)
 #define BIO_ISSUE_SIZE_SHIFT    (BIO_ISSUE_RES_SHIFT - BIO_ISSUE_SIZE_BITS)
-#define BIO_ISSUE_TIME_MASK     ((1ULL << BIO_ISSUE_SIZE_SHIFT) - 1)
+#define BIO_ISSUE_TIME_MASK     GENMASK_ULL(BIO_ISSUE_SIZE_SHIFT - 1, 0)
 #define BIO_ISSUE_SIZE_MASK     \
-	(((1ULL << BIO_ISSUE_SIZE_BITS) - 1) << BIO_ISSUE_SIZE_SHIFT)
-#define BIO_ISSUE_RES_MASK      (~((1ULL << BIO_ISSUE_RES_SHIFT) - 1))
+	GENMASK_ULL(BIO_ISSUE_RES_SHIFT - 1, BIO_ISSUE_SIZE_SHIFT)
+#define BIO_ISSUE_RES_MASK      GENMASK_ULL(64, BIO_ISSUE_RES_SHIFT)
 
 /* Reserved bit for blk-throtl */
-#define BIO_ISSUE_THROTL_SKIP_LATENCY (1ULL << 63)
+#define BIO_ISSUE_THROTL_SKIP_LATENCY   BIT_ULL(63)
 
 struct bio_issue {
 	u64 value;
@@ -131,7 +132,7 @@ static inline sector_t bio_issue_size(struct bio_issue *issue)
 static inline void bio_issue_init(struct bio_issue *issue,
 				       sector_t size)
 {
-	size &= (1ULL << BIO_ISSUE_SIZE_BITS) - 1;
+	size &= GENMASK_ULL(BIO_ISSUE_SIZE_BITS - 1, 0);
 	issue->value = ((issue->value & BIO_ISSUE_RES_MASK) |
 			(ktime_get_ns() & BIO_ISSUE_TIME_MASK) |
 			((u64)size << BIO_ISSUE_SIZE_SHIFT));
@@ -270,7 +271,7 @@ typedef __u32 __bitwise blk_mq_req_flags_t;
  * meaning.
  */
 #define REQ_OP_BITS	8
-#define REQ_OP_MASK	((1 << REQ_OP_BITS) - 1)
+#define REQ_OP_MASK	GENMASK(REQ_OP_BITS - 1, 0)
 #define REQ_FLAG_BITS	24
 
 enum req_opf {
@@ -329,25 +330,25 @@ enum req_flag_bits {
 	__REQ_NR_BITS,		/* stops here */
 };
 
-#define REQ_FAILFAST_DEV	(1ULL << __REQ_FAILFAST_DEV)
-#define REQ_FAILFAST_TRANSPORT	(1ULL << __REQ_FAILFAST_TRANSPORT)
-#define REQ_FAILFAST_DRIVER	(1ULL << __REQ_FAILFAST_DRIVER)
-#define REQ_SYNC		(1ULL << __REQ_SYNC)
-#define REQ_META		(1ULL << __REQ_META)
-#define REQ_PRIO		(1ULL << __REQ_PRIO)
-#define REQ_NOMERGE		(1ULL << __REQ_NOMERGE)
-#define REQ_IDLE		(1ULL << __REQ_IDLE)
-#define REQ_INTEGRITY		(1ULL << __REQ_INTEGRITY)
-#define REQ_FUA			(1ULL << __REQ_FUA)
-#define REQ_PREFLUSH		(1ULL << __REQ_PREFLUSH)
-#define REQ_RAHEAD		(1ULL << __REQ_RAHEAD)
-#define REQ_BACKGROUND		(1ULL << __REQ_BACKGROUND)
-#define REQ_NOWAIT		(1ULL << __REQ_NOWAIT)
-#define REQ_NOUNMAP		(1ULL << __REQ_NOUNMAP)
-#define REQ_HIPRI		(1ULL << __REQ_HIPRI)
-
-#define REQ_DRV			(1ULL << __REQ_DRV)
-#define REQ_SWAP		(1ULL << __REQ_SWAP)
+#define REQ_FAILFAST_DEV	BIT_ULL(__REQ_FAILFAST_DEV)
+#define REQ_FAILFAST_TRANSPORT	BIT_ULL(__REQ_FAILFAST_TRANSPORT)
+#define REQ_FAILFAST_DRIVER	BIT_ULL(__REQ_FAILFAST_DRIVER)
+#define REQ_SYNC		BIT_ULL(__REQ_SYNC)
+#define REQ_META		BIT_ULL(__REQ_META)
+#define REQ_PRIO		BIT_ULL(__REQ_PRIO)
+#define REQ_NOMERGE		BIT_ULL(__REQ_NOMERGE)
+#define REQ_IDLE		BIT_ULL(__REQ_IDLE)
+#define REQ_INTEGRITY		BIT_ULL(__REQ_INTEGRITY)
+#define REQ_FUA			BIT_ULL(__REQ_FUA)
+#define REQ_PREFLUSH		BIT_ULL(__REQ_PREFLUSH)
+#define REQ_RAHEAD		BIT_ULL(__REQ_RAHEAD)
+#define REQ_BACKGROUND		BIT_ULL(__REQ_BACKGROUND)
+#define REQ_NOWAIT		BIT_ULL(__REQ_NOWAIT)
+#define REQ_NOUNMAP		BIT_ULL(__REQ_NOUNMAP)
+#define REQ_HIPRI		BIT_ULL(__REQ_HIPRI)
+
+#define REQ_DRV			BIT_ULL(__REQ_DRV)
+#define REQ_SWAP		BIT_ULL(__REQ_SWAP)
 
 #define REQ_FAILFAST_MASK \
 	(REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)
@@ -415,7 +416,7 @@ static inline int op_stat_group(unsigned int op)
 typedef unsigned int blk_qc_t;
 #define BLK_QC_T_NONE		-1U
 #define BLK_QC_T_SHIFT		16
-#define BLK_QC_T_INTERNAL	(1U << 31)
+#define BLK_QC_T_INTERNAL	BIT(31)
 
 static inline bool blk_qc_t_valid(blk_qc_t cookie)
 {
@@ -429,7 +430,7 @@ static inline unsigned int blk_qc_t_to_queue_num(blk_qc_t cookie)
 
 static inline unsigned int blk_qc_t_to_tag(blk_qc_t cookie)
 {
-	return cookie & ((1u << BLK_QC_T_SHIFT) - 1);
+	return cookie & GENMASK(BLK_QC_T_SHIFT - 1, 0);
 }
 
 static inline bool blk_qc_t_is_internal(blk_qc_t cookie)
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ