int deltahigh;
int deltalow;
- if (newrate < 0)
- newrate = 0;
+ if (newrate <= 0) {
+ ch->ch_custom_speed = 0;
+ return;
+ }
/*
* Since the divisor is stored in a 16-bit integer, we make sure
if (newrate && newrate > ch->ch_bd->bd_dividend)
newrate = ch->ch_bd->bd_dividend;
- while (newrate > 0) {
+ if (newrate > 0) {
testdiv = ch->ch_bd->bd_dividend / newrate;
/*
* If the rate for the requested divisor is correct, just
* use it and be done.
*/
- if (testrate_high == newrate )
- break;
-
- /*
- * Otherwise, pick the rate that is closer (i.e. whichever rate
- * has a smaller delta).
- */
- deltahigh = testrate_high - newrate;
- deltalow = newrate - testrate_low;
+ if (testrate_high != newrate) {
+ /*
+ * Otherwise, pick the rate that is closer (i.e. whichever rate
+ * has a smaller delta).
+ */
+ deltahigh = testrate_high - newrate;
+ deltalow = newrate - testrate_low;
- if (deltahigh < deltalow) {
- newrate = testrate_high;
- } else {
- newrate = testrate_low;
+ if (deltahigh < deltalow) {
+ newrate = testrate_high;
+ } else {
+ newrate = testrate_low;
+ }
}
-
- break;
}
ch->ch_custom_speed = newrate;
-
- return;
}
case DIGI_SETCUSTOMBAUD:
{
- uint new_rate;
+ int new_rate;
/* Let go of locks when accessing user space, could sleep */
DGNC_UNLOCK(ch->ch_lock, lock_flags);
- rc = get_user(new_rate, (unsigned int __user *) arg);
+ rc = get_user(new_rate, (int __user *) arg);
if (rc)
return rc;
DGNC_LOCK(ch->ch_lock, lock_flags);