Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] Decrease number of pointer derefs in jsm_tty.c

Decrease the number of pointer derefs in drivers/serial/jsm/jsm_tty.c

Benefits of the patch:
- Fewer pointer dereferences should make the code slightly faster.
- Size of generated code is smaller
- Improved readability

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Acked-by: "V. ANANDA KRISHNAN" <mansarov@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Jesper Juhl and committed by
Linus Torvalds
a58e00e7 a244e169

+17 -12
+17 -12
drivers/serial/jsm/jsm_tty.c
··· 142 142 { 143 143 unsigned long lock_flags; 144 144 struct jsm_channel *channel = (struct jsm_channel *)port; 145 + struct termios *termios; 145 146 146 147 spin_lock_irqsave(&port->lock, lock_flags); 147 - if (ch == port->info->tty->termios->c_cc[VSTART]) 148 + termios = port->info->tty->termios; 149 + if (ch == termios->c_cc[VSTART]) 148 150 channel->ch_bd->bd_ops->send_start_character(channel); 149 151 150 - if (ch == port->info->tty->termios->c_cc[VSTOP]) 152 + if (ch == termios->c_cc[VSTOP]) 151 153 channel->ch_bd->bd_ops->send_stop_character(channel); 152 154 spin_unlock_irqrestore(&port->lock, lock_flags); 153 155 } ··· 180 178 struct jsm_board *brd; 181 179 int rc = 0; 182 180 struct jsm_channel *channel = (struct jsm_channel *)port; 181 + struct termios *termios; 183 182 184 183 /* Get board pointer from our array of majors we have allocated */ 185 184 brd = channel->ch_bd; ··· 242 239 channel->ch_cached_lsr = 0; 243 240 channel->ch_stops_sent = 0; 244 241 245 - channel->ch_c_cflag = port->info->tty->termios->c_cflag; 246 - channel->ch_c_iflag = port->info->tty->termios->c_iflag; 247 - channel->ch_c_oflag = port->info->tty->termios->c_oflag; 248 - channel->ch_c_lflag = port->info->tty->termios->c_lflag; 249 - channel->ch_startc = port->info->tty->termios->c_cc[VSTART]; 250 - channel->ch_stopc = port->info->tty->termios->c_cc[VSTOP]; 242 + termios = port->info->tty->termios; 243 + channel->ch_c_cflag = termios->c_cflag; 244 + channel->ch_c_iflag = termios->c_iflag; 245 + channel->ch_c_oflag = termios->c_oflag; 246 + channel->ch_c_lflag = termios->c_lflag; 247 + channel->ch_startc = termios->c_cc[VSTART]; 248 + channel->ch_stopc = termios->c_cc[VSTOP]; 251 249 252 250 /* Tell UART to init itself */ 253 251 brd->bd_ops->uart_init(channel); ··· 788 784 789 785 void jsm_check_queue_flow_control(struct jsm_channel *ch) 790 786 { 787 + struct board_ops *bd_ops = ch->ch_bd->bd_ops; 791 788 int qleft = 0; 792 789 793 790 /* Store how much space we have left in the queue */ ··· 814 809 /* HWFLOW */ 815 810 if (ch->ch_c_cflag & CRTSCTS) { 816 811 if(!(ch->ch_flags & CH_RECEIVER_OFF)) { 817 - ch->ch_bd->bd_ops->disable_receiver(ch); 812 + bd_ops->disable_receiver(ch); 818 813 ch->ch_flags |= (CH_RECEIVER_OFF); 819 814 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, 820 815 "Internal queue hit hilevel mark (%d)! Turning off interrupts.\n", ··· 824 819 /* SWFLOW */ 825 820 else if (ch->ch_c_iflag & IXOFF) { 826 821 if (ch->ch_stops_sent <= MAX_STOPS_SENT) { 827 - ch->ch_bd->bd_ops->send_stop_character(ch); 822 + bd_ops->send_stop_character(ch); 828 823 ch->ch_stops_sent++; 829 824 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, 830 825 "Sending stop char! Times sent: %x\n", ch->ch_stops_sent); ··· 851 846 /* HWFLOW */ 852 847 if (ch->ch_c_cflag & CRTSCTS) { 853 848 if (ch->ch_flags & CH_RECEIVER_OFF) { 854 - ch->ch_bd->bd_ops->enable_receiver(ch); 849 + bd_ops->enable_receiver(ch); 855 850 ch->ch_flags &= ~(CH_RECEIVER_OFF); 856 851 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, 857 852 "Internal queue hit lowlevel mark (%d)! Turning on interrupts.\n", ··· 861 856 /* SWFLOW */ 862 857 else if (ch->ch_c_iflag & IXOFF && ch->ch_stops_sent) { 863 858 ch->ch_stops_sent = 0; 864 - ch->ch_bd->bd_ops->send_start_character(ch); 859 + bd_ops->send_start_character(ch); 865 860 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "Sending start char!\n"); 866 861 } 867 862 }