aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@linaro.org>2016-09-01 18:28:08 -0400
committerBjorn Andersson <bjorn.andersson@linaro.org>2016-09-09 01:15:25 -0400
commit4b83c52a21cf5a7421b7c28bebf8ff28ba96ceb9 (patch)
tree750fbb5bb454ea00c2ea96859e08134cb50457bf
parente88dae5da46d3989fd6a83dd9f6806777b20d1ae (diff)
rpmsg: Allow callback to return errors
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 <bjorn.andersson@linaro.org>
-rw-r--r--drivers/rpmsg/virtio_rpmsg_bus.c10
-rw-r--r--include/linux/rpmsg.h4
-rw-r--r--samples/rpmsg/rpmsg_client_sample.c6
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)
791} 791}
792 792
793/* invoked when a name service announcement arrives */ 793/* invoked when a name service announcement arrives */
794static void rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, 794static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,
795 void *priv, u32 src) 795 void *priv, u32 src)
796{ 796{
797 struct rpmsg_ns_msg *msg = data; 797 struct rpmsg_ns_msg *msg = data;
798 struct rpmsg_device *newch; 798 struct rpmsg_device *newch;
@@ -808,7 +808,7 @@ static void rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,
808 808
809 if (len != sizeof(*msg)) { 809 if (len != sizeof(*msg)) {
810 dev_err(dev, "malformed ns msg (%d)\n", len); 810 dev_err(dev, "malformed ns msg (%d)\n", len);
811 return; 811 return -EINVAL;
812 } 812 }
813 813
814 /* 814 /*
@@ -819,7 +819,7 @@ static void rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,
819 */ 819 */
820 if (rpdev) { 820 if (rpdev) {
821 dev_err(dev, "anomaly: ns ept has an rpdev handle\n"); 821 dev_err(dev, "anomaly: ns ept has an rpdev handle\n");
822 return; 822 return -EINVAL;
823 } 823 }
824 824
825 /* don't trust the remote processor for null terminating the name */ 825 /* 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,
842 if (!newch) 842 if (!newch)
843 dev_err(dev, "rpmsg_create_channel failed\n"); 843 dev_err(dev, "rpmsg_create_channel failed\n");
844 } 844 }
845
846 return 0;
845} 847}
846 848
847static int rpmsg_probe(struct virtio_device *vdev) 849static 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 {
80 const struct rpmsg_device_ops *ops; 80 const struct rpmsg_device_ops *ops;
81}; 81};
82 82
83typedef void (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32); 83typedef int (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32);
84 84
85/** 85/**
86 * struct rpmsg_endpoint - binds a local rpmsg address to its user 86 * struct rpmsg_endpoint - binds a local rpmsg address to its user
@@ -129,7 +129,7 @@ struct rpmsg_driver {
129 const struct rpmsg_device_id *id_table; 129 const struct rpmsg_device_id *id_table;
130 int (*probe)(struct rpmsg_device *dev); 130 int (*probe)(struct rpmsg_device *dev);
131 void (*remove)(struct rpmsg_device *dev); 131 void (*remove)(struct rpmsg_device *dev);
132 void (*callback)(struct rpmsg_device *, void *, int, void *, u32); 132 int (*callback)(struct rpmsg_device *, void *, int, void *, u32);
133}; 133};
134 134
135int register_rpmsg_device(struct rpmsg_device *dev); 135int 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 {
28 int rx_count; 28 int rx_count;
29}; 29};
30 30
31static void rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, 31static int rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len,
32 void *priv, u32 src) 32 void *priv, u32 src)
33{ 33{
34 int ret; 34 int ret;
@@ -43,13 +43,15 @@ static void rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len,
43 /* samples should not live forever */ 43 /* samples should not live forever */
44 if (idata->rx_count >= MSG_LIMIT) { 44 if (idata->rx_count >= MSG_LIMIT) {
45 dev_info(&rpdev->dev, "goodbye!\n"); 45 dev_info(&rpdev->dev, "goodbye!\n");
46 return; 46 return 0;
47 } 47 }
48 48
49 /* send a new message now */ 49 /* send a new message now */
50 ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG)); 50 ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG));
51 if (ret) 51 if (ret)
52 dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret); 52 dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret);
53
54 return 0;
53} 55}
54 56
55static int rpmsg_sample_probe(struct rpmsg_device *rpdev) 57static int rpmsg_sample_probe(struct rpmsg_device *rpdev)