Skip to content

Commit 973ec55

Browse files
committed
Merge tag 'rpmsg-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux
Pull rpmsg updates from Bjorn Andersson: - Reduce code duplication related to channel removal, and invoke the removal in one case previously missing, both in the Glink driver * tag 'rpmsg-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux: rpmsg: glink: remove duplicate code for rpmsg device remove rpmsg: glink: fix rpmsg device leak
2 parents e637b37 + 112766c commit 973ec55

1 file changed

Lines changed: 16 additions & 19 deletions

File tree

drivers/rpmsg/qcom_glink_native.c

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,19 @@ static int qcom_glink_announce_create(struct rpmsg_device *rpdev)
13951395
return 0;
13961396
}
13971397

1398+
static void qcom_glink_remove_rpmsg_device(struct qcom_glink *glink, struct glink_channel *channel)
1399+
{
1400+
struct rpmsg_channel_info chinfo;
1401+
1402+
if (channel->rpdev) {
1403+
strscpy_pad(chinfo.name, channel->name, sizeof(chinfo.name));
1404+
chinfo.src = RPMSG_ADDR_ANY;
1405+
chinfo.dst = RPMSG_ADDR_ANY;
1406+
rpmsg_unregister_device(glink->dev, &chinfo);
1407+
}
1408+
channel->rpdev = NULL;
1409+
}
1410+
13981411
static void qcom_glink_destroy_ept(struct rpmsg_endpoint *ept)
13991412
{
14001413
struct glink_channel *channel = to_glink_channel(ept);
@@ -1406,7 +1419,7 @@ static void qcom_glink_destroy_ept(struct rpmsg_endpoint *ept)
14061419
spin_unlock_irqrestore(&channel->recv_lock, flags);
14071420

14081421
/* Decouple the potential rpdev from the channel */
1409-
channel->rpdev = NULL;
1422+
qcom_glink_remove_rpmsg_device(glink, channel);
14101423

14111424
qcom_glink_send_close_req(glink, channel);
14121425
}
@@ -1697,7 +1710,6 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid,
16971710

16981711
static void qcom_glink_rx_close(struct qcom_glink *glink, unsigned int rcid)
16991712
{
1700-
struct rpmsg_channel_info chinfo;
17011713
struct glink_channel *channel;
17021714
unsigned long flags;
17031715

@@ -1713,14 +1725,7 @@ static void qcom_glink_rx_close(struct qcom_glink *glink, unsigned int rcid)
17131725
/* cancel pending rx_done work */
17141726
cancel_work_sync(&channel->intent_work);
17151727

1716-
if (channel->rpdev) {
1717-
strscpy_pad(chinfo.name, channel->name, sizeof(chinfo.name));
1718-
chinfo.src = RPMSG_ADDR_ANY;
1719-
chinfo.dst = RPMSG_ADDR_ANY;
1720-
1721-
rpmsg_unregister_device(glink->dev, &chinfo);
1722-
}
1723-
channel->rpdev = NULL;
1728+
qcom_glink_remove_rpmsg_device(glink, channel);
17241729

17251730
qcom_glink_send_close_ack(glink, channel);
17261731

@@ -1734,7 +1739,6 @@ static void qcom_glink_rx_close(struct qcom_glink *glink, unsigned int rcid)
17341739

17351740
static void qcom_glink_rx_close_ack(struct qcom_glink *glink, unsigned int lcid)
17361741
{
1737-
struct rpmsg_channel_info chinfo;
17381742
struct glink_channel *channel;
17391743
unsigned long flags;
17401744

@@ -1756,14 +1760,7 @@ static void qcom_glink_rx_close_ack(struct qcom_glink *glink, unsigned int lcid)
17561760
spin_unlock_irqrestore(&glink->idr_lock, flags);
17571761

17581762
/* Decouple the potential rpdev from the channel */
1759-
if (channel->rpdev) {
1760-
strscpy(chinfo.name, channel->name, sizeof(chinfo.name));
1761-
chinfo.src = RPMSG_ADDR_ANY;
1762-
chinfo.dst = RPMSG_ADDR_ANY;
1763-
1764-
rpmsg_unregister_device(glink->dev, &chinfo);
1765-
}
1766-
channel->rpdev = NULL;
1763+
qcom_glink_remove_rpmsg_device(glink, channel);
17671764

17681765
kref_put(&channel->refcount, qcom_glink_channel_release);
17691766
}

0 commit comments

Comments
 (0)