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: 9309915 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 2E46B60756 for ; Thu, 1 Sep 2016 22:29:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D862A2952E for ; Thu, 1 Sep 2016 22:29:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCA342955F; Thu, 1 Sep 2016 22:29:47 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 696B32952E for ; Thu, 1 Sep 2016 22:29:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752148AbcIAW3S (ORCPT ); Thu, 1 Sep 2016 18:29:18 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:35917 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752879AbcIAW2b (ORCPT ); Thu, 1 Sep 2016 18:28:31 -0400 Received: by mail-pa0-f50.google.com with SMTP id fu3so26012037pad.3 for ; Thu, 01 Sep 2016 15:28:30 -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=aX54rV3ZGGbqI8/019XkuhguJcV/l3CxeutKIz1r4wcsOG+Liaq/vDZlC1YRPuMTAx Ss9wRnuvTDNgPM2QegcXMjoTb+Y53Ztujx/+CKOyzUUVu1abHvgaOQx8Btd96qjNKsc9 OUgmzwTtxPY9ZNurqHncyXXCrtTnTFzmuGqUM9IXXrIOxJ41O4ZvEneJfqr39ySjTAB8 IUd1zGxxc+LR3IpJjloeT2nOkdlmosLQnLW7yCTPLgbv+mRkspKRhmvXtoQeXspyJ/2B k6zkTGiS/Q5BDGFm5+gzey8vggBnL3ZURT/NbB2wFXN1k+wn1bHfmVudngDUuD6nf/pr i9mQ== X-Gm-Message-State: AE9vXwPVbjeijNjHt95qjXzhb7+oetgA0vmfLVS7EBhG66x1VHvAwE6Ddeg++Ko69zl9DUKP 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 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 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> 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 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; } /*