]> git.karo-electronics.de Git - karo-tx-linux.git/commit
block: do not call sector_div() with a 64-bit divisor
authorGeert Uytterhoeven <geert@linux-m68k.org>
Tue, 5 Nov 2013 05:55:20 +0000 (16:55 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 5 Nov 2013 05:55:20 +0000 (16:55 +1100)
commite9f5c1d76be5cec29c32b145ac65b27c7e010f7b
treee5c55e0e7ad67726d37965446e07d6ecbc5c13c1
parent690d18bd10c6e96475bfad4243928146f145e71f
block: do not call sector_div() with a 64-bit divisor

do_div() (called by sector_div() if CONFIG_LBDAF=y) is meant for divisions
of 64-bit number by 32-bit numbers.  Passing 64-bit divisor types caused
issues in the past on 32-bit platforms, cfr.  commit ea077b1b96e073ea
("m68k: Truncate base in do_div()").

As queue_limits.max_discard_sectors and .discard_granularity are unsigned
int, max_discard_sectors and granularity should be unsigned int.  As
bdev_discard_alignment() returns int, alignment should be int.  Now 2
calls to sector_div() can be replaced by 32-bit arithmetic:

  - The 64-bit modulo operation can become a 32-bit modulo operation,
  - The 64-bit division and multiplication can be replaced by a 32-bit
    modulo operation and a subtraction.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
block/blk-lib.c