From patchwork Mon Dec 18 22:02:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Lew X-Patchwork-Id: 10121965 X-Patchwork-Delegate: agross@codeaurora.org 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 CD92760327 for ; Mon, 18 Dec 2017 22:03:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFF5826CFC for ; Mon, 18 Dec 2017 22:03:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4FE028B44; Mon, 18 Dec 2017 22:03:21 +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=unavailable 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 6407226CFC for ; Mon, 18 Dec 2017 22:03:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965667AbdLRWDT (ORCPT ); Mon, 18 Dec 2017 17:03:19 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:51752 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937850AbdLRWCZ (ORCPT ); Mon, 18 Dec 2017 17:02:25 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B14C66079C; Mon, 18 Dec 2017 22:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1513634544; bh=trXSQjQK2SbqICkES27KLGNOIv/JyNn1qxquqjvkZnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U0gJ1IomY88nYZCRafceJ06NB8gzNv3+2vfXhU0WpZgspFybXBHWwM25GKDzMLa55 PpU7wjoeFhfa9L6maZpltzEDQ0Qbg9KJSFMhOaRnoCqcevTtr31cysVQJhwjQCX82e bNWwOHksJECNo46jyEbtOGdU/QWPbMeegnGDTUUE= Received: from clew-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: clew@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id C1C746070B; Mon, 18 Dec 2017 22:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1513634544; bh=trXSQjQK2SbqICkES27KLGNOIv/JyNn1qxquqjvkZnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U0gJ1IomY88nYZCRafceJ06NB8gzNv3+2vfXhU0WpZgspFybXBHWwM25GKDzMLa55 PpU7wjoeFhfa9L6maZpltzEDQ0Qbg9KJSFMhOaRnoCqcevTtr31cysVQJhwjQCX82e bNWwOHksJECNo46jyEbtOGdU/QWPbMeegnGDTUUE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C1C746070B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=clew@codeaurora.org From: Chris Lew To: bjorn.andersson@linaro.org, robh+dt@kernel.org, andy.gross@linaro.org, david.brown@linaro.org Cc: aneela@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, clew@codeaurora.org Subject: [PATCH 3/6] rpmsg: glink: Add support for rpmsg glink chrdev Date: Mon, 18 Dec 2017 14:02:11 -0800 Message-Id: <1513634534-22861-4-git-send-email-clew@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1513634534-22861-1-git-send-email-clew@codeaurora.org> References: <1513634534-22861-1-git-send-email-clew@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP RPMSG provides a char device interface to userspace. Probe the rpmsg chrdev channel to enable the rpmsg_ctrl device creation on glink transports. Signed-off-by: Chris Lew --- drivers/rpmsg/qcom_glink_native.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 179132226dc2..786f2eca01f1 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -132,6 +132,13 @@ enum { GLINK_STATE_CLOSING, }; +struct qcom_glink_device { + struct rpmsg_device rpdev; + struct qcom_glink *glink; +}; + +#define to_glink_device(_x) container_of(_x, struct qcom_glink_device, rpdev) + /** * struct glink_channel - internal representation of a channel * @rpdev: rpdev reference, only used for primary endpoints @@ -1339,6 +1346,10 @@ static struct device_node *qcom_glink_match_channel(struct device_node *node, return NULL; } +static const struct rpmsg_device_ops glink_chrdev_ops = { + .create_ept = qcom_glink_create_ept, +}; + static const struct rpmsg_device_ops glink_device_ops = { .create_ept = qcom_glink_create_ept, .announce_create = qcom_glink_announce_create, @@ -1547,6 +1558,30 @@ static void qcom_glink_work(struct work_struct *work) } } +static void qcom_glink_device_release(struct device *dev) +{ + struct rpmsg_device *rpdev = to_rpmsg_device(dev); + struct qcom_glink_device *gdev = to_glink_device(rpdev); + + kfree(gdev); +} + +static int qcom_glink_create_chrdev(struct qcom_glink *glink) +{ + struct qcom_glink_device *gdev; + + gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); + if (!gdev) + return -ENOMEM; + + gdev->glink = glink; + gdev->rpdev.ops = &glink_chrdev_ops; + gdev->rpdev.dev.parent = glink->dev; + gdev->rpdev.dev.release = qcom_glink_device_release; + + return rpmsg_chrdev_register_device(&gdev->rpdev); +} + struct qcom_glink *qcom_glink_native_probe(struct device *dev, unsigned long features, struct qcom_glink_pipe *rx, @@ -1605,6 +1640,10 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev, if (ret) return ERR_PTR(ret); + ret = qcom_glink_create_chrdev(glink); + if (ret) + dev_err(glink->dev, "failed to register chrdev\n"); + return glink; } EXPORT_SYMBOL_GPL(qcom_glink_native_probe);