diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2013-01-28 22:34:35 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-29 23:28:44 -0500 |
commit | de321a14da65a534da89a80dde949d0c6ff6316f (patch) | |
tree | 570391719343bd6bf7b868872805358fcc5eb2d4 | |
parent | 2b86216ba1d059b2609532ded9400f905013b376 (diff) |
staging/fwserial: Only reset port status for attached peers
When a port has been reserved in an attempt to connect to a peer
but that attempt does not succeed, releasing the port should not
reset the port line status. Although resetting is functionally
harmless, it can appear as if a remote peer dropped carrier to a
port it was not attached to (which can be confusing).
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/fwserial/fwserial.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index 59e90e666d7b..8db4b41d4f43 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c | |||
@@ -1783,10 +1783,11 @@ static struct fwtty_port *fwserial_find_port(struct fwtty_peer *peer) | |||
1783 | return NULL; | 1783 | return NULL; |
1784 | } | 1784 | } |
1785 | 1785 | ||
1786 | static void fwserial_release_port(struct fwtty_port *port) | 1786 | static void fwserial_release_port(struct fwtty_port *port, bool reset) |
1787 | { | 1787 | { |
1788 | /* drop carrier (and all other line status) */ | 1788 | /* drop carrier (and all other line status) */ |
1789 | fwtty_update_port_status(port, 0); | 1789 | if (reset) |
1790 | fwtty_update_port_status(port, 0); | ||
1790 | 1791 | ||
1791 | spin_lock_bh(&port->lock); | 1792 | spin_lock_bh(&port->lock); |
1792 | 1793 | ||
@@ -1816,7 +1817,7 @@ static void fwserial_plug_timeout(unsigned long data) | |||
1816 | spin_unlock_bh(&peer->lock); | 1817 | spin_unlock_bh(&peer->lock); |
1817 | 1818 | ||
1818 | if (port) | 1819 | if (port) |
1819 | fwserial_release_port(port); | 1820 | fwserial_release_port(port, false); |
1820 | } | 1821 | } |
1821 | 1822 | ||
1822 | /** | 1823 | /** |
@@ -1879,7 +1880,7 @@ cancel_timer: | |||
1879 | peer_revert_state(peer); | 1880 | peer_revert_state(peer); |
1880 | release_port: | 1881 | release_port: |
1881 | spin_unlock_bh(&peer->lock); | 1882 | spin_unlock_bh(&peer->lock); |
1882 | fwserial_release_port(port); | 1883 | fwserial_release_port(port, false); |
1883 | free_pkt: | 1884 | free_pkt: |
1884 | kfree(pkt); | 1885 | kfree(pkt); |
1885 | return err; | 1886 | return err; |
@@ -2157,7 +2158,7 @@ static void fwserial_remove_peer(struct fwtty_peer *peer) | |||
2157 | spin_unlock_bh(&peer->lock); | 2158 | spin_unlock_bh(&peer->lock); |
2158 | 2159 | ||
2159 | if (port) | 2160 | if (port) |
2160 | fwserial_release_port(port); | 2161 | fwserial_release_port(port, true); |
2161 | 2162 | ||
2162 | synchronize_rcu(); | 2163 | synchronize_rcu(); |
2163 | kfree(peer); | 2164 | kfree(peer); |
@@ -2617,7 +2618,7 @@ static void fwserial_handle_plug_req(struct work_struct *work) | |||
2617 | 2618 | ||
2618 | spin_unlock_bh(&peer->lock); | 2619 | spin_unlock_bh(&peer->lock); |
2619 | if (port) | 2620 | if (port) |
2620 | fwserial_release_port(port); | 2621 | fwserial_release_port(port, false); |
2621 | 2622 | ||
2622 | rcode = fwserial_send_mgmt_sync(peer, pkt); | 2623 | rcode = fwserial_send_mgmt_sync(peer, pkt); |
2623 | 2624 | ||
@@ -2639,7 +2640,7 @@ static void fwserial_handle_plug_req(struct work_struct *work) | |||
2639 | cleanup: | 2640 | cleanup: |
2640 | spin_unlock_bh(&peer->lock); | 2641 | spin_unlock_bh(&peer->lock); |
2641 | if (port) | 2642 | if (port) |
2642 | fwserial_release_port(port); | 2643 | fwserial_release_port(port, false); |
2643 | kfree(pkt); | 2644 | kfree(pkt); |
2644 | return; | 2645 | return; |
2645 | } | 2646 | } |
@@ -2691,7 +2692,7 @@ static void fwserial_handle_unplug_req(struct work_struct *work) | |||
2691 | cleanup: | 2692 | cleanup: |
2692 | spin_unlock_bh(&peer->lock); | 2693 | spin_unlock_bh(&peer->lock); |
2693 | if (port) | 2694 | if (port) |
2694 | fwserial_release_port(port); | 2695 | fwserial_release_port(port, true); |
2695 | kfree(pkt); | 2696 | kfree(pkt); |
2696 | return; | 2697 | return; |
2697 | } | 2698 | } |
@@ -2702,6 +2703,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer, | |||
2702 | size_t len) | 2703 | size_t len) |
2703 | { | 2704 | { |
2704 | struct fwtty_port *port = NULL; | 2705 | struct fwtty_port *port = NULL; |
2706 | bool reset = false; | ||
2705 | int rcode; | 2707 | int rcode; |
2706 | 2708 | ||
2707 | if (addr != fwserial_mgmt_addr_handler.offset || len < sizeof(pkt->hdr)) | 2709 | if (addr != fwserial_mgmt_addr_handler.offset || len < sizeof(pkt->hdr)) |
@@ -2777,6 +2779,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer, | |||
2777 | if (be16_to_cpu(pkt->hdr.code) & FWSC_RSP_NACK) | 2779 | if (be16_to_cpu(pkt->hdr.code) & FWSC_RSP_NACK) |
2778 | fwtty_notice(&peer->unit, "NACK unplug?"); | 2780 | fwtty_notice(&peer->unit, "NACK unplug?"); |
2779 | port = peer_revert_state(peer); | 2781 | port = peer_revert_state(peer); |
2782 | reset = true; | ||
2780 | } | 2783 | } |
2781 | break; | 2784 | break; |
2782 | 2785 | ||
@@ -2788,7 +2791,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer, | |||
2788 | spin_unlock_bh(&peer->lock); | 2791 | spin_unlock_bh(&peer->lock); |
2789 | 2792 | ||
2790 | if (port) | 2793 | if (port) |
2791 | fwserial_release_port(port); | 2794 | fwserial_release_port(port, reset); |
2792 | 2795 | ||
2793 | return rcode; | 2796 | return rcode; |
2794 | } | 2797 | } |