Skip to content

Commit a58e00e

Browse files
Jesper JuhlLinus Torvalds
authored andcommitted
[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>
1 parent a244e16 commit a58e00e

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

‎drivers/serial/jsm/jsm_tty.c‎

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,14 @@ static void jsm_tty_send_xchar(struct uart_port *port, char ch)
142142
{
143143
unsigned long lock_flags;
144144
struct jsm_channel *channel = (struct jsm_channel *)port;
145+
struct termios *termios;
145146

146147
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])
148150
channel->ch_bd->bd_ops->send_start_character(channel);
149151

150-
if (ch == port->info->tty->termios->c_cc[VSTOP])
152+
if (ch == termios->c_cc[VSTOP])
151153
channel->ch_bd->bd_ops->send_stop_character(channel);
152154
spin_unlock_irqrestore(&port->lock, lock_flags);
153155
}
@@ -178,6 +180,7 @@ static int jsm_tty_open(struct uart_port *port)
178180
struct jsm_board *brd;
179181
int rc = 0;
180182
struct jsm_channel *channel = (struct jsm_channel *)port;
183+
struct termios *termios;
181184

182185
/* Get board pointer from our array of majors we have allocated */
183186
brd = channel->ch_bd;
@@ -239,12 +242,13 @@ static int jsm_tty_open(struct uart_port *port)
239242
channel->ch_cached_lsr = 0;
240243
channel->ch_stops_sent = 0;
241244

242-
channel->ch_c_cflag = port->info->tty->termios->c_cflag;
243-
channel->ch_c_iflag = port->info->tty->termios->c_iflag;
244-
channel->ch_c_oflag = port->info->tty->termios->c_oflag;
245-
channel->ch_c_lflag = port->info->tty->termios->c_lflag;
246-
channel->ch_startc = port->info->tty->termios->c_cc[VSTART];
247-
channel->ch_stopc = port->info->tty->termios->c_cc[VSTOP];
245+
termios = port->info->tty->termios;
246+
channel->ch_c_cflag = termios->c_cflag;
247+
channel->ch_c_iflag = termios->c_iflag;
248+
channel->ch_c_oflag = termios->c_oflag;
249+
channel->ch_c_lflag = termios->c_lflag;
250+
channel->ch_startc = termios->c_cc[VSTART];
251+
channel->ch_stopc = termios->c_cc[VSTOP];
248252

249253
/* Tell UART to init itself */
250254
brd->bd_ops->uart_init(channel);
@@ -784,6 +788,7 @@ static void jsm_carrier(struct jsm_channel *ch)
784788

785789
void jsm_check_queue_flow_control(struct jsm_channel *ch)
786790
{
791+
struct board_ops *bd_ops = ch->ch_bd->bd_ops;
787792
int qleft = 0;
788793

789794
/* Store how much space we have left in the queue */
@@ -809,7 +814,7 @@ void jsm_check_queue_flow_control(struct jsm_channel *ch)
809814
/* HWFLOW */
810815
if (ch->ch_c_cflag & CRTSCTS) {
811816
if(!(ch->ch_flags & CH_RECEIVER_OFF)) {
812-
ch->ch_bd->bd_ops->disable_receiver(ch);
817+
bd_ops->disable_receiver(ch);
813818
ch->ch_flags |= (CH_RECEIVER_OFF);
814819
jsm_printk(READ, INFO, &ch->ch_bd->pci_dev,
815820
"Internal queue hit hilevel mark (%d)! Turning off interrupts.\n",
@@ -819,7 +824,7 @@ void jsm_check_queue_flow_control(struct jsm_channel *ch)
819824
/* SWFLOW */
820825
else if (ch->ch_c_iflag & IXOFF) {
821826
if (ch->ch_stops_sent <= MAX_STOPS_SENT) {
822-
ch->ch_bd->bd_ops->send_stop_character(ch);
827+
bd_ops->send_stop_character(ch);
823828
ch->ch_stops_sent++;
824829
jsm_printk(READ, INFO, &ch->ch_bd->pci_dev,
825830
"Sending stop char! Times sent: %x\n", ch->ch_stops_sent);
@@ -846,7 +851,7 @@ void jsm_check_queue_flow_control(struct jsm_channel *ch)
846851
/* HWFLOW */
847852
if (ch->ch_c_cflag & CRTSCTS) {
848853
if (ch->ch_flags & CH_RECEIVER_OFF) {
849-
ch->ch_bd->bd_ops->enable_receiver(ch);
854+
bd_ops->enable_receiver(ch);
850855
ch->ch_flags &= ~(CH_RECEIVER_OFF);
851856
jsm_printk(READ, INFO, &ch->ch_bd->pci_dev,
852857
"Internal queue hit lowlevel mark (%d)! Turning on interrupts.\n",
@@ -856,7 +861,7 @@ void jsm_check_queue_flow_control(struct jsm_channel *ch)
856861
/* SWFLOW */
857862
else if (ch->ch_c_iflag & IXOFF && ch->ch_stops_sent) {
858863
ch->ch_stops_sent = 0;
859-
ch->ch_bd->bd_ops->send_start_character(ch);
864+
bd_ops->send_start_character(ch);
860865
jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "Sending start char!\n");
861866
}
862867
}

0 commit comments

Comments
 (0)