mtd: rawnand: Fix return type of __DIVIDE() when called with 32-bit
authorGeert Uytterhoeven <geert@linux-m68k.org>
Mon, 14 May 2018 10:49:37 +0000 (12:49 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Jun 2018 19:01:45 +0000 (04:01 +0900)
commit4c04217c2661d1a7c3eee38df2851ad0d61d6c71
tree3faa3d392d2351b4b7ff51e69e446d77b9523371
parentf882b432dd4da459473002dede4632ce24a28999
mtd: rawnand: Fix return type of __DIVIDE() when called with 32-bit

[ Upstream commit 9f825e74d761c13b0cfaa5f65344d64ff970e252 ]

The __DIVIDE() macro checks whether it is called with a 32-bit or 64-bit
dividend, to select the appropriate divide-and-round-up routine.
As the check uses the ternary operator, the result will always be
promoted to a type that can hold both results, i.e. unsigned long long.

When using this result in a division on a 32-bit system, this may lead
to link errors like:

    ERROR: "__udivdi3" [drivers/mtd/nand/raw/nand.ko] undefined!

Fix this by casting the result of the division to the type of the
dividend.

Fixes: 8878b126df769831 ("mtd: nand: add ->exec_op() implementation")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/mtd/rawnand.h