diff options
author | Bhaktipriya Shridhar <bhaktipriya96@gmail.com> | 2016-03-10 00:05:16 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-03-10 19:34:22 -0800 |
commit | 7f9d2b1ce5f01e76a26ca9dd087c87fd47cb0cfd (patch) | |
tree | 2307a5bfc2b32b552f056efe1e1d4d591373cfeb | |
parent | df6ba4f16170838482319f40ce1a2b280b9e80f3 (diff) | |
download | linux-7f9d2b1ce5f01e76a26ca9dd087c87fd47cb0cfd.tar.bz2 |
staging: comedi: drivers: ni_mio_common: Prefer using macro DIV_ROUND_UP
The macro DIV_ROUND_UP performs the computation
(((n) + (d) - 1) /(d)). It clarifies the divisor calculations.
This was done using the coccinelle script:
@@
expression e1;
expression e2;
@@
(
- ((e1) + e2 - 1) / (e2)
+ DIV_ROUND_UP(e1,e2)
|
- ((e1) + (e2 - 1)) / (e2)
+ DIV_ROUND_UP(e1,e2)
)
Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers/ni_mio_common.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 8d8535b1b6ca..d1226c97664b 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -2058,7 +2058,7 @@ static int ni_ns_to_timer(const struct comedi_device *dev, unsigned nanosec, divider = (nanosec) / devpriv->clock_ns; break; case CMDF_ROUND_UP: - divider = (nanosec + devpriv->clock_ns - 1) / devpriv->clock_ns; + divider = DIV_ROUND_UP(nanosec, devpriv->clock_ns); break; } return divider - 1; @@ -4241,8 +4241,7 @@ static int ni_m_series_pwm_config(struct comedi_device *dev, break; case CMDF_ROUND_UP: up_count = - (data[2] + devpriv->clock_ns - - 1) / devpriv->clock_ns; + DIV_ROUND_UP(data[2], devpriv->clock_ns); break; default: return -EINVAL; @@ -4257,8 +4256,7 @@ static int ni_m_series_pwm_config(struct comedi_device *dev, break; case CMDF_ROUND_UP: down_count = - (data[4] + devpriv->clock_ns - - 1) / devpriv->clock_ns; + DIV_ROUND_UP(data[4], devpriv->clock_ns); break; default: return -EINVAL; @@ -4303,8 +4301,7 @@ static int ni_6143_pwm_config(struct comedi_device *dev, break; case CMDF_ROUND_UP: up_count = - (data[2] + devpriv->clock_ns - - 1) / devpriv->clock_ns; + DIV_ROUND_UP(data[2], devpriv->clock_ns); break; default: return -EINVAL; @@ -4319,8 +4316,7 @@ static int ni_6143_pwm_config(struct comedi_device *dev, break; case CMDF_ROUND_UP: down_count = - (data[4] + devpriv->clock_ns - - 1) / devpriv->clock_ns; + DIV_ROUND_UP(data[4], devpriv->clock_ns); break; default: return -EINVAL; |