From: Jens Axboe Date: Fri, 8 Aug 2008 09:17:12 +0000 (+0200) Subject: block: add bio_has_data() to detect whether a bio carries data or not X-Git-Tag: v2.6.28-rc1~733^2~130 X-Git-Url: http://www.pilppa.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=7a67f63b3233ff28e753854fe27891c44f8588ae;p=linux-2.6-omap-h63xx.git block: add bio_has_data() to detect whether a bio carries data or not Signed-off-by: Jens Axboe --- diff --git a/include/linux/bio.h b/include/linux/bio.h index 0933a14e641..9e93c929947 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -445,6 +445,14 @@ static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx, __bio_kmap_irq((bio), (bio)->bi_idx, (flags)) #define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags) +/* + * Check whether this bio carries any data or not. A NULL bio is allowed. + */ +static inline int bio_has_data(struct bio *bio) +{ + return bio && bio->bi_io_vec != NULL; +} + #if defined(CONFIG_BLK_DEV_INTEGRITY) #define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)]))