From patchwork Sat Oct 8 04:23: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: 9367969 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 B883E60487 for ; Sat, 8 Oct 2016 04:23:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0B8D298B3 for ; Sat, 8 Oct 2016 04:23:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95A3829897; Sat, 8 Oct 2016 04:23: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=-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 3357E29897 for ; Sat, 8 Oct 2016 04:23:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754466AbcJHEXn (ORCPT ); Sat, 8 Oct 2016 00:23:43 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:35757 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752329AbcJHEX1 (ORCPT ); Sat, 8 Oct 2016 00:23:27 -0400 Received: by mail-pf0-f173.google.com with SMTP id 128so12995129pfz.2 for ; Fri, 07 Oct 2016 21:23:26 -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=MYvyJVGFafM36kJUFp1jasu0VCjR/7m4d+nT/IolBAY=; b=fAri2TIgeW0hg8Ostx4Qt51eRcbWo7lstj71wSrMolfu3KkQQgJpKto2psxdqE/gR2 n6TliXlN02Q3fvh+61PsUlWlW95sVjZOwjUIJ7Myi4tSsA6FDHdDS4zHxk7RwL6oPSYx p2Mt/Klvg417qUARfHb0Xlb16WEqb/pD1zJns= 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=MYvyJVGFafM36kJUFp1jasu0VCjR/7m4d+nT/IolBAY=; b=KuTHY/FJlZPIHErPy9nCp0/q1SHyN6TOv6sKtwlCRgFSjk3HEPanYoonHvOhTw5d43 hD0UMIMFMeAkWXOOoAsiCU69dIGi+bvga4bcQAX0D9eFgdJwpDE94CuKR0ZlS5FDVC/C vVonfbeB8zPjMFL8d+9pv+EoY31wnmQYHtvPhfq5O/MBTOMrVTYgc391J8bco/LOusAo fLVcM3/FGK2o9EwoaxmgImBbZPjhd6o+RTSkPsTDOJbFepHDEX4TkWPm5hitx7vp6oMq 5Z6lBLyXZJrUR4jI2itteNAc3A07NTiKBbGCygIRQvXvmrwROvC+t+C2e8pNXhhTbhtk p4mA== X-Gm-Message-State: AA6/9Rk7b5iDZ3ECp7X4q5u5XAvXXqWKe+YCUwr6JF47NAQ2yLo5bZLg6JjjjUbRPwOzzVZ0 X-Received: by 10.98.81.1 with SMTP id f1mr34976393pfb.35.1475900606010; Fri, 07 Oct 2016 21:23:26 -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 t67sm17537506pfd.32.2016.10.07.21.23.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Oct 2016 21:23:24 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: Jonathan Corbet , Linus Walleij , Marek Novak , Matteo Sartori , Michal Simek , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 3/5] rpmsg: Support drivers without primary endpoint Date: Fri, 7 Oct 2016 21:23:13 -0700 Message-Id: <1475900595-8375-3-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1475900595-8375-1-git-send-email-bjorn.andersson@linaro.org> References: <1475900595-8375-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 Some types of rpmsg drivers does not have a primary endpoint to tie their existence upon, but wishes to create and destroy endpoints dynamically, e.g. based on user interactions. Allow rpmsg drivers to omit a driver callback to signal this case and make the probe path not create a primary endpoint in this case. Signed-off-by: Bjorn Andersson --- drivers/rpmsg/rpmsg_core.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index 087d4db896c8..7561941ba413 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -347,27 +347,30 @@ static int rpmsg_dev_probe(struct device *dev) struct rpmsg_device *rpdev = to_rpmsg_device(dev); struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver); struct rpmsg_channel_info chinfo = {}; - struct rpmsg_endpoint *ept; + struct rpmsg_endpoint *ept = NULL; int err; - strncpy(chinfo.name, rpdev->id.name, RPMSG_NAME_SIZE); - chinfo.src = rpdev->src; - chinfo.dst = RPMSG_ADDR_ANY; + if (rpdrv->callback) { + strncpy(chinfo.name, rpdev->id.name, RPMSG_NAME_SIZE); + chinfo.src = rpdev->src; + chinfo.dst = RPMSG_ADDR_ANY; - ept = rpmsg_create_ept(rpdev, rpdrv->callback, NULL, chinfo); - if (!ept) { - dev_err(dev, "failed to create endpoint\n"); - err = -ENOMEM; - goto out; - } + ept = rpmsg_create_ept(rpdev, rpdrv->callback, NULL, chinfo); + if (!ept) { + dev_err(dev, "failed to create endpoint\n"); + err = -ENOMEM; + goto out; + } - rpdev->ept = ept; - rpdev->src = ept->addr; + rpdev->ept = ept; + rpdev->src = ept->addr; + } err = rpdrv->probe(rpdev); if (err) { dev_err(dev, "%s: failed: %d\n", __func__, err); - rpmsg_destroy_ept(ept); + if (ept) + rpmsg_destroy_ept(ept); goto out; } @@ -388,7 +391,8 @@ static int rpmsg_dev_remove(struct device *dev) rpdrv->remove(rpdev); - rpmsg_destroy_ept(rpdev->ept); + if (rpdev->ept) + rpmsg_destroy_ept(rpdev->ept); return err; }