staging: comedi: rtd520: use DIV_ROUND_CLOSEST and DIV_ROUND_UP macros
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 25 Sep 2015 00:52:11 +0000 (17:52 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Sep 2015 01:32:22 +0000 (03:32 +0200)
Use the macros to clarify the divisor calculations.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/rtd520.c

index e23a7b990513a051693d625b1f2473928cf11662..96c419374c9ddd6ad79f0d999c28518135d698cf 100644 (file)
@@ -392,13 +392,13 @@ static int rtd_ns_to_timer_base(unsigned int *nanosec,
        switch (flags & CMDF_ROUND_MASK) {
        case CMDF_ROUND_NEAREST:
        default:
-               divider = (*nanosec + base / 2) / base;
+               divider = DIV_ROUND_CLOSEST(*nanosec, base);
                break;
        case CMDF_ROUND_DOWN:
                divider = (*nanosec) / base;
                break;
        case CMDF_ROUND_UP:
-               divider = (*nanosec + base - 1) / base;
+               divider = DIV_ROUND_UP(*nanosec, base);
                break;
        }
        if (divider < 2)