aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/dgnc/dgnc_tty.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/dgnc/dgnc_tty.c')
-rw-r--r--drivers/staging/dgnc/dgnc_tty.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index a6c6aba82d72..f0b17c36edd8 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -964,8 +964,10 @@ static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate)
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
@@ -978,7 +980,7 @@ static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate)
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;
/*
@@ -995,28 +997,23 @@ static void dgnc_set_custom_speed(struct channel_t *ch, uint 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;
}
@@ -1025,7 +1022,8 @@ void dgnc_check_queue_flow_control(struct channel_t *ch)
int qleft = 0;
/* Store how much space we have left in the queue */
- if ((qleft = ch->ch_r_tail - ch->ch_r_head - 1) < 0)
+ qleft = ch->ch_r_tail - ch->ch_r_head - 1;
+ if (qleft < 0)
qleft += RQUEUEMASK + 1;
/*
@@ -1119,7 +1117,8 @@ void dgnc_wakeup_writes(struct channel_t *ch)
/*
* If channel now has space, wake up anyone waiting on the condition.
*/
- if ((qlen = ch->ch_w_head - ch->ch_w_tail) < 0)
+ qlen = ch->ch_w_head - ch->ch_w_tail;
+ if (qlen < 0)
qlen += WQUEUESIZE;
if (qlen >= (WQUEUESIZE - 256)) {
@@ -1917,7 +1916,8 @@ static int dgnc_tty_write_room(struct tty_struct *tty)
head = (ch->ch_w_head) & tmask;
tail = (ch->ch_w_tail) & tmask;
- if ((ret = tail - head - 1) < 0)
+ ret = tail - head - 1;
+ if (ret < 0)
ret += WQUEUESIZE;
/* Limit printer to maxcps */
@@ -2017,7 +2017,8 @@ static int dgnc_tty_write(struct tty_struct *tty,
head = (ch->ch_w_head) & tmask;
tail = (ch->ch_w_tail) & tmask;
- if ((bufcount = tail - head - 1) < 0)
+ bufcount = tail - head - 1;
+ if (bufcount < 0)
bufcount += WQUEUESIZE;
DPR_WRITE(("%d: bufcount: %x count: %x tail: %x head: %x tmask: %x\n",
@@ -3316,10 +3317,10 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
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);