drivers/rpmsg/clk/ioe: destroy nxsem properly

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2022-11-20 22:07:15 +08:00 committed by Xiang Xiao
parent 74cfa7ddb9
commit 07604b3220
2 changed files with 16 additions and 18 deletions

View File

@ -485,18 +485,17 @@ static int64_t clk_rpmsg_sendrecv(FAR struct rpmsg_endpoint *ept,
cookie.result = -EIO;
ret = rpmsg_send_nocopy(ept, msg, len);
if (ret < 0)
if (ret >= 0)
{
return ret;
ret = nxsem_wait_uninterruptible(&cookie.sem);
if (ret >= 0)
{
ret = cookie.result;
}
}
ret = nxsem_wait_uninterruptible(&cookie.sem);
if (ret < 0)
{
return ret;
}
return cookie.result;
nxsem_destroy(&cookie.sem);
return ret;
}
static bool clk_rpmsg_server_match(FAR struct rpmsg_device *rdev,

View File

@ -275,18 +275,17 @@ static int ioe_rpmsg_sendrecv(FAR struct rpmsg_endpoint *ept,
msg->cookie = (uintptr_t)&cookie;
ret = rpmsg_send(ept, msg, len);
if (ret < 0)
if (ret >= 0)
{
return ret;
ret = rpmsg_wait(ept, &cookie.sem);
if (ret >= 0)
{
ret = cookie.result;
}
}
ret = rpmsg_wait(ept, &cookie.sem);
if (ret < 0)
{
return ret;
}
return cookie.result;
nxsem_destroy(&cookie.sem);
return ret;
}
static int ioe_rpmsg_direction(FAR struct ioexpander_dev_s *dev, uint8_t pin,