From patchwork Thu Sep 1 22:28:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9310039 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 7BAAE60756 for ; Thu, 1 Sep 2016 22:35:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 346062955E for ; Thu, 1 Sep 2016 22:35:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 294B629562; Thu, 1 Sep 2016 22:35:56 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A664B2955E for ; Thu, 1 Sep 2016 22:35:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bfaYq-0008Lt-Fn; Thu, 01 Sep 2016 22:34:16 +0000 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bfaTX-0002F9-S3 for linux-arm-kernel@lists.infradead.org; Thu, 01 Sep 2016 22:28:51 +0000 Received: by mail-pa0-x22a.google.com with SMTP id cy9so33877852pac.0 for ; Thu, 01 Sep 2016 15:28:31 -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=lN+wAJ8E0xXXY+GMek1Au5qczjcq2mLChtN74WrR7WQ=; b=YkElx7a4LoZiPyoGjXWGCSYyhge8HE6kMgYdjoCXurT7q0DocifwcJUc5V3uim/tLx 1Hcoa2W4J+vieFKjwcmLYfVMW1DHry/DHgVziWAE50fH1dMAeE/5hsH6Nxo/o7xChElU RKQfD3McSbRRwJ5atlw3MRQJHSGHHZmTOPQf4= 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=lN+wAJ8E0xXXY+GMek1Au5qczjcq2mLChtN74WrR7WQ=; b=VlJRq9XKLVeN7iFgt2DcSZq7rwuTMNfXW6NzfwsRdkULHa2L2AY9bjlJcUOL2LIKmy p7dl5a+ORjbwIQt67bxhgv3GYwigN/uay6k0dcf+yCbAtaTJiNpB+UYFYk6/zXk2M890 4Vn+tJ4HDh70VRLwo/bmb7/A3b/cXaOthOfCX0aVUuTNR27Babv/5YQTeW5zwU4Vn7Pm HcSCDYQWKzra49QTGWSjvcAvWcPE1jdNq/703QXA9uwzFcgM//VhEpRZjHfs159Fhhax +0ZrHowg+spW+ZgVEEy00qCfkFBxkIrua4+EAUijrHXpxr9AV94HFvaAXXaC5YkHViKk ZC8Q== X-Gm-Message-State: AE9vXwOHqLD/g2lqwRPA/6BPT5ATVfpHwd2gWWbwoNoeee2hCXtT3QYRhnjyCl7xZaePyMGA X-Received: by 10.66.242.166 with SMTP id wr6mr30669516pac.147.1472768911148; Thu, 01 Sep 2016 15:28:31 -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 iw10sm8887131pac.14.2016.09.01.15.28.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Sep 2016 15:28:30 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Subject: [PATCH v2 16/17] rpmsg: Allow callback to return errors Date: Thu, 1 Sep 2016 15:28:08 -0700 Message-Id: <1472768889-3906-17-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1472768889-3906-1-git-send-email-bjorn.andersson@linaro.org> References: <1472768889-3906-1-git-send-email-bjorn.andersson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160901_152848_163209_C0872277 X-CRM114-Status: GOOD ( 16.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some rpmsg backends support holding on to and redelivering messages upon failed handling of them, so provide a way for the callback to report and error and allow the backends to handle this. Signed-off-by: Bjorn Andersson --- Changes since v1: - None drivers/rpmsg/virtio_rpmsg_bus.c | 10 ++++++---- include/linux/rpmsg.h | 4 ++-- samples/rpmsg/rpmsg_client_sample.c | 6 ++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 671cb1803431..3090b0d3072f 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -791,8 +791,8 @@ static void rpmsg_xmit_done(struct virtqueue *svq) } /* invoked when a name service announcement arrives */ -static void rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, - void *priv, u32 src) +static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, + void *priv, u32 src) { struct rpmsg_ns_msg *msg = data; struct rpmsg_device *newch; @@ -808,7 +808,7 @@ static void rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, if (len != sizeof(*msg)) { dev_err(dev, "malformed ns msg (%d)\n", len); - return; + return -EINVAL; } /* @@ -819,7 +819,7 @@ static void rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, */ if (rpdev) { dev_err(dev, "anomaly: ns ept has an rpdev handle\n"); - return; + return -EINVAL; } /* don't trust the remote processor for null terminating the name */ @@ -842,6 +842,8 @@ static void rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, if (!newch) dev_err(dev, "rpmsg_create_channel failed\n"); } + + return 0; } static int rpmsg_probe(struct virtio_device *vdev) diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index 71b16d37503a..452d393cc8dd 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -80,7 +80,7 @@ struct rpmsg_device { const struct rpmsg_device_ops *ops; }; -typedef void (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32); +typedef int (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32); /** * struct rpmsg_endpoint - binds a local rpmsg address to its user @@ -129,7 +129,7 @@ struct rpmsg_driver { const struct rpmsg_device_id *id_table; int (*probe)(struct rpmsg_device *dev); void (*remove)(struct rpmsg_device *dev); - void (*callback)(struct rpmsg_device *, void *, int, void *, u32); + int (*callback)(struct rpmsg_device *, void *, int, void *, u32); }; int register_rpmsg_device(struct rpmsg_device *dev); diff --git a/samples/rpmsg/rpmsg_client_sample.c b/samples/rpmsg/rpmsg_client_sample.c index 4fcd7ee13fb9..f161dfd3e70a 100644 --- a/samples/rpmsg/rpmsg_client_sample.c +++ b/samples/rpmsg/rpmsg_client_sample.c @@ -28,7 +28,7 @@ struct instance_data { int rx_count; }; -static void rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, +static int rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, void *priv, u32 src) { int ret; @@ -43,13 +43,15 @@ static void rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, /* samples should not live forever */ if (idata->rx_count >= MSG_LIMIT) { dev_info(&rpdev->dev, "goodbye!\n"); - return; + return 0; } /* send a new message now */ ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG)); if (ret) dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret); + + return 0; } static int rpmsg_sample_probe(struct rpmsg_device *rpdev)