diff options
Diffstat (limited to 'include/linux/rpmsg.h')
-rw-r--r-- | include/linux/rpmsg.h | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index 9fdcfc7c7837..d54458effd54 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h | |||
@@ -96,8 +96,10 @@ enum rpmsg_ns_flags { | |||
96 | #define RPMSG_ADDR_ANY 0xFFFFFFFF | 96 | #define RPMSG_ADDR_ANY 0xFFFFFFFF |
97 | 97 | ||
98 | struct virtproc_info; | 98 | struct virtproc_info; |
99 | struct rpmsg_device; | ||
99 | struct rpmsg_endpoint; | 100 | struct rpmsg_endpoint; |
100 | struct rpmsg_device_ops; | 101 | struct rpmsg_device_ops; |
102 | struct rpmsg_endpoint_ops; | ||
101 | 103 | ||
102 | /** | 104 | /** |
103 | * struct rpmsg_channel_info - channel info representation | 105 | * struct rpmsg_channel_info - channel info representation |
@@ -184,6 +186,36 @@ struct rpmsg_endpoint { | |||
184 | struct mutex cb_lock; | 186 | struct mutex cb_lock; |
185 | u32 addr; | 187 | u32 addr; |
186 | void *priv; | 188 | void *priv; |
189 | |||
190 | const struct rpmsg_endpoint_ops *ops; | ||
191 | }; | ||
192 | |||
193 | /** | ||
194 | * struct rpmsg_endpoint_ops - indirection table for rpmsg_endpoint operations | ||
195 | * @destroy_ept: destroy the given endpoint, required | ||
196 | * @send: see @rpmsg_send(), required | ||
197 | * @sendto: see @rpmsg_sendto(), optional | ||
198 | * @send_offchannel: see @rpmsg_send_offchannel(), optional | ||
199 | * @trysend: see @rpmsg_trysend(), required | ||
200 | * @trysendto: see @rpmsg_trysendto(), optional | ||
201 | * @trysend_offchannel: see @rpmsg_trysend_offchannel(), optional | ||
202 | * | ||
203 | * Indirection table for the operations that a rpmsg backend should implement. | ||
204 | * In addition to @destroy_ept, the backend must at least implement @send and | ||
205 | * @trysend, while the variants sending data off-channel are optional. | ||
206 | */ | ||
207 | struct rpmsg_endpoint_ops { | ||
208 | void (*destroy_ept)(struct rpmsg_endpoint *ept); | ||
209 | |||
210 | int (*send)(struct rpmsg_endpoint *ept, void *data, int len); | ||
211 | int (*sendto)(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); | ||
212 | int (*send_offchannel)(struct rpmsg_endpoint *ept, u32 src, u32 dst, | ||
213 | void *data, int len); | ||
214 | |||
215 | int (*trysend)(struct rpmsg_endpoint *ept, void *data, int len); | ||
216 | int (*trysendto)(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); | ||
217 | int (*trysend_offchannel)(struct rpmsg_endpoint *ept, u32 src, u32 dst, | ||
218 | void *data, int len); | ||
187 | }; | 219 | }; |
188 | 220 | ||
189 | /** | 221 | /** |
@@ -210,8 +242,6 @@ void rpmsg_destroy_ept(struct rpmsg_endpoint *); | |||
210 | struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *, | 242 | struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *, |
211 | rpmsg_rx_cb_t cb, void *priv, | 243 | rpmsg_rx_cb_t cb, void *priv, |
212 | struct rpmsg_channel_info chinfo); | 244 | struct rpmsg_channel_info chinfo); |
213 | int | ||
214 | rpmsg_send_offchannel_raw(struct rpmsg_device *, u32, u32, void *, int, bool); | ||
215 | 245 | ||
216 | /* use a macro to avoid include chaining to get THIS_MODULE */ | 246 | /* use a macro to avoid include chaining to get THIS_MODULE */ |
217 | #define register_rpmsg_driver(drv) \ | 247 | #define register_rpmsg_driver(drv) \ |
@@ -249,10 +279,7 @@ rpmsg_send_offchannel_raw(struct rpmsg_device *, u32, u32, void *, int, bool); | |||
249 | */ | 279 | */ |
250 | static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len) | 280 | static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len) |
251 | { | 281 | { |
252 | struct rpmsg_device *rpdev = ept->rpdev; | 282 | return ept->ops->send(ept, data, len); |
253 | u32 src = ept->addr, dst = rpdev->dst; | ||
254 | |||
255 | return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); | ||
256 | } | 283 | } |
257 | 284 | ||
258 | /** | 285 | /** |
@@ -276,10 +303,7 @@ static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len) | |||
276 | static inline | 303 | static inline |
277 | int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) | 304 | int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) |
278 | { | 305 | { |
279 | struct rpmsg_device *rpdev = ept->rpdev; | 306 | return ept->ops->sendto(ept, data, len, dst); |
280 | u32 src = ept->addr; | ||
281 | |||
282 | return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); | ||
283 | } | 307 | } |
284 | 308 | ||
285 | /** | 309 | /** |
@@ -306,9 +330,7 @@ static inline | |||
306 | int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, | 330 | int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, |
307 | void *data, int len) | 331 | void *data, int len) |
308 | { | 332 | { |
309 | struct rpmsg_device *rpdev = ept->rpdev; | 333 | return ept->ops->send_offchannel(ept, src, dst, data, len); |
310 | |||
311 | return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); | ||
312 | } | 334 | } |
313 | 335 | ||
314 | /** | 336 | /** |
@@ -331,10 +353,7 @@ int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, | |||
331 | static inline | 353 | static inline |
332 | int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len) | 354 | int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len) |
333 | { | 355 | { |
334 | struct rpmsg_device *rpdev = ept->rpdev; | 356 | return ept->ops->trysend(ept, data, len); |
335 | u32 src = ept->addr, dst = rpdev->dst; | ||
336 | |||
337 | return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); | ||
338 | } | 357 | } |
339 | 358 | ||
340 | /** | 359 | /** |
@@ -357,10 +376,7 @@ int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len) | |||
357 | static inline | 376 | static inline |
358 | int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) | 377 | int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) |
359 | { | 378 | { |
360 | struct rpmsg_device *rpdev = ept->rpdev; | 379 | return ept->ops->trysendto(ept, data, len, dst); |
361 | u32 src = ept->addr; | ||
362 | |||
363 | return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); | ||
364 | } | 380 | } |
365 | 381 | ||
366 | /** | 382 | /** |
@@ -386,9 +402,7 @@ static inline | |||
386 | int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, | 402 | int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, |
387 | void *data, int len) | 403 | void *data, int len) |
388 | { | 404 | { |
389 | struct rpmsg_device *rpdev = ept->rpdev; | 405 | return ept->ops->trysend_offchannel(ept, src, dst, data, len); |
390 | |||
391 | return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); | ||
392 | } | 406 | } |
393 | 407 | ||
394 | #endif /* _LINUX_RPMSG_H */ | 408 | #endif /* _LINUX_RPMSG_H */ |