Skip to contentSkip to conversation

linux/kernel.h: move DIV_ROUND_DOWN_ULL() macro

PATCH New [email protected] 1 participant 1 message Sep 8, 2017

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 52/126 linux/kernel.h: move DIV_ROUND_DOWN_ULL() macro

From: Masahiro Yamada <[email protected]>
Subject: linux/kernel.h: move DIV_ROUND_DOWN_ULL() macro

This macro is useful to avoid link error on 32-bit systems.

We have the same definition in two drivers, so move it to include/linux/kernel.h

While we are here, refactor DIV_ROUND_UP_ULL() by using DIV_ROUND_DOWN_ULL().

Cc Cyrille Pitchen <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Boris Brezillon <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Brian Norris <[email protected]>
Cc Richard Weinberger <[email protected]>
Cc David Woodhouse <[email protected]>

---

 drivers/mtd/nand/denali.c  |    3 ---
 include/linux/kernel.h     |    7 +++++--
 sound/soc/codecs/pcm512x.c |    3 ---
 3 files changed, 5 insertions(+), 8 deletions(-)
drivers/mtd/nand/denali.c renamed from drivers/mtd/nand/denali.c~linux-kernelh-move-div_round_down_ull-macro +0 -3
diff -puN drivers/mtd/nand/denali.c~linux-kernelh-move-div_round_down_ull-macro drivers/mtd/nand/denali.c
@@ -980,9 +980,6 @@ static int denali_erase(struct mtd_info
 	return irq_status & INTR__ERASE_COMP ? 0 : NAND_STATUS_FAIL;
 }
 
-#define DIV_ROUND_DOWN_ULL(ll, d) \
-	({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; })
-
 static int denali_setup_data_interface(struct mtd_info *mtd, int chipnr,
 				       const struct nand_data_interface *conf)
 {
include/linux/kernel.h renamed from include/linux/kernel.h~linux-kernelh-move-div_round_down_ull-macro +5 -2
diff -puN include/linux/kernel.h~linux-kernelh-move-div_round_down_ull-macro include/linux/kernel.h
@@ -78,8 +78,11 @@
 
 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
 #define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP
-#define DIV_ROUND_UP_ULL(ll,d) \
-	({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; })
+
+#define DIV_ROUND_DOWN_ULL(ll, d) \
+	({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; })
+
+#define DIV_ROUND_UP_ULL(ll, d)		DIV_ROUND_DOWN_ULL((ll) + (d) - 1, (d))
 
 #if BITS_PER_LONG == 32
 # define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP_ULL(ll, d)
sound/soc/codecs/pcm512x.c renamed from sound/soc/codecs/pcm512x.c~linux-kernelh-move-div_round_down_ull-macro +0 -2
diff -puN sound/soc/codecs/pcm512x.c~linux-kernelh-move-div_round_down_ull-macro sound/soc/codecs/pcm512x.c
@@ -30,9 +30,6 @@
 
 #include "pcm512x.h"
 
-#define DIV_ROUND_DOWN_ULL(ll, d) \
-	({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; })