From patchwork Thu Sep 1 22:28:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9309999 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 37A9560756 for ; Thu, 1 Sep 2016 22:33:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDB71293E7 for ; Thu, 1 Sep 2016 22:33:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E25222955F; Thu, 1 Sep 2016 22:33:42 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7A425293E7 for ; Thu, 1 Sep 2016 22:33:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bfaWX-0006DO-Om; Thu, 01 Sep 2016 22:31:53 +0000 Received: from mail-pa0-x232.google.com ([2607:f8b0:400e:c03::232]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bfaTS-0002Eb-Qn for linux-arm-kernel@lists.infradead.org; Thu, 01 Sep 2016 22:28:47 +0000 Received: by mail-pa0-x232.google.com with SMTP id cy9so33877244pac.0 for ; Thu, 01 Sep 2016 15:28:25 -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:in-reply-to:references; bh=kC6JEb+v4px1xXmbztIzSkEa83GwmdDNfmD+bVPQM6w=; b=ATw48A0odsUVX7P6zmLEDXFs4PLDeqV+fbvFdbyRSdcD9gXbnZL/1H+162Z1LbUz96 hLQQYHsowMnJ4EhOe6FAlpUrx8Aw7lR9sXb5ShrPiSpTkjWw7i2VxD9JbYWtqVWCNC28 zWR5ip8kdN9m87WnBegvqbve7sBiSiaZnq/Uc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kC6JEb+v4px1xXmbztIzSkEa83GwmdDNfmD+bVPQM6w=; b=OFZIKZkXfxY4W/MYW28YS33SCyrYRNJdcvmDKwcK9bezqrW2CeaHvmT4z7WiGxfgK3 pNPxiuW5Ph24E5Uno6FPoo9HuVG6mJlqckbS1OA/fPy6EOQ2ielcuHMFxnHdR9sx+g3r GYMYfhOUM7uTSMjjwquE/Qqo8An7Q3qSmZph60wU4kg+wTJdSd7L6MsvC031j+HrHCj6 NtM7qGqn26NvSTSvLYVQyTy50YEcbmZzlesvICR71pZpBtsQpSueu34SlW6z8l/nKbmg Tie+SyuppCGboTjFH1HhAI0fWREwCH+LZ3gX/fyxjGzT2CLRU1FlY5vXk016HgyiR6Ym RwwA== X-Gm-Message-State: AE9vXwPbaaNCUWILKRE6sIjxZGGozj6FQ9nB6JvPySRoEwQxRQ3+LCxHic6tidNllde9Eokx X-Received: by 10.66.66.233 with SMTP id i9mr30866441pat.45.1472768905393; Thu, 01 Sep 2016 15:28:25 -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 iw10sm8887131pac.14.2016.09.01.15.28.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Sep 2016 15:28:24 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Subject: [PATCH v2 11/17] rpmsg: Split off generic tail of create_channel() Date: Thu, 1 Sep 2016 15:28:03 -0700 Message-Id: <1472768889-3906-12-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1472768889-3906-1-git-send-email-bjorn.andersson@linaro.org> References: <1472768889-3906-1-git-send-email-bjorn.andersson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160901_152842_976228_1BCCD0B1 X-CRM114-Status: GOOD ( 14.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The tail of create_channel() is common among all rpmsg backends, so split it off from the virtio specific part to allow it to be extracted to the rpmsg core. Signed-off-by: Bjorn Andersson --- Changes since v1: - None drivers/rpmsg/virtio_rpmsg_bus.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 488fd93a290c..e1052622c6a2 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -120,6 +120,7 @@ static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); static int virtio_rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, void *data, int len); +static int rpmsg_register_device(struct rpmsg_device *rpdev); /* sysfs show configuration fields */ #define rpmsg_show_attr(field, path, format_string) \ @@ -499,10 +500,22 @@ 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; + ret = rpmsg_register_device(rpdev); + if (ret) + return NULL; + + return rpdev; +} + +static int rpmsg_register_device(struct rpmsg_device *rpdev) +{ + struct device *dev = &rpdev->dev; + int ret; + dev_set_name(&rpdev->dev, "%s:%s", dev_name(dev->parent), rpdev->id.name); - rpdev->dev.parent = &vrp->vdev->dev; rpdev->dev.bus = &rpmsg_bus; rpdev->dev.release = rpmsg_release_device; @@ -510,10 +523,9 @@ static struct rpmsg_device *rpmsg_create_channel(struct virtproc_info *vrp, if (ret) { dev_err(dev, "device_register failed: %d\n", ret); put_device(&rpdev->dev); - return NULL; } - return rpdev; + return ret; } /*