msm: ADSPRPC: close glink channel before opening again

Added proper checks to avoid opening a glink channel before
completely closing previously opened channel.

Change-Id: Iaa41f4b27a80967b634dd832cc6ad060ea083b18
Acked-by: Viswanatham Paduchuri <vpaduchu@qti.qualcomm.com>
Signed-off-by: Tharun Kumar Merugu <mtharu@codeaurora.org>
This commit is contained in:
Tharun Kumar Merugu 2017-05-10 11:32:25 +05:30 committed by Gerrit - the friendly Code Review server
parent 3d82d66409
commit 5a15915855

View file

@ -2126,11 +2126,9 @@ void fastrpc_glink_notify_state(void *handle, const void *priv, unsigned event)
link->port_state = FASTRPC_LINK_DISCONNECTED; link->port_state = FASTRPC_LINK_DISCONNECTED;
break; break;
case GLINK_REMOTE_DISCONNECTED: case GLINK_REMOTE_DISCONNECTED:
if (me->channel[cid].chan && if (me->channel[cid].chan) {
link->link_state == FASTRPC_LINK_STATE_UP) {
fastrpc_glink_close(me->channel[cid].chan, cid); fastrpc_glink_close(me->channel[cid].chan, cid);
me->channel[cid].chan = 0; me->channel[cid].chan = 0;
link->port_state = FASTRPC_LINK_DISCONNECTED;
} }
break; break;
default: default:
@ -2296,10 +2294,9 @@ static int fastrpc_glink_open(int cid)
if (err) if (err)
goto bail; goto bail;
if (link->port_state == FASTRPC_LINK_CONNECTED || VERIFY(err, (link->port_state == FASTRPC_LINK_DISCONNECTED));
link->port_state == FASTRPC_LINK_CONNECTING) { if (err)
goto bail; goto bail;
}
link->port_state = FASTRPC_LINK_CONNECTING; link->port_state = FASTRPC_LINK_CONNECTING;
cfg->priv = (void *)(uintptr_t)cid; cfg->priv = (void *)(uintptr_t)cid;
@ -2458,7 +2455,9 @@ static int fastrpc_channel_open(struct fastrpc_file *fl)
if ((kref_get_unless_zero(&me->channel[cid].kref) == 0) || if ((kref_get_unless_zero(&me->channel[cid].kref) == 0) ||
(me->channel[cid].chan == 0)) { (me->channel[cid].chan == 0)) {
if (me->glink) { if (me->glink) {
fastrpc_glink_register(cid, me); VERIFY(err, 0 == fastrpc_glink_register(cid, me));
if (err)
goto bail;
VERIFY(err, 0 == fastrpc_glink_open(cid)); VERIFY(err, 0 == fastrpc_glink_open(cid));
} else { } else {
VERIFY(err, !smd_named_open_on_edge(FASTRPC_SMD_GUID, VERIFY(err, !smd_named_open_on_edge(FASTRPC_SMD_GUID,