Commit de321a14 authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman

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: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2b86216b
...@@ -1783,9 +1783,10 @@ static struct fwtty_port *fwserial_find_port(struct fwtty_peer *peer) ...@@ -1783,9 +1783,10 @@ static struct fwtty_port *fwserial_find_port(struct fwtty_peer *peer)
return NULL; return NULL;
} }
static void fwserial_release_port(struct fwtty_port *port) static void fwserial_release_port(struct fwtty_port *port, bool reset)
{ {
/* drop carrier (and all other line status) */ /* drop carrier (and all other line status) */
if (reset)
fwtty_update_port_status(port, 0); fwtty_update_port_status(port, 0);
spin_lock_bh(&port->lock); spin_lock_bh(&port->lock);
...@@ -1816,7 +1817,7 @@ static void fwserial_plug_timeout(unsigned long data) ...@@ -1816,7 +1817,7 @@ static void fwserial_plug_timeout(unsigned long data)
spin_unlock_bh(&peer->lock); spin_unlock_bh(&peer->lock);
if (port) if (port)
fwserial_release_port(port); fwserial_release_port(port, false);
} }
/** /**
...@@ -1879,7 +1880,7 @@ static int fwserial_connect_peer(struct fwtty_peer *peer) ...@@ -1879,7 +1880,7 @@ static int fwserial_connect_peer(struct fwtty_peer *peer)
peer_revert_state(peer); peer_revert_state(peer);
release_port: release_port:
spin_unlock_bh(&peer->lock); spin_unlock_bh(&peer->lock);
fwserial_release_port(port); fwserial_release_port(port, false);
free_pkt: free_pkt:
kfree(pkt); kfree(pkt);
return err; return err;
...@@ -2157,7 +2158,7 @@ static void fwserial_remove_peer(struct fwtty_peer *peer) ...@@ -2157,7 +2158,7 @@ static void fwserial_remove_peer(struct fwtty_peer *peer)
spin_unlock_bh(&peer->lock); spin_unlock_bh(&peer->lock);
if (port) if (port)
fwserial_release_port(port); fwserial_release_port(port, true);
synchronize_rcu(); synchronize_rcu();
kfree(peer); kfree(peer);
...@@ -2617,7 +2618,7 @@ static void fwserial_handle_plug_req(struct work_struct *work) ...@@ -2617,7 +2618,7 @@ static void fwserial_handle_plug_req(struct work_struct *work)
spin_unlock_bh(&peer->lock); spin_unlock_bh(&peer->lock);
if (port) if (port)
fwserial_release_port(port); fwserial_release_port(port, false);
rcode = fwserial_send_mgmt_sync(peer, pkt); rcode = fwserial_send_mgmt_sync(peer, pkt);
...@@ -2639,7 +2640,7 @@ static void fwserial_handle_plug_req(struct work_struct *work) ...@@ -2639,7 +2640,7 @@ static void fwserial_handle_plug_req(struct work_struct *work)
cleanup: cleanup:
spin_unlock_bh(&peer->lock); spin_unlock_bh(&peer->lock);
if (port) if (port)
fwserial_release_port(port); fwserial_release_port(port, false);
kfree(pkt); kfree(pkt);
return; return;
} }
...@@ -2691,7 +2692,7 @@ static void fwserial_handle_unplug_req(struct work_struct *work) ...@@ -2691,7 +2692,7 @@ static void fwserial_handle_unplug_req(struct work_struct *work)
cleanup: cleanup:
spin_unlock_bh(&peer->lock); spin_unlock_bh(&peer->lock);
if (port) if (port)
fwserial_release_port(port); fwserial_release_port(port, true);
kfree(pkt); kfree(pkt);
return; return;
} }
...@@ -2702,6 +2703,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer, ...@@ -2702,6 +2703,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer,
size_t len) size_t len)
{ {
struct fwtty_port *port = NULL; struct fwtty_port *port = NULL;
bool reset = false;
int rcode; int rcode;
if (addr != fwserial_mgmt_addr_handler.offset || len < sizeof(pkt->hdr)) 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,6 +2779,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer,
if (be16_to_cpu(pkt->hdr.code) & FWSC_RSP_NACK) if (be16_to_cpu(pkt->hdr.code) & FWSC_RSP_NACK)
fwtty_notice(&peer->unit, "NACK unplug?"); fwtty_notice(&peer->unit, "NACK unplug?");
port = peer_revert_state(peer); port = peer_revert_state(peer);
reset = true;
} }
break; break;
...@@ -2788,7 +2791,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer, ...@@ -2788,7 +2791,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer,
spin_unlock_bh(&peer->lock); spin_unlock_bh(&peer->lock);
if (port) if (port)
fwserial_release_port(port); fwserial_release_port(port, reset);
return rcode; return rcode;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment