aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/keyspan.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2013-03-07 07:12:30 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-18 19:24:29 -0400
commitaa27a094e2c2e0cc59914e56113b860f524f4479 (patch)
treeb3cfef8d8023741107e3d3bed934f2bd4d8bf189 /drivers/usb/serial/keyspan.c
parente4408ce3c23f8451eff7a2954694598fb8fce833 (diff)
TTY: add tty_port_tty_hangup helper
It allows for cleaning up on a considerable amount of places. They did port_get, hangup, kref_put. Now the only thing needed is to call tty_port_tty_hangup which does exactly that. And they can also decide whether to consider CLOCAL or completely ignore that. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial/keyspan.c')
-rw-r--r--drivers/usb/serial/keyspan.c43
1 files changed, 10 insertions, 33 deletions
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 1fd1935c8316..b011478d2e5f 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -378,7 +378,6 @@ static void usa26_instat_callback(struct urb *urb)
378 struct usb_serial *serial; 378 struct usb_serial *serial;
379 struct usb_serial_port *port; 379 struct usb_serial_port *port;
380 struct keyspan_port_private *p_priv; 380 struct keyspan_port_private *p_priv;
381 struct tty_struct *tty;
382 int old_dcd_state, err; 381 int old_dcd_state, err;
383 int status = urb->status; 382 int status = urb->status;
384 383
@@ -421,12 +420,8 @@ static void usa26_instat_callback(struct urb *urb)
421 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); 420 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
422 p_priv->ri_state = ((msg->ri) ? 1 : 0); 421 p_priv->ri_state = ((msg->ri) ? 1 : 0);
423 422
424 if (old_dcd_state != p_priv->dcd_state) { 423 if (old_dcd_state != p_priv->dcd_state)
425 tty = tty_port_tty_get(&port->port); 424 tty_port_tty_hangup(&port->port, true);
426 if (tty && !C_CLOCAL(tty))
427 tty_hangup(tty);
428 tty_kref_put(tty);
429 }
430 425
431 /* Resubmit urb so we continue receiving */ 426 /* Resubmit urb so we continue receiving */
432 err = usb_submit_urb(urb, GFP_ATOMIC); 427 err = usb_submit_urb(urb, GFP_ATOMIC);
@@ -510,7 +505,6 @@ static void usa28_instat_callback(struct urb *urb)
510 struct usb_serial *serial; 505 struct usb_serial *serial;
511 struct usb_serial_port *port; 506 struct usb_serial_port *port;
512 struct keyspan_port_private *p_priv; 507 struct keyspan_port_private *p_priv;
513 struct tty_struct *tty;
514 int old_dcd_state; 508 int old_dcd_state;
515 int status = urb->status; 509 int status = urb->status;
516 510
@@ -551,12 +545,8 @@ static void usa28_instat_callback(struct urb *urb)
551 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); 545 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
552 p_priv->ri_state = ((msg->ri) ? 1 : 0); 546 p_priv->ri_state = ((msg->ri) ? 1 : 0);
553 547
554 if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { 548 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
555 tty = tty_port_tty_get(&port->port); 549 tty_port_tty_hangup(&port->port, true);
556 if (tty && !C_CLOCAL(tty))
557 tty_hangup(tty);
558 tty_kref_put(tty);
559 }
560 550
561 /* Resubmit urb so we continue receiving */ 551 /* Resubmit urb so we continue receiving */
562 err = usb_submit_urb(urb, GFP_ATOMIC); 552 err = usb_submit_urb(urb, GFP_ATOMIC);
@@ -642,12 +632,8 @@ static void usa49_instat_callback(struct urb *urb)
642 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); 632 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
643 p_priv->ri_state = ((msg->ri) ? 1 : 0); 633 p_priv->ri_state = ((msg->ri) ? 1 : 0);
644 634
645 if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { 635 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
646 struct tty_struct *tty = tty_port_tty_get(&port->port); 636 tty_port_tty_hangup(&port->port, true);
647 if (tty && !C_CLOCAL(tty))
648 tty_hangup(tty);
649 tty_kref_put(tty);
650 }
651 637
652 /* Resubmit urb so we continue receiving */ 638 /* Resubmit urb so we continue receiving */
653 err = usb_submit_urb(urb, GFP_ATOMIC); 639 err = usb_submit_urb(urb, GFP_ATOMIC);
@@ -851,7 +837,6 @@ static void usa90_instat_callback(struct urb *urb)
851 struct usb_serial *serial; 837 struct usb_serial *serial;
852 struct usb_serial_port *port; 838 struct usb_serial_port *port;
853 struct keyspan_port_private *p_priv; 839 struct keyspan_port_private *p_priv;
854 struct tty_struct *tty;
855 int old_dcd_state, err; 840 int old_dcd_state, err;
856 int status = urb->status; 841 int status = urb->status;
857 842
@@ -880,12 +865,8 @@ static void usa90_instat_callback(struct urb *urb)
880 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); 865 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
881 p_priv->ri_state = ((msg->ri) ? 1 : 0); 866 p_priv->ri_state = ((msg->ri) ? 1 : 0);
882 867
883 if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { 868 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
884 tty = tty_port_tty_get(&port->port); 869 tty_port_tty_hangup(&port->port, true);
885 if (tty && !C_CLOCAL(tty))
886 tty_hangup(tty);
887 tty_kref_put(tty);
888 }
889 870
890 /* Resubmit urb so we continue receiving */ 871 /* Resubmit urb so we continue receiving */
891 err = usb_submit_urb(urb, GFP_ATOMIC); 872 err = usb_submit_urb(urb, GFP_ATOMIC);
@@ -953,12 +934,8 @@ static void usa67_instat_callback(struct urb *urb)
953 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); 934 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
954 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); 935 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
955 936
956 if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { 937 if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
957 struct tty_struct *tty = tty_port_tty_get(&port->port); 938 tty_port_tty_hangup(&port->port, true);
958 if (tty && !C_CLOCAL(tty))
959 tty_hangup(tty);
960 tty_kref_put(tty);
961 }
962 939
963 /* Resubmit urb so we continue receiving */ 940 /* Resubmit urb so we continue receiving */
964 err = usb_submit_urb(urb, GFP_ATOMIC); 941 err = usb_submit_urb(urb, GFP_ATOMIC);