Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37630f40 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman
Browse files

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: default avatarJiri Slaby <jslaby@suse.cz>
Cc: Karsten Keil <isdn@linux-pingi.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ce93d33c
Loading
Loading
Loading
Loading
+93 −85
Original line number Diff line number Diff line
@@ -65,9 +65,16 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb)
	struct tty_struct *tty;
	char last;

	if (info->online) {
		if ((tty = info->tty)) {
			if (info->mcr & UART_MCR_RTS) {
	if (!info->online)
		return 0;

	tty = info->tty;
	if (!tty)
		return 0;

	if (!(info->mcr & UART_MCR_RTS))
		return 0;

	len = skb->len
#ifdef CONFIG_ISDN_AUDIO
		+ ISDN_AUDIO_SKB_DLECOUNT(skb)
@@ -75,7 +82,9 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb)
		;

	c = tty_buffer_request_room(tty, len);
				if (c >= len) {
	if (c < len)
		return 0;

#ifdef CONFIG_ISDN_AUDIO
	if (ISDN_AUDIO_SKB_DLECOUNT(skb)) {
		int l = skb->len;
@@ -102,13 +111,9 @@ isdn_tty_try_read(modem_info *info, struct sk_buff *skb)
		tty_insert_flip_char(tty, last, TTY_NORMAL);
	tty_flip_buffer_push(tty);
	kfree_skb(skb);

	return 1;
}
			}
		}
	}
	return 0;
}

/* isdn_tty_readmodem() is called periodically from within timer-interrupt.
 * It tries getting received data from the receive queue an stuff it into
@@ -125,16 +130,22 @@ isdn_tty_readmodem(void)
	modem_info *info;

	for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
		if ((midx = dev->m_idx[i]) >= 0) {
		midx = dev->m_idx[i];
		if (midx < 0)
			continue;

		info = &dev->mdm.info[midx];
			if (info->online) {
		if (!info->online)
			continue;

		r = 0;
#ifdef CONFIG_ISDN_AUDIO
		isdn_audio_eval_dtmf(info);
		if ((info->vonline & 1) && (info->emu.vpar[1]))
			isdn_audio_eval_silence(info);
#endif
				if ((tty = info->tty)) {
		tty = info->tty;
		if (tty) {
			if (info->mcr & UART_MCR_RTS) {
				/* CISCO AsyncPPP Hack */
				if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP))
@@ -153,8 +164,6 @@ isdn_tty_readmodem(void)
		} else
			info->rcvsched = 1;
	}
		}
	}
	if (!resched)
		isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 0);
}
@@ -3769,13 +3778,13 @@ isdn_tty_modem_escape(void)
	int midx;

	for (i = 0; i < ISDN_MAX_CHANNELS; i++)
		if (USG_MODEM(dev->usage[i]))
			if ((midx = dev->m_idx[i]) >= 0) {
		if (USG_MODEM(dev->usage[i]) && (midx = dev->m_idx[i]) >= 0) {
			modem_info *info = &dev->mdm.info[midx];
			if (info->online) {
				ton = 1;
				if ((info->emu.pluscount == 3) &&
					    time_after(jiffies , info->emu.lastplus + PLUSWAIT2)) {
				    time_after(jiffies,
					    info->emu.lastplus + PLUSWAIT2)) {
					info->emu.pluscount = 0;
					info->online = 0;
					isdn_tty_modem_result(RESULT_OK, info);
@@ -3839,15 +3848,14 @@ isdn_tty_carrier_timeout(void)

	for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
		modem_info *info = &dev->mdm.info[i];
		if (info->dialing) {
		if (!info->dialing)
			continue;
		if (info->emu.carrierwait++ > info->emu.mdmreg[REG_WAITC]) {
			info->dialing = 0;
			isdn_tty_modem_result(RESULT_NO_CARRIER, info);
			isdn_tty_modem_hup(info, 1);
			}
			else
		} else
			ton = 1;
	}
	}
	isdn_timer_ctrl(ISDN_TIMER_CARRIER, ton);
}