Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3437338pxj; Mon, 7 Jun 2021 10:32:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgm75q8+HLmQpVSbWyQQCH6TM1n/gi0J1/0hisZTcS9C9C+CK7wzr1ILN2azPQPk0GimIv X-Received: by 2002:a17:907:1de6:: with SMTP id og38mr17806772ejc.471.1623087162673; Mon, 07 Jun 2021 10:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623087162; cv=none; d=google.com; s=arc-20160816; b=Ce5oZMSzLBsrIGlr8GTums/MOFva3MGhPRvgfd/zXI89h8zKO9P/4koADa23+9g5TR RgftTmlMPMlqT97piv9ZiZqI0KkLMjcFU1jpj7LxtHctoe4TtnnOnR7Wz1i+2Dyp30qG hYpK2OUFFg3jhJG9ETuiJOvZ2Sq59EXf7CO8HXqR2oTfICSuMfAVjpPqIi/VSg5pz020 tOI6fK9R6G8Fo9m2fznjcMD5Lz+uoyTG57A+Wx2c/A06N2YMeuPHZJ9n6229G+PM4I+n +QFfl+1VV+nJUY99BIAl9Wfh7jvqU34uoC8HdRaDWJaldFTNHH2Dug8Is+meFxn5NNen q/YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FpNn0xtfniShx67ksE/od2rMjnWYSm81fyLdm7GA7DM=; b=EtC3Xo8b6V2dBiem3/afSoq6Wgby1H4KyBFh7uuHbjcu36HEi53t1diS4GdOR1r2j/ 2R7In1+p8p5jxQL3dAJx6CPihN1mTg7LduEn9+7Rf1wAQhTvsemkcON96SAL6XDYocKn s5SDKgcQnvHqaS6TK/lcSJlMHjvfqkU5LALqbDnGXH9vdpKtQo1Qm0pe5uc0qPUX+YaE iv6Hwc4zV9nmbS1pS7wO5LnBW+3HHa8qaeliSwdhvJLC1PTSQwJAHZcYcMy/z+wEhyZY dr3mSRta0rctEwXVOsGmliTpF9KJP98dl9iSqE6nJD3x2bJ03yUKGXrlATpj8sa0oA+e An0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=nXmcTv9F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d10si12684748edq.351.2021.06.07.10.32.20; Mon, 07 Jun 2021 10:32:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=nXmcTv9F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231477AbhFGRcu (ORCPT + 99 others); Mon, 7 Jun 2021 13:32:50 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:47388 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbhFGRcn (ORCPT ); Mon, 7 Jun 2021 13:32:43 -0400 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 157HLXdr026586; Mon, 7 Jun 2021 19:30:40 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=FpNn0xtfniShx67ksE/od2rMjnWYSm81fyLdm7GA7DM=; b=nXmcTv9F1LTrC8z0VWEd4XCpOKC5BmzJnsOk25rd9r9Ctja45yoNTqpyri29W9OVQ8v/ HYPZe6PTfkxoNQaInJo7fVCH8Js1oWOBxMT/Py99usG4X7NEin6iZx0Kz5RstcKq0653 5ecO0WkuOAjfAq5JcOhhMnZ5Kzgp6FnZdn1FMgddBf9iqadSsoI6bbXNpNoPMOu6fYJO VT/1dQuCiye6JGsRak7xo+g/zwkQ6JP3JU2y7OrVL8dEGL4Qo80PaNSDHKYwZLcdonhs N3O9KKkNBUQzyBd2QjQYSrKd/3JL/tb2QAqQOIG3fnrn8N/m/rW43mlSesPUUFhIE90P Jw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 391ph88chu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Jun 2021 19:30:40 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EA31E100039; Mon, 7 Jun 2021 19:30:39 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id CD9D12142B6; Mon, 7 Jun 2021 19:30:39 +0200 (CEST) Received: from localhost (10.75.127.51) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 7 Jun 2021 19:30:39 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , , Subject: [PATCH 3/4] rpmsg: char: Introduce the "rpmsg-raw" channel Date: Mon, 7 Jun 2021 19:30:31 +0200 Message-ID: <20210607173032.30133-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210607173032.30133-1-arnaud.pouliquen@foss.st.com> References: <20210607173032.30133-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG2NODE1.st.com (10.75.127.4) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-06-07_14:2021-06-04,2021-06-07 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allows to probe the endpoint device on a remote name service announcement, by registering a rpmsg_driverfor the "rpmsg-raw" channel. With this patch the /dev/rpmsgX interface can be instantiated by the remote firmware. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 54 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 4199ac1bee10..3b850b218eb0 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -25,6 +25,8 @@ #include "rpmsg_char.h" +#define RPMSG_CHAR_DEVNAME "rpmsg-raw" + static dev_t rpmsg_major; static struct class *rpmsg_class; @@ -416,6 +418,40 @@ int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent } EXPORT_SYMBOL(rpmsg_chrdev_eptdev_create); +static int rpmsg_chrdev_probe(struct rpmsg_device *rpdev) +{ + struct rpmsg_channel_info chinfo; + + memcpy(chinfo.name, RPMSG_CHAR_DEVNAME, sizeof(RPMSG_CHAR_DEVNAME)); + chinfo.src = rpdev->src; + chinfo.dst = rpdev->dst; + + return __rpmsg_chrdev_eptdev_create(rpdev, &rpdev->dev, chinfo, true); +} + +static void rpmsg_chrdev_remove(struct rpmsg_device *rpdev) +{ + int ret; + + ret = device_for_each_child(&rpdev->dev, NULL, rpmsg_chrdev_eptdev_destroy); + if (ret) + dev_warn(&rpdev->dev, "failed to destroy endpoints: %d\n", ret); +} + +static struct rpmsg_device_id rpmsg_chrdev_id_table[] = { + { .name = RPMSG_CHAR_DEVNAME }, + { }, +}; + +static struct rpmsg_driver rpmsg_chrdev_driver = { + .probe = rpmsg_chrdev_probe, + .remove = rpmsg_chrdev_remove, + .id_table = rpmsg_chrdev_id_table, + .drv = { + .name = "rpmsg_chrdev", + }, +}; + static int rpmsg_chrdev_init(void) { int ret; @@ -429,16 +465,30 @@ static int rpmsg_chrdev_init(void) rpmsg_class = class_create(THIS_MODULE, "rpmsg"); if (IS_ERR(rpmsg_class)) { pr_err("failed to create rpmsg class\n"); - unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); - return PTR_ERR(rpmsg_class); + ret = PTR_ERR(rpmsg_class); + goto free_region; + } + + ret = register_rpmsg_driver(&rpmsg_chrdev_driver); + if (ret < 0) { + pr_err("rpmsg: failed to register rpmsg raw driver\n"); + goto free_class; } return 0; + +free_class: + class_destroy(rpmsg_class); +free_region: + unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); + + return ret; } postcore_initcall(rpmsg_chrdev_init); static void rpmsg_chrdev_exit(void) { + unregister_rpmsg_driver(&rpmsg_chrdev_driver); class_destroy(rpmsg_class); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); } -- 2.17.1