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: 77377 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp501273qge; Fri, 7 Oct 2016 21:23:53 -0700 (PDT) X-Received: by 10.98.12.4 with SMTP id u4mr24833145pfi.80.1475900633270; Fri, 07 Oct 2016 21:23:53 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yn6si19913222pab.271.2016.10.07.21.23.53; Fri, 07 Oct 2016 21:23:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754596AbcJHEXp (ORCPT + 9 others); Sat, 8 Oct 2016 00:23:45 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:36539 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752291AbcJHEX1 (ORCPT ); Sat, 8 Oct 2016 00:23:27 -0400 Received: by mail-pf0-f169.google.com with SMTP id i85so31716035pfa.3 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=F89HLpNesRuLMkq0rlR+NfTWUv447ZCmCPqU6icF1FvZYVvYvm2x0FQPcwNF01aMiO v8tCKn1rHGB4fBUfe9GuEPq58FRHXlxrz8L2eMZzwtQ3F9HdNy+9ZHR26r+gInzC/ksC WFGGviW6OCqccHNVPwrI5NU4VOhIkKoNzzwB3ytMkKY8MudESJj0B040wownJjoC0n57 T/q4ujCW+b5JR7o2CyyWoBQ1X7Qj8dPIaXgY2dR8htanlGZzH7uz4o+4be87ieRG28VM sF7qz7UN/on2zY3e/JwySpYu4O/O5BY5/ggEh/KOMhiHwOcVNxChQBDfx0tq5Bia00Dv 2Ivg== X-Gm-Message-State: AA6/9RkPy8nvrhit6zvv/yYMA3WMOOCCk6/zTo1jB7/aJwWwfT9WaWxQyWuM9/BsATpr9nWo 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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(-) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; }