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

tty: metag_da: avoid getting tty kref in dashtty_timer()

Getting the tty kref in dashtty_timer() is no longer necessary since it
isn't needed in fetch_data() any longer (due to changes which make the
tty flip functions refer to tty_ports instead of tty_structs), so just
pass around a channel number instead.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Acked-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

James Hogan and committed by
Greg Kroah-Hartman
a8cd9858 8200e38a

+14 -17
+14 -17
drivers/tty/metag_da.c
··· 147 147 /* 148 148 * Attempts to fetch count bytes from channel and returns actual count. 149 149 */ 150 - static int fetch_data(struct tty_struct *tty) 150 + static int fetch_data(unsigned int channel) 151 151 { 152 - unsigned int channel = tty->index; 153 152 struct dashtty_port *dport = &dashtty_ports[channel]; 154 153 int received = 0; 155 154 ··· 179 180 } 180 181 181 182 /** 182 - * find_channel_to_poll() - Returns kref to the next channel tty to poll. 183 - * Returns: The TTY of the next channel to poll, or NULL if no TTY needs 184 - * polling. Release with tty_kref_put(). 183 + * find_channel_to_poll() - Returns number of the next channel to poll. 184 + * Returns: The number of the next channel to poll, or -1 if none need 185 + * polling. 185 186 */ 186 - static struct tty_struct *find_channel_to_poll(void) 187 + static int find_channel_to_poll(void) 187 188 { 188 189 static int last_polled_channel; 189 190 int last = last_polled_channel; 190 191 int chan; 191 - struct tty_struct *tty = NULL; 192 + struct dashtty_port *dport; 192 193 193 194 for (chan = last + 1; ; ++chan) { 194 195 if (chan >= NUM_TTY_CHANNELS) 195 196 chan = 0; 196 197 197 - tty = tty_port_tty_get(&dashtty_ports[chan].port); 198 - if (tty) { 198 + dport = &dashtty_ports[chan]; 199 + if (dport->rx_buf) { 199 200 last_polled_channel = chan; 200 - return tty; 201 + return chan; 201 202 } 202 203 203 204 if (chan == last) 204 205 break; 205 206 } 206 - return tty; 207 + return -1; 207 208 } 208 209 209 210 /** ··· 301 302 */ 302 303 static void dashtty_timer(unsigned long ignored) 303 304 { 304 - struct tty_struct *tty; 305 + int channel; 305 306 306 307 /* If there are no ports open do nothing and don't poll again. */ 307 308 if (!atomic_read(&num_channels_need_poll)) 308 309 return; 309 310 310 - tty = find_channel_to_poll(); 311 + channel = find_channel_to_poll(); 311 312 312 313 /* Did we find a channel to poll? */ 313 - if (tty) { 314 - fetch_data(tty); 315 - tty_kref_put(tty); 316 - } 314 + if (channel >= 0) 315 + fetch_data(channel); 317 316 318 317 mod_timer_pinned(&poll_timer, jiffies + DA_TTY_POLL); 319 318 }