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

TTY: HVC, use tty from tty_port

The driver already used refcounting. So we just switch it to tty_port
helpers. And switch to tty_port->lock for tty.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
85bbc003 f3d9f250

+16 -23
+15 -21
drivers/tty/hvc/hvc_console.c
··· 323 323 } /* else count == 0 */ 324 324 325 325 tty->driver_data = hp; 326 - 327 - hp->tty = tty_kref_get(tty); 328 - 329 326 spin_unlock_irqrestore(&hp->lock, flags); 327 + 328 + tty_port_tty_set(&hp->port, tty); 330 329 331 330 if (hp->ops->notifier_add) 332 331 rc = hp->ops->notifier_add(hp, hp->data); ··· 337 338 * tty fields and return the kref reference. 338 339 */ 339 340 if (rc) { 340 - spin_lock_irqsave(&hp->lock, flags); 341 - hp->tty = NULL; 342 - spin_unlock_irqrestore(&hp->lock, flags); 341 + tty_port_tty_set(&hp->port, NULL); 343 342 tty_kref_put(tty); 344 343 tty->driver_data = NULL; 345 344 tty_port_put(&hp->port); ··· 370 373 spin_lock_irqsave(&hp->lock, flags); 371 374 372 375 if (--hp->count == 0) { 373 - /* We are done with the tty pointer now. */ 374 - hp->tty = NULL; 375 376 spin_unlock_irqrestore(&hp->lock, flags); 377 + /* We are done with the tty pointer now. */ 378 + tty_port_tty_set(&hp->port, NULL); 376 379 377 380 if (hp->ops->notifier_del) 378 381 hp->ops->notifier_del(hp, hp->data); ··· 424 427 temp_open_count = hp->count; 425 428 hp->count = 0; 426 429 hp->n_outbuf = 0; 427 - hp->tty = NULL; 428 - 429 430 spin_unlock_irqrestore(&hp->lock, flags); 431 + tty_port_tty_set(&hp->port, NULL); 430 432 431 433 if (hp->ops->notifier_hangup) 432 434 hp->ops->notifier_hangup(hp, hp->data); ··· 522 526 523 527 hp = container_of(work, struct hvc_struct, tty_resize); 524 528 525 - spin_lock_irqsave(&hp->lock, hvc_flags); 526 - if (!hp->tty) { 527 - spin_unlock_irqrestore(&hp->lock, hvc_flags); 529 + tty = tty_port_tty_get(&hp->port); 530 + if (!tty) 528 531 return; 529 - } 530 - ws = hp->ws; 531 - tty = tty_kref_get(hp->tty); 532 + 533 + spin_lock_irqsave(&hp->lock, hvc_flags); 534 + ws = hp->ws; 532 535 spin_unlock_irqrestore(&hp->lock, hvc_flags); 533 536 534 537 tty_do_resize(tty, &ws); ··· 596 601 } 597 602 598 603 /* No tty attached, just skip */ 599 - tty = tty_kref_get(hp->tty); 604 + tty = tty_port_tty_get(&hp->port); 600 605 if (tty == NULL) 601 606 goto bail; 602 607 ··· 676 681 677 682 tty_flip_buffer_push(tty); 678 683 } 679 - if (tty) 680 - tty_kref_put(tty); 684 + tty_kref_put(tty); 681 685 682 686 return poll_mask; 683 687 } ··· 874 880 unsigned long flags; 875 881 struct tty_struct *tty; 876 882 877 - spin_lock_irqsave(&hp->lock, flags); 878 - tty = tty_kref_get(hp->tty); 883 + tty = tty_port_tty_get(&hp->port); 879 884 885 + spin_lock_irqsave(&hp->lock, flags); 880 886 if (hp->index < MAX_NR_HVC_CONSOLES) 881 887 vtermnos[hp->index] = -1; 882 888
-1
drivers/tty/hvc/hvc_console.h
··· 49 49 struct tty_port port; 50 50 spinlock_t lock; 51 51 int index; 52 - struct tty_struct *tty; 53 52 int count; 54 53 int do_wakeup; 55 54 char *outbuf;
+1 -1
drivers/tty/hvc/hvsi_lib.c
··· 377 377 pr_devel("HVSI@%x: open !\n", pv->termno); 378 378 379 379 /* Keep track of the tty data structure */ 380 - pv->tty = tty_kref_get(hp->tty); 380 + pv->tty = tty_port_tty_get(&hp->port); 381 381 382 382 hvsilib_establish(pv); 383 383