From patchwork Tue Aug 16 00:17:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9282419 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 E556E607FD for ; Tue, 16 Aug 2016 00:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D48F821050 for ; Tue, 16 Aug 2016 00:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C95DD28E8E; Tue, 16 Aug 2016 00:20:52 +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 6427021050 for ; Tue, 16 Aug 2016 00:20:52 +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 1bZS6K-0004MU-Ez; Tue, 16 Aug 2016 00:19:28 +0000 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZS4m-0003Re-4T for linux-arm-kernel@lists.infradead.org; Tue, 16 Aug 2016 00:17:58 +0000 Received: by mail-pf0-x231.google.com with SMTP id p64so21404056pfb.1 for ; Mon, 15 Aug 2016 17:17:31 -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=r33Ebn4dQsXzI4Tki8KPhX1N9+5deLqMZQkSPA6XiB8=; b=WkT/ablgXMw7dhiNzowEsFyw7KrVyTnUmg97iw1gSbmNAjzO1jyij/COqBxdVTVYme dcaeTaF0WAwE1Y9pUuyRuV2Ed/kIwzfoBDbHvFGj1vGcfM/Q5PRa/sflUHcIotdnwwO6 FHhIuP6e8OM93ht4n1AnJ/hbhAZ++HgHmUREY= 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=r33Ebn4dQsXzI4Tki8KPhX1N9+5deLqMZQkSPA6XiB8=; b=DvMCLQCmpwzIA3HUZm3DBN+O7p+zt8iYsxIm+VB3u2n+jfB8gsao5URrh0PpRzs3PW gLAr9fVztAdbGU7auM8JHmIfnO4lYgUqjSPPs1rGQKKRWtnVsKExP3IXQ7F29YkUSHno o2AXsNiSsM8laHspFqe7Cb2y0zH7+pkJ85R+oqu/3ND5L0usoCg54j7hjb1dl9kBXgPf GJcwS7tMHOamubulDsqZCPi5XeVuBKuRzq5YM3szAxEiMTLfMI50foRmhasRqHcKrQnx wsaz+9qLJWZ+YQuBXccw6WXZ2ts3LLuWSJHHidl/ZscJTyHOc0Gd75/NDAyWAEbKU0QA g31Q== X-Gm-Message-State: AEkoouuetvI0c5OkmZ541S76LWRzWtFXDxcmOAaquWtnixZjLHykYieBT0Rtr6XkDw7+syib X-Received: by 10.98.108.3 with SMTP id h3mr58749869pfc.162.1471306651268; Mon, 15 Aug 2016 17:17:31 -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 p187sm34047931pfb.5.2016.08.15.17.17.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Aug 2016 17:17:30 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Subject: [PATCH 07/14] rpmsg: Split off generic tail of create_channel() Date: Mon, 15 Aug 2016 17:17:13 -0700 Message-Id: <1471306640-29917-8-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1471306640-29917-1-git-send-email-bjorn.andersson@linaro.org> References: <1471306640-29917-1-git-send-email-bjorn.andersson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160815_171752_411363_447B522D X-CRM114-Status: GOOD ( 13.17 ) 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 --- 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 1dc7a1149c51..5cadb75a225d 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -129,6 +129,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) \ @@ -583,10 +584,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; @@ -594,10 +607,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; } /*