From patchwork Fri Aug 12 23:42:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 73873 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp405896qga; Fri, 12 Aug 2016 16:42:58 -0700 (PDT) X-Received: by 10.98.99.67 with SMTP id x64mr31888190pfb.26.1471045378273; Fri, 12 Aug 2016 16:42:58 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si11274118pag.125.2016.08.12.16.42.58; Fri, 12 Aug 2016 16:42:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752895AbcHLXmm (ORCPT + 27 others); Fri, 12 Aug 2016 19:42:42 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:54314 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752630AbcHLXmg (ORCPT ); Fri, 12 Aug 2016 19:42:36 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id u7CNgZJY012456; Fri, 12 Aug 2016 18:42:35 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id u7CNgYR7026299; Fri, 12 Aug 2016 18:42:34 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.294.0; Fri, 12 Aug 2016 18:42:33 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u7CNgX9h013166; Fri, 12 Aug 2016 18:42:33 -0500 Received: from localhost (irmo.am.dhcp.ti.com [128.247.83.68]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id u7CNgX306378; Fri, 12 Aug 2016 18:42:33 -0500 (CDT) From: Suman Anna To: Bjorn Andersson CC: Ohad Ben-Cohen , , , Suman Anna Subject: [PATCH 13/13] samples/rpmsg: add support for multiple instances Date: Fri, 12 Aug 2016 18:42:28 -0500 Message-ID: <20160812234228.39731-14-s-anna@ti.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160812234228.39731-1-s-anna@ti.com> References: <20160812234228.39731-1-s-anna@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current rpmsg_client_sample is a very simple example and is not designed to handle multiple instances. Add support for multiple instances, so that the same number of pings are sent to each instance. The instances can be on one or multiple remote processors. Signed-off-by: Suman Anna --- samples/rpmsg/rpmsg_client_sample.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) -- 2.9.0 diff --git a/samples/rpmsg/rpmsg_client_sample.c b/samples/rpmsg/rpmsg_client_sample.c index d0e249c90668..7e17d1c0aaf2 100644 --- a/samples/rpmsg/rpmsg_client_sample.c +++ b/samples/rpmsg/rpmsg_client_sample.c @@ -24,19 +24,24 @@ #define MSG "hello world!" #define MSG_LIMIT 100 +struct instance_data { + int rx_count; +}; + static void rpmsg_sample_cb(struct rpmsg_channel *rpdev, void *data, int len, void *priv, u32 src) { int ret; - static int rx_count; + struct instance_data *idata = dev_get_drvdata(&rpdev->dev); - dev_info(&rpdev->dev, "incoming msg %d (src: 0x%x)\n", ++rx_count, src); + dev_info(&rpdev->dev, "incoming msg %d (src: 0x%x)\n", + ++idata->rx_count, src); print_hex_dump(KERN_DEBUG, __func__, DUMP_PREFIX_NONE, 16, 1, data, len, true); /* samples should not live forever */ - if (rx_count >= MSG_LIMIT) { + if (idata->rx_count >= MSG_LIMIT) { dev_info(&rpdev->dev, "goodbye!\n"); return; } @@ -50,10 +55,17 @@ static void rpmsg_sample_cb(struct rpmsg_channel *rpdev, void *data, int len, static int rpmsg_sample_probe(struct rpmsg_channel *rpdev) { int ret; + struct instance_data *idata; dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n", rpdev->src, rpdev->dst); + idata = devm_kzalloc(&rpdev->dev, sizeof(*idata), GFP_KERNEL); + if (!idata) + return -ENOMEM; + + dev_set_drvdata(&rpdev->dev, idata); + /* send a message to our remote processor */ ret = rpmsg_send(rpdev, MSG, strlen(MSG)); if (ret) {