Improve static type checking by using the enum req_op type for variables that represent a request operation and the new blk_opf_t type for variables that represent request flags all or not combined with a request operation. Cc: Alasdair Kergon <agk@xxxxxxxxxx> Cc: Mike Snitzer <snitzer@xxxxxxxxxx> Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> --- drivers/md/dm-io.c | 18 ++++++++++-------- drivers/md/dm.c | 2 +- include/linux/dm-io.h | 5 +++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c index e4b95eaeec8c..29ff150634cd 100644 --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c @@ -293,7 +293,7 @@ static void km_dp_init(struct dpages *dp, void *data) /*----------------------------------------------------------------- * IO routines that accept a list of pages. *---------------------------------------------------------------*/ -static void do_region(int op, int op_flags, unsigned region, +static void do_region(enum req_op op, blk_opf_t op_flags, unsigned region, struct dm_io_region *where, struct dpages *dp, struct io *io) { @@ -368,9 +368,9 @@ static void do_region(int op, int op_flags, unsigned region, } while (remaining); } -static void dispatch_io(int op, int op_flags, unsigned int num_regions, - struct dm_io_region *where, struct dpages *dp, - struct io *io, int sync) +static void dispatch_io(enum req_op op, blk_opf_t op_flags, + unsigned int num_regions, struct dm_io_region *where, + struct dpages *dp, struct io *io, int sync) { int i; struct dpages old_pages = *dp; @@ -411,8 +411,9 @@ static void sync_io_complete(unsigned long error, void *context) } static int sync_io(struct dm_io_client *client, unsigned int num_regions, - struct dm_io_region *where, int op, int op_flags, - struct dpages *dp, unsigned long *error_bits) + struct dm_io_region *where, enum req_op op, + blk_opf_t op_flags, struct dpages *dp, + unsigned long *error_bits) { struct io *io; struct sync_io sio; @@ -445,8 +446,9 @@ static int sync_io(struct dm_io_client *client, unsigned int num_regions, } static int async_io(struct dm_io_client *client, unsigned int num_regions, - struct dm_io_region *where, int op, int op_flags, - struct dpages *dp, io_notify_fn fn, void *context) + struct dm_io_region *where, enum req_op op, + blk_opf_t op_flags, struct dpages *dp, io_notify_fn fn, + void *context) { struct io *io; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index bed7ad573f79..ea0bbbd6837f 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1622,7 +1622,7 @@ static blk_status_t __split_and_process_bio(struct clone_info *ci) * Only support bio polling for normal IO, and the target io is * exactly inside the dm_io instance (verified in dm_poll_dm_io) */ - ci->submit_as_polled = ci->bio->bi_opf & REQ_POLLED; + ci->submit_as_polled = !!(ci->bio->bi_opf & REQ_POLLED); len = min_t(sector_t, max_io_len(ti, ci->sector), ci->sector_count); setup_split_accounting(ci, len); diff --git a/include/linux/dm-io.h b/include/linux/dm-io.h index a52c6580cc9a..811f29ca4971 100644 --- a/include/linux/dm-io.h +++ b/include/linux/dm-io.h @@ -13,6 +13,7 @@ #ifdef __KERNEL__ #include <linux/types.h> +#include <linux/blk_types.h> struct dm_io_region { struct block_device *bdev; @@ -57,8 +58,8 @@ struct dm_io_notify { */ struct dm_io_client; struct dm_io_request { - int bi_op; /* REQ_OP */ - int bi_op_flags; /* req_flag_bits */ + enum req_op bi_op; /* REQ_OP */ + blk_opf_t bi_op_flags; /* req_flag_bits */ struct dm_io_memory mem; /* Memory to use for io */ struct dm_io_notify notify; /* Synchronous if notify.fn is NULL */ struct dm_io_client *client; /* Client memory handler */