[PATCH] font: fbconsole: use DIV_ROUND_UP for clarity

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Sep 11 01:17:11 PDT 2024


Adding X - 1 and then dividing by X is effectively rounding up, so let's
use the macro to make this clearer.

No functional change.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 lib/fonts/fonts.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c
index e08b75fbccc0..b3bdaa21a2aa 100644
--- a/lib/fonts/fonts.c
+++ b/lib/fonts/fonts.c
@@ -35,8 +35,7 @@ int find_font_index(const struct font_desc *font, int ch)
 {
 	int index;
 	if (font->index == NULL) {
-		index  = font->width + 7;
-		index /= 8;
+		index  = DIV_ROUND_UP(font->width, 8);
 		index *= font->height;
 		index *= ch;
 	} else {
-- 
2.39.2




More information about the barebox mailing list