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

rpmsg: Introduce "poll" to endpoint ops

This allows rpmsg backends to implement polling of the outgoing buffer,
which provides poll support to user space when using the rpmsg character
device.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

+36
+20
drivers/rpmsg/rpmsg_core.c
··· 240 240 EXPORT_SYMBOL(rpmsg_trysendto); 241 241 242 242 /** 243 + * rpmsg_poll() - poll the endpoint's send buffers 244 + * @ept: the rpmsg endpoint 245 + * @filp: file for poll_wait() 246 + * @wait: poll_table for poll_wait() 247 + * 248 + * Returns mask representing the current state of the endpoint's send buffers 249 + */ 250 + unsigned int rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp, 251 + poll_table *wait) 252 + { 253 + if (WARN_ON(!ept)) 254 + return 0; 255 + if (!ept->ops->poll) 256 + return 0; 257 + 258 + return ept->ops->poll(ept, filp, wait); 259 + } 260 + EXPORT_SYMBOL(rpmsg_poll); 261 + 262 + /** 243 263 * rpmsg_send_offchannel() - send a message using explicit src/dst addresses 244 264 * @ept: the rpmsg endpoint 245 265 * @src: source address
+3
drivers/rpmsg/rpmsg_internal.h
··· 21 21 #define __RPMSG_INTERNAL_H__ 22 22 23 23 #include <linux/rpmsg.h> 24 + #include <linux/poll.h> 24 25 25 26 #define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev) 26 27 #define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv) ··· 71 70 int (*trysendto)(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); 72 71 int (*trysend_offchannel)(struct rpmsg_endpoint *ept, u32 src, u32 dst, 73 72 void *data, int len); 73 + unsigned int (*poll)(struct rpmsg_endpoint *ept, struct file *filp, 74 + poll_table *wait); 74 75 }; 75 76 76 77 int rpmsg_register_device(struct rpmsg_device *rpdev);
+13
include/linux/rpmsg.h
··· 41 41 #include <linux/mod_devicetable.h> 42 42 #include <linux/kref.h> 43 43 #include <linux/mutex.h> 44 + #include <linux/poll.h> 44 45 45 46 #define RPMSG_ADDR_ANY 0xFFFFFFFF 46 47 ··· 157 156 int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, 158 157 void *data, int len); 159 158 159 + unsigned int rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp, 160 + poll_table *wait); 161 + 160 162 #else 161 163 162 164 static inline int register_rpmsg_device(struct rpmsg_device *dev) ··· 256 252 WARN_ON(1); 257 253 258 254 return -ENXIO; 255 + } 256 + 257 + static inline unsigned int rpmsg_poll(struct rpmsg_endpoint *ept, 258 + struct file *filp, poll_table *wait) 259 + { 260 + /* This shouldn't be possible */ 261 + WARN_ON(1); 262 + 263 + return 0; 259 264 } 260 265 261 266 #endif /* IS_ENABLED(CONFIG_RPMSG) */