2020-10-20 01:31:35

by Hui Su

[permalink] [raw]
Subject: [PATCH] blk: use REQ_OP_WRITE instead of hard code

use REQ_OP_WRITE instead of hard code in
op_is_write().

Signed-off-by: Hui Su <[email protected]>
---
include/linux/blk_types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 7d7c13238fdb..7b9b02378c24 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -440,7 +440,7 @@ static inline void bio_set_op_attrs(struct bio *bio, unsigned op,

static inline bool op_is_write(unsigned int op)
{
- return (op & 1);
+ return (op & REQ_OP_WRITE);
}

/*
--
2.25.1



2020-10-20 03:19:47

by Johannes Thumshirn

[permalink] [raw]
Subject: Re: [PATCH] blk: use REQ_OP_WRITE instead of hard code

On 19/10/2020 16:30, ?ջ? wrote:
> Yeah, you are right, thanks for your explanation<br/><br/>Maybe we should define a MASK to do this?

Why? I personally find a '& 1' way more understandable than a
REQ_OP_IS_WRITE_MASK or sth like that. The former I can just read,
for the latter I would need to look up the definition to be able to
understand the code.