aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/hvc/hvc_console.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-04-02 07:54:22 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-09 14:28:18 -0400
commit85bbc003b24335e253a392f6a9874103b77abb36 (patch)
tree49eb57fe74d81dc1107879c754865a7a91d4490b /drivers/tty/hvc/hvc_console.c
parentf3d9f25097b62eaeb9e5b71358b863c7bf54c600 (diff)
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>
Diffstat (limited to 'drivers/tty/hvc/hvc_console.c')
-rw-r--r--drivers/tty/hvc/hvc_console.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 12a42730d3c8..92b7f5d5441f 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -323,11 +323,10 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
323 } /* else count == 0 */ 323 } /* else count == 0 */
324 324
325 tty->driver_data = hp; 325 tty->driver_data = hp;
326
327 hp->tty = tty_kref_get(tty);
328
329 spin_unlock_irqrestore(&hp->lock, flags); 326 spin_unlock_irqrestore(&hp->lock, flags);
330 327
328 tty_port_tty_set(&hp->port, tty);
329
331 if (hp->ops->notifier_add) 330 if (hp->ops->notifier_add)
332 rc = hp->ops->notifier_add(hp, hp->data); 331 rc = hp->ops->notifier_add(hp, hp->data);
333 332
@@ -338,9 +337,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
338 * tty fields and return the kref reference. 337 * tty fields and return the kref reference.
339 */ 338 */
340 if (rc) { 339 if (rc) {
341 spin_lock_irqsave(&hp->lock, flags); 340 tty_port_tty_set(&hp->port, NULL);
342 hp->tty = NULL;
343 spin_unlock_irqrestore(&hp->lock, flags);
344 tty_kref_put(tty); 341 tty_kref_put(tty);
345 tty->driver_data = NULL; 342 tty->driver_data = NULL;
346 tty_port_put(&hp->port); 343 tty_port_put(&hp->port);
@@ -373,9 +370,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
373 spin_lock_irqsave(&hp->lock, flags); 370 spin_lock_irqsave(&hp->lock, flags);
374 371
375 if (--hp->count == 0) { 372 if (--hp->count == 0) {
376 /* We are done with the tty pointer now. */
377 hp->tty = NULL;
378 spin_unlock_irqrestore(&hp->lock, flags); 373 spin_unlock_irqrestore(&hp->lock, flags);
374 /* We are done with the tty pointer now. */
375 tty_port_tty_set(&hp->port, NULL);
379 376
380 if (hp->ops->notifier_del) 377 if (hp->ops->notifier_del)
381 hp->ops->notifier_del(hp, hp->data); 378 hp->ops->notifier_del(hp, hp->data);
@@ -427,9 +424,8 @@ static void hvc_hangup(struct tty_struct *tty)
427 temp_open_count = hp->count; 424 temp_open_count = hp->count;
428 hp->count = 0; 425 hp->count = 0;
429 hp->n_outbuf = 0; 426 hp->n_outbuf = 0;
430 hp->tty = NULL;
431
432 spin_unlock_irqrestore(&hp->lock, flags); 427 spin_unlock_irqrestore(&hp->lock, flags);
428 tty_port_tty_set(&hp->port, NULL);
433 429
434 if (hp->ops->notifier_hangup) 430 if (hp->ops->notifier_hangup)
435 hp->ops->notifier_hangup(hp, hp->data); 431 hp->ops->notifier_hangup(hp, hp->data);
@@ -526,13 +522,12 @@ static void hvc_set_winsz(struct work_struct *work)
526 522
527 hp = container_of(work, struct hvc_struct, tty_resize); 523 hp = container_of(work, struct hvc_struct, tty_resize);
528 524
529 spin_lock_irqsave(&hp->lock, hvc_flags); 525 tty = tty_port_tty_get(&hp->port);
530 if (!hp->tty) { 526 if (!tty)
531 spin_unlock_irqrestore(&hp->lock, hvc_flags);
532 return; 527 return;
533 } 528
534 ws = hp->ws; 529 spin_lock_irqsave(&hp->lock, hvc_flags);
535 tty = tty_kref_get(hp->tty); 530 ws = hp->ws;
536 spin_unlock_irqrestore(&hp->lock, hvc_flags); 531 spin_unlock_irqrestore(&hp->lock, hvc_flags);
537 532
538 tty_do_resize(tty, &ws); 533 tty_do_resize(tty, &ws);
@@ -601,7 +596,7 @@ int hvc_poll(struct hvc_struct *hp)
601 } 596 }
602 597
603 /* No tty attached, just skip */ 598 /* No tty attached, just skip */
604 tty = tty_kref_get(hp->tty); 599 tty = tty_port_tty_get(&hp->port);
605 if (tty == NULL) 600 if (tty == NULL)
606 goto bail; 601 goto bail;
607 602
@@ -681,8 +676,7 @@ int hvc_poll(struct hvc_struct *hp)
681 676
682 tty_flip_buffer_push(tty); 677 tty_flip_buffer_push(tty);
683 } 678 }
684 if (tty) 679 tty_kref_put(tty);
685 tty_kref_put(tty);
686 680
687 return poll_mask; 681 return poll_mask;
688} 682}
@@ -880,9 +874,9 @@ int hvc_remove(struct hvc_struct *hp)
880 unsigned long flags; 874 unsigned long flags;
881 struct tty_struct *tty; 875 struct tty_struct *tty;
882 876
883 spin_lock_irqsave(&hp->lock, flags); 877 tty = tty_port_tty_get(&hp->port);
884 tty = tty_kref_get(hp->tty);
885 878
879 spin_lock_irqsave(&hp->lock, flags);
886 if (hp->index < MAX_NR_HVC_CONSOLES) 880 if (hp->index < MAX_NR_HVC_CONSOLES)
887 vtermnos[hp->index] = -1; 881 vtermnos[hp->index] = -1;
888 882