TTY: isdn, make some functions readable
Huh, this was a mess. * Remove the 5 indent levels by just returning from isdn_tty_try_read when the conditions there are not satisfied. * Use 'continue' in loop in isdn_tty_readmodem to save 2 levels. * Chain 'if's in isdn_tty_modem_escape. * Use 'continue' in loop in isdn_tty_carrier_timeout to save 1 level. Better to look at this patch with -w -b. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Karsten Keil <isdn@linux-pingi.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ce93d33cf4
commit
37630f4063
@ -65,49 +65,54 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb)
|
|||||||
struct tty_struct *tty;
|
struct tty_struct *tty;
|
||||||
char last;
|
char last;
|
||||||
|
|
||||||
if (info->online) {
|
if (!info->online)
|
||||||
if ((tty = info->tty)) {
|
return 0;
|
||||||
if (info->mcr & UART_MCR_RTS) {
|
|
||||||
len = skb->len
|
|
||||||
#ifdef CONFIG_ISDN_AUDIO
|
|
||||||
+ ISDN_AUDIO_SKB_DLECOUNT(skb)
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
c = tty_buffer_request_room(tty, len);
|
tty = info->tty;
|
||||||
if (c >= len) {
|
if (!tty)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!(info->mcr & UART_MCR_RTS))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
len = skb->len
|
||||||
#ifdef CONFIG_ISDN_AUDIO
|
#ifdef CONFIG_ISDN_AUDIO
|
||||||
if (ISDN_AUDIO_SKB_DLECOUNT(skb)) {
|
+ ISDN_AUDIO_SKB_DLECOUNT(skb)
|
||||||
int l = skb->len;
|
|
||||||
unsigned char *dp = skb->data;
|
|
||||||
while (--l) {
|
|
||||||
if (*dp == DLE)
|
|
||||||
tty_insert_flip_char(tty, DLE, 0);
|
|
||||||
tty_insert_flip_char(tty, *dp++, 0);
|
|
||||||
}
|
|
||||||
if (*dp == DLE)
|
|
||||||
tty_insert_flip_char(tty, DLE, 0);
|
|
||||||
last = *dp;
|
|
||||||
} else {
|
|
||||||
#endif
|
#endif
|
||||||
if (len > 1)
|
;
|
||||||
tty_insert_flip_string(tty, skb->data, len - 1);
|
|
||||||
last = skb->data[len - 1];
|
c = tty_buffer_request_room(tty, len);
|
||||||
|
if (c < len)
|
||||||
|
return 0;
|
||||||
|
|
||||||
#ifdef CONFIG_ISDN_AUDIO
|
#ifdef CONFIG_ISDN_AUDIO
|
||||||
}
|
if (ISDN_AUDIO_SKB_DLECOUNT(skb)) {
|
||||||
#endif
|
int l = skb->len;
|
||||||
if (info->emu.mdmreg[REG_CPPP] & BIT_CPPP)
|
unsigned char *dp = skb->data;
|
||||||
tty_insert_flip_char(tty, last, 0xFF);
|
while (--l) {
|
||||||
else
|
if (*dp == DLE)
|
||||||
tty_insert_flip_char(tty, last, TTY_NORMAL);
|
tty_insert_flip_char(tty, DLE, 0);
|
||||||
tty_flip_buffer_push(tty);
|
tty_insert_flip_char(tty, *dp++, 0);
|
||||||
kfree_skb(skb);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (*dp == DLE)
|
||||||
|
tty_insert_flip_char(tty, DLE, 0);
|
||||||
|
last = *dp;
|
||||||
|
} else {
|
||||||
|
#endif
|
||||||
|
if (len > 1)
|
||||||
|
tty_insert_flip_string(tty, skb->data, len - 1);
|
||||||
|
last = skb->data[len - 1];
|
||||||
|
#ifdef CONFIG_ISDN_AUDIO
|
||||||
}
|
}
|
||||||
return 0;
|
#endif
|
||||||
|
if (info->emu.mdmreg[REG_CPPP] & BIT_CPPP)
|
||||||
|
tty_insert_flip_char(tty, last, 0xFF);
|
||||||
|
else
|
||||||
|
tty_insert_flip_char(tty, last, TTY_NORMAL);
|
||||||
|
tty_flip_buffer_push(tty);
|
||||||
|
kfree_skb(skb);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* isdn_tty_readmodem() is called periodically from within timer-interrupt.
|
/* isdn_tty_readmodem() is called periodically from within timer-interrupt.
|
||||||
@ -125,35 +130,39 @@ isdn_tty_readmodem(void)
|
|||||||
modem_info *info;
|
modem_info *info;
|
||||||
|
|
||||||
for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
|
for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
|
||||||
if ((midx = dev->m_idx[i]) >= 0) {
|
midx = dev->m_idx[i];
|
||||||
info = &dev->mdm.info[midx];
|
if (midx < 0)
|
||||||
if (info->online) {
|
continue;
|
||||||
r = 0;
|
|
||||||
|
info = &dev->mdm.info[midx];
|
||||||
|
if (!info->online)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
r = 0;
|
||||||
#ifdef CONFIG_ISDN_AUDIO
|
#ifdef CONFIG_ISDN_AUDIO
|
||||||
isdn_audio_eval_dtmf(info);
|
isdn_audio_eval_dtmf(info);
|
||||||
if ((info->vonline & 1) && (info->emu.vpar[1]))
|
if ((info->vonline & 1) && (info->emu.vpar[1]))
|
||||||
isdn_audio_eval_silence(info);
|
isdn_audio_eval_silence(info);
|
||||||
#endif
|
#endif
|
||||||
if ((tty = info->tty)) {
|
tty = info->tty;
|
||||||
if (info->mcr & UART_MCR_RTS) {
|
if (tty) {
|
||||||
/* CISCO AsyncPPP Hack */
|
if (info->mcr & UART_MCR_RTS) {
|
||||||
if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP))
|
/* CISCO AsyncPPP Hack */
|
||||||
r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 0);
|
if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP))
|
||||||
else
|
r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 0);
|
||||||
r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 1);
|
else
|
||||||
if (r)
|
r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 1);
|
||||||
tty_flip_buffer_push(tty);
|
if (r)
|
||||||
} else
|
tty_flip_buffer_push(tty);
|
||||||
r = 1;
|
} else
|
||||||
} else
|
r = 1;
|
||||||
r = 1;
|
} else
|
||||||
if (r) {
|
r = 1;
|
||||||
info->rcvsched = 0;
|
if (r) {
|
||||||
resched = 1;
|
info->rcvsched = 0;
|
||||||
} else
|
resched = 1;
|
||||||
info->rcvsched = 1;
|
} else
|
||||||
}
|
info->rcvsched = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!resched)
|
if (!resched)
|
||||||
isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 0);
|
isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 0);
|
||||||
@ -3769,19 +3778,19 @@ isdn_tty_modem_escape(void)
|
|||||||
int midx;
|
int midx;
|
||||||
|
|
||||||
for (i = 0; i < ISDN_MAX_CHANNELS; i++)
|
for (i = 0; i < ISDN_MAX_CHANNELS; i++)
|
||||||
if (USG_MODEM(dev->usage[i]))
|
if (USG_MODEM(dev->usage[i]) && (midx = dev->m_idx[i]) >= 0) {
|
||||||
if ((midx = dev->m_idx[i]) >= 0) {
|
modem_info *info = &dev->mdm.info[midx];
|
||||||
modem_info *info = &dev->mdm.info[midx];
|
if (info->online) {
|
||||||
if (info->online) {
|
ton = 1;
|
||||||
ton = 1;
|
if ((info->emu.pluscount == 3) &&
|
||||||
if ((info->emu.pluscount == 3) &&
|
time_after(jiffies,
|
||||||
time_after(jiffies , info->emu.lastplus + PLUSWAIT2)) {
|
info->emu.lastplus + PLUSWAIT2)) {
|
||||||
info->emu.pluscount = 0;
|
info->emu.pluscount = 0;
|
||||||
info->online = 0;
|
info->online = 0;
|
||||||
isdn_tty_modem_result(RESULT_OK, info);
|
isdn_tty_modem_result(RESULT_OK, info);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
isdn_timer_ctrl(ISDN_TIMER_MODEMPLUS, ton);
|
isdn_timer_ctrl(ISDN_TIMER_MODEMPLUS, ton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3839,15 +3848,14 @@ isdn_tty_carrier_timeout(void)
|
|||||||
|
|
||||||
for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
|
for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
|
||||||
modem_info *info = &dev->mdm.info[i];
|
modem_info *info = &dev->mdm.info[i];
|
||||||
if (info->dialing) {
|
if (!info->dialing)
|
||||||
if (info->emu.carrierwait++ > info->emu.mdmreg[REG_WAITC]) {
|
continue;
|
||||||
info->dialing = 0;
|
if (info->emu.carrierwait++ > info->emu.mdmreg[REG_WAITC]) {
|
||||||
isdn_tty_modem_result(RESULT_NO_CARRIER, info);
|
info->dialing = 0;
|
||||||
isdn_tty_modem_hup(info, 1);
|
isdn_tty_modem_result(RESULT_NO_CARRIER, info);
|
||||||
}
|
isdn_tty_modem_hup(info, 1);
|
||||||
else
|
} else
|
||||||
ton = 1;
|
ton = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
isdn_timer_ctrl(ISDN_TIMER_CARRIER, ton);
|
isdn_timer_ctrl(ISDN_TIMER_CARRIER, ton);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user