[PATCH v2 1/3] math.h: Add mult_fract() that takes struct __Txx_fract as argument

From: Andy Shevchenko

Date: Thu Nov 19 2026 - 14:24:23 EST


Add mult_fract() that takes struct __Txx_fract as argument
and calls mult_frac() underneath.

Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@xxxxxxxxx>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
include/linux/math.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/include/linux/math.h b/include/linux/math.h
index 1e8fb3efbc8c..0f584ee48753 100644
--- a/include/linux/math.h
+++ b/include/linux/math.h
@@ -128,6 +128,13 @@ __STRUCT_FRACT(u32)
q * n_ + r * n_ / d_; \
})

+/* Same as above but for a struct __Txx_fract fraction */
+#define mult_fract(x, f) \
+({ \
+ auto f_ = (f); \
+ mult_frac(x, f_->numerator, f_->denominator); \
+})
+
#define sector_div(a, b) do_div(a, b)

/**
--
2.50.1