From db298e1946c074c83d97f1c959fbc0def2af2c86 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 7 Oct 2011 14:23:00 +1100 Subject: md/raid5: convert to macros into inline functions. More type-safety. Easier to read. Signed-off-by: NeilBrown --- drivers/md/raid5.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'drivers/md') diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 6ab3434..01163c8 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -70,7 +70,11 @@ #define NR_HASH (PAGE_SIZE / sizeof(struct hlist_head)) #define HASH_MASK (NR_HASH - 1) -#define stripe_hash(conf, sect) (&((conf)->stripe_hashtbl[((sect) >> STRIPE_SHIFT) & HASH_MASK])) +static inline struct hlist_head *stripe_hash(raid5_conf_t *conf, sector_t sect) +{ + int hash = (sect >> STRIPE_SHIFT) & HASH_MASK; + return &conf->stripe_hashtbl[hash]; +} /* bio's attached to a stripe+device for I/O are linked together in bi_sector * order without overlap. There may be several bio's per stripe+device, and @@ -78,10 +82,17 @@ * When walking this list for a particular stripe+device, we must never proceed * beyond a bio that extends past this device, as the next bio might no longer * be valid. - * This macro is used to determine the 'next' bio in the list, given the sector + * This function is used to determine the 'next' bio in the list, given the sector * of the current stripe+device */ -#define r5_next_bio(bio, sect) ( ( (bio)->bi_sector + ((bio)->bi_size>>9) < sect + STRIPE_SECTORS) ? (bio)->bi_next : NULL) +static inline struct bio *r5_next_bio(struct bio *bio, sector_t sector) +{ + int sectors = bio->bi_size >> 9; + if (bio->bi_sector + sectors < sector + STRIPE_SECTORS) + return bio->bi_next; + else + return NULL; +} /* * The following can be used to debug the driver */ -- cgit v1.1