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: 9627109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6577B6048C for ; Thu, 16 Mar 2017 05:20:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 558BE285E3 for ; Thu, 16 Mar 2017 05:20:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47030285F5; Thu, 16 Mar 2017 05:20:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B52DA285E3 for ; Thu, 16 Mar 2017 05:20:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751111AbdCPFUL (ORCPT ); Thu, 16 Mar 2017 01:20:11 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:32979 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751037AbdCPFUL (ORCPT ); Thu, 16 Mar 2017 01:20:11 -0400 Received: by mail-pg0-f41.google.com with SMTP id n190so19533655pga.0 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=Hd6KqjeqZi17zPHQenJdZ6SjKtEyF7i1HtLobTu9bdINJvM849y4wXJYhCoeWvxiJZ zp3amlD9XswnylwCucuySBIkPmUDsFnMT9FRlSif8eH17SB6s2Urw+hzQN2Bjbzy6eIY MeMt39kT/4+y8S0nBMZPRR5pJN39ZaCpdHvkpd5TTntmOe54ly3Pe2EX68icFxQTooCm sH3OiL3l1velIKtzQvQMgXSChDFH6veQcrHHWl9+2CW7vX51VFaP3zCVgTWEWcu2tKda lOmZOu7KC+iyGMp66cm7VfySkx2lNS9+SbLRHq0LHZVENtCJjSgnNImCMTBXER2hdDRg JYKw== X-Gm-Message-State: AFeK/H0AalAoXkI7xeGa6ivJJKQXVhkZT7BvJggfm82r2HD4chUbtDrNnuqUc23dF+RvM39R 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-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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;