helpers: Add an integer division helper that rounds up
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This commit is contained in:
parent
617bb9afc9
commit
b3d94c9843
|
@ -95,6 +95,16 @@ do { \
|
|||
#define CLIP(c, x, y) MIN(MAX(c, x), y)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Divides two integers, rounding up.
|
||||
*
|
||||
* @param n the numerator to divide.
|
||||
* @param d the denominator to divide by.
|
||||
* @return the rounded up result of the division n / d.
|
||||
*/
|
||||
#define DIV_ROUND_UP(n, d) \
|
||||
({ typeof(d) tmp = (d); ((n) + tmp - 1) / tmp; })
|
||||
|
||||
/**
|
||||
* Returns a pointer to the containing struct of a given member item.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue