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: 73942 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1711944qga; Mon, 15 Aug 2016 17:18:14 -0700 (PDT) X-Received: by 10.98.73.24 with SMTP id w24mr7036939pfa.27.1471306694405; Mon, 15 Aug 2016 17:18:14 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r5si28974912paa.190.2016.08.15.17.18.13; Mon, 15 Aug 2016 17:18:14 -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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932455AbcHPARk (ORCPT + 27 others); Mon, 15 Aug 2016 20:17:40 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:33920 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932416AbcHPARg (ORCPT ); Mon, 15 Aug 2016 20:17:36 -0400 Received: by mail-pf0-f176.google.com with SMTP id p64so21404057pfb.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=iJKRVhTPg++eWNMZUQzO8e0FuohKhMZzwlE2AbLur5LRVkikENrJM/B56PUw3+3wnF goh864vn+sv4Da8SE8YepuCwc9+O/0cu0++7ytnwOQ+MILLn9tN3/fH3YrqwCChfFXUx MuR3hpxZLwevPfYQAsXws9UyuBn46NM4NAQ3UkXmfIB/msHwFr8X3fD76JQzHFXNpIVA rZE2xo3UTiTj8mbUDyds4caP/QZfRRbrAEbT0kpc2jSf0lXCF9J1aQOyc0eUzWurATJQ N/uuLfAY2Wx1zTTuWU2Ao6QzaWs375Ep9yhA8b5JJhEz4nDxX7xHPTBa7rNTXkrvyf83 PI7w== X-Gm-Message-State: AEkoousV2rSNgKnqqHnNsfIZ6QgoJxkTVN3Z9Le995w9HC4l4LzOeCF9tusM1Jf4d9hFu1Xs 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 Cc: linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.5.0 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; } /*