From: Martin K. Petersen Date: Fri, 26 Sep 2014 23:20:00 +0000 (-0400) Subject: block: Make protection interval calculation generic X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5a2aa873059fec8b6385071d9c0802893a9b2f41;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git block: Make protection interval calculation generic Now that the protection interval has been detached from the sector size we need to be able to handle sizes that are different from 4K and 512. Make the interval calculation generic. Signed-off-by: Martin K. Petersen Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg Signed-off-by: Jens Axboe --- diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 6a3aacf57b19..cf40837e7710 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -197,11 +197,7 @@ EXPORT_SYMBOL(bio_integrity_enabled); static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi, unsigned int sectors) { - /* At this point there are only 512b or 4096b DIF/EPP devices */ - if (bi->interval == 4096) - return sectors >>= 3; - - return sectors; + return sectors >> (ilog2(bi->interval) - 9); } static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,