From patchwork Thu Mar 16 05:18:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 95367 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp658156qgd; Wed, 15 Mar 2017 22:20:18 -0700 (PDT) X-Received: by 10.98.159.149 with SMTP id v21mr8197527pfk.57.1489641618324; Wed, 15 Mar 2017 22:20:18 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si1377279pfh.39.2017.03.15.22.20.17; Wed, 15 Mar 2017 22:20:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751161AbdCPFUN (ORCPT + 25 others); Thu, 16 Mar 2017 01:20:13 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:36627 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751029AbdCPFUL (ORCPT ); Thu, 16 Mar 2017 01:20:11 -0400 Received: by mail-pg0-f53.google.com with SMTP id g2so19409869pge.3 for ; Wed, 15 Mar 2017 22:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ST/e2Ryg5PMqyuhtF6Zc1rhfZUMCtzJklJOaF7l8yHI=; b=cDuBqDDgRhkTbDO5UyRJpqBH7ru5CW9p8X0g4TTRGH1gk3ZpMEBI2h6rxMCLbEjxWD pAe1MsCeL+Riq7KtXbRMIhQuiMJyxevhPHWXcV5qE5bU08N/QydgAxsEGqdmREfeVabd ajhFNyqx8kI4VJv8bN+6scJhFpRhfK+NN5P0Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ST/e2Ryg5PMqyuhtF6Zc1rhfZUMCtzJklJOaF7l8yHI=; b=MD32qyfVFC2SSHkTy+1Uo8NYA06pj03xoV9BaIvNfaPBtGtW7K1kAn9KPhCAoc4eIf omH/w2W3FuGDt4APd+j6PR/LLdB3G1xTJ2JKlYvfAT1P156s2yFMlQBQP79kRpmpa7NB 1HldCZmYX3wvpmrMQn3WEanAHYQfVigizUWnoZX6wawqDv5XI3trS9icq4ySerbZ+VuR UWWvN3Si1jtlv/ME5x0jcet0pYN7OkGgQloiyy7GIDrwlWQjAc59ePvbACUOuXd9x0KR 41fUQavmd9mxyuzQzc9MEiiOgeMxsGyRL7qBWfS6ZOKhoB2naGBFzAP2TjfDkFeNQbhc y2WQ== X-Gm-Message-State: AFeK/H3kTD4ic+FWeJazVznVa4BNlB8GTZuziC4yCmPdfhbR2sbbM81i1mWzYLMFPrTkX/z3 X-Received: by 10.98.50.66 with SMTP id y63mr8063850pfy.21.1489641519915; Wed, 15 Mar 2017 22:18:39 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id u75sm7398290pgc.31.2017.03.15.22.18.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:18:38 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rpmsg: Release rpmsg devices in backends Date: Wed, 15 Mar 2017 22:18:35 -0700 Message-Id: <20170316051835.10008-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rpmsg devices are allocated in the backends and as such must be freed there as well. Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_smd.c | 11 +++++++++++ drivers/rpmsg/virtio_rpmsg_bus.c | 9 +++++++++ 2 files changed, 20 insertions(+) -- 2.12.0 diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index beaef5dd973e..a0a39a8821a3 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -969,6 +969,14 @@ static const struct rpmsg_endpoint_ops qcom_smd_endpoint_ops = { .poll = qcom_smd_poll, }; +static void qcom_smd_release_device(struct device *dev) +{ + struct rpmsg_device *rpdev = to_rpmsg_device(dev); + struct qcom_smd_device *qsdev = to_smd_device(rpdev); + + kfree(qsdev); +} + /* * Create a smd client device for channel that is being opened. */ @@ -998,6 +1006,7 @@ static int qcom_smd_create_device(struct qcom_smd_channel *channel) rpdev->dev.of_node = qcom_smd_match_channel(edge->of_node, channel->name); rpdev->dev.parent = &edge->dev; + rpdev->dev.release = qcom_smd_release_device; return rpmsg_register_device(rpdev); } @@ -1013,6 +1022,8 @@ static int qcom_smd_create_chrdev(struct qcom_smd_edge *edge) qsdev->edge = edge; qsdev->rpdev.ops = &qcom_smd_device_ops; qsdev->rpdev.dev.parent = &edge->dev; + qsdev->rpdev.dev.release = qcom_smd_release_device; + return rpmsg_chrdev_register_device(&qsdev->rpdev); } diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 5e66e081027e..7f8c5cc1c118 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -360,6 +360,14 @@ static const struct rpmsg_device_ops virtio_rpmsg_ops = { .announce_destroy = virtio_rpmsg_announce_destroy, }; +static void virtio_rpmsg_release_device(struct device *dev) +{ + struct rpmsg_device *rpdev = to_rpmsg_device(dev); + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); + + kfree(vch); +} + /* * create an rpmsg channel using its name and address info. * this function will be used to create both static and dynamic @@ -408,6 +416,7 @@ static struct rpmsg_device *rpmsg_create_channel(struct virtproc_info *vrp, strncpy(rpdev->id.name, chinfo->name, RPMSG_NAME_SIZE); rpdev->dev.parent = &vrp->vdev->dev; + rpdev->dev.release = virtio_rpmsg_release_device; ret = rpmsg_register_device(rpdev); if (ret) return NULL;