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>
This commit is contained in:
parent
df6ba4f161
commit
7f9d2b1ce5
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue