Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+12 -8
+6 -4
drivers/rpmsg/virtio_rpmsg_bus.c
··· 791 791 } 792 792 793 793 /* invoked when a name service announcement arrives */ 794 - static void rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, 795 - void *priv, u32 src) 794 + static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, 795 + void *priv, u32 src) 796 796 { 797 797 struct rpmsg_ns_msg *msg = data; 798 798 struct rpmsg_device *newch; ··· 808 808 809 809 if (len != sizeof(*msg)) { 810 810 dev_err(dev, "malformed ns msg (%d)\n", len); 811 - return; 811 + return -EINVAL; 812 812 } 813 813 814 814 /* ··· 819 819 */ 820 820 if (rpdev) { 821 821 dev_err(dev, "anomaly: ns ept has an rpdev handle\n"); 822 - return; 822 + return -EINVAL; 823 823 } 824 824 825 825 /* don't trust the remote processor for null terminating the name */ ··· 842 842 if (!newch) 843 843 dev_err(dev, "rpmsg_create_channel failed\n"); 844 844 } 845 + 846 + return 0; 845 847 } 846 848 847 849 static int rpmsg_probe(struct virtio_device *vdev)
+2 -2
include/linux/rpmsg.h
··· 80 80 const struct rpmsg_device_ops *ops; 81 81 }; 82 82 83 - typedef void (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32); 83 + typedef int (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32); 84 84 85 85 /** 86 86 * struct rpmsg_endpoint - binds a local rpmsg address to its user ··· 129 129 const struct rpmsg_device_id *id_table; 130 130 int (*probe)(struct rpmsg_device *dev); 131 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 135 135 int register_rpmsg_device(struct rpmsg_device *dev);
+4 -2
samples/rpmsg/rpmsg_client_sample.c
··· 28 28 int rx_count; 29 29 }; 30 30 31 - static void rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, 31 + static int rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, 32 32 void *priv, u32 src) 33 33 { 34 34 int ret; ··· 43 43 /* samples should not live forever */ 44 44 if (idata->rx_count >= MSG_LIMIT) { 45 45 dev_info(&rpdev->dev, "goodbye!\n"); 46 - return; 46 + return 0; 47 47 } 48 48 49 49 /* send a new message now */ 50 50 ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG)); 51 51 if (ret) 52 52 dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret); 53 + 54 + return 0; 53 55 } 54 56 55 57 static int rpmsg_sample_probe(struct rpmsg_device *rpdev)