aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/rpmsg/rpmsg_core.c160
-rw-r--r--drivers/rpmsg/virtio_rpmsg_bus.c13
-rw-r--r--include/linux/rpmsg.h148
3 files changed, 166 insertions, 155 deletions
diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
index c511b5d64f89..3bee8e03a387 100644
--- a/drivers/rpmsg/rpmsg_core.c
+++ b/drivers/rpmsg/rpmsg_core.c
@@ -69,3 +69,163 @@ struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev,
69 return rpdev->ops->create_ept(rpdev, cb, priv, chinfo); 69 return rpdev->ops->create_ept(rpdev, cb, priv, chinfo);
70} 70}
71EXPORT_SYMBOL(rpmsg_create_ept); 71EXPORT_SYMBOL(rpmsg_create_ept);
72
73/**
74 * rpmsg_destroy_ept() - destroy an existing rpmsg endpoint
75 * @ept: endpoing to destroy
76 *
77 * Should be used by drivers to destroy an rpmsg endpoint previously
78 * created with rpmsg_create_ept().
79 */
80void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
81{
82 ept->ops->destroy_ept(ept);
83}
84EXPORT_SYMBOL(rpmsg_destroy_ept);
85
86/**
87 * rpmsg_send() - send a message across to the remote processor
88 * @ept: the rpmsg endpoint
89 * @data: payload of message
90 * @len: length of payload
91 *
92 * This function sends @data of length @len on the @ept endpoint.
93 * The message will be sent to the remote processor which the @ept
94 * endpoint belongs to, using @ept's address and its associated rpmsg
95 * device destination addresses.
96 * In case there are no TX buffers available, the function will block until
97 * one becomes available, or a timeout of 15 seconds elapses. When the latter
98 * happens, -ERESTARTSYS is returned.
99 *
100 * Can only be called from process context (for now).
101 *
102 * Returns 0 on success and an appropriate error value on failure.
103 */
104int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len)
105{
106 return ept->ops->send(ept, data, len);
107}
108EXPORT_SYMBOL(rpmsg_send);
109
110/**
111 * rpmsg_sendto() - send a message across to the remote processor, specify dst
112 * @ept: the rpmsg endpoint
113 * @data: payload of message
114 * @len: length of payload
115 * @dst: destination address
116 *
117 * This function sends @data of length @len to the remote @dst address.
118 * The message will be sent to the remote processor which the @ept
119 * endpoint belongs to, using @ept's address as source.
120 * In case there are no TX buffers available, the function will block until
121 * one becomes available, or a timeout of 15 seconds elapses. When the latter
122 * happens, -ERESTARTSYS is returned.
123 *
124 * Can only be called from process context (for now).
125 *
126 * Returns 0 on success and an appropriate error value on failure.
127 */
128int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst)
129{
130 return ept->ops->sendto(ept, data, len, dst);
131}
132EXPORT_SYMBOL(rpmsg_sendto);
133
134/**
135 * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
136 * @ept: the rpmsg endpoint
137 * @src: source address
138 * @dst: destination address
139 * @data: payload of message
140 * @len: length of payload
141 *
142 * This function sends @data of length @len to the remote @dst address,
143 * and uses @src as the source address.
144 * The message will be sent to the remote processor which the @ept
145 * endpoint belongs to.
146 * In case there are no TX buffers available, the function will block until
147 * one becomes available, or a timeout of 15 seconds elapses. When the latter
148 * happens, -ERESTARTSYS is returned.
149 *
150 * Can only be called from process context (for now).
151 *
152 * Returns 0 on success and an appropriate error value on failure.
153 */
154int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
155 void *data, int len)
156{
157 return ept->ops->send_offchannel(ept, src, dst, data, len);
158}
159EXPORT_SYMBOL(rpmsg_send_offchannel);
160
161/**
162 * rpmsg_send() - send a message across to the remote processor
163 * @ept: the rpmsg endpoint
164 * @data: payload of message
165 * @len: length of payload
166 *
167 * This function sends @data of length @len on the @ept endpoint.
168 * The message will be sent to the remote processor which the @ept
169 * endpoint belongs to, using @ept's address as source and its associated
170 * rpdev's address as destination.
171 * In case there are no TX buffers available, the function will immediately
172 * return -ENOMEM without waiting until one becomes available.
173 *
174 * Can only be called from process context (for now).
175 *
176 * Returns 0 on success and an appropriate error value on failure.
177 */
178int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len)
179{
180 return ept->ops->trysend(ept, data, len);
181}
182EXPORT_SYMBOL(rpmsg_trysend);
183
184/**
185 * rpmsg_sendto() - send a message across to the remote processor, specify dst
186 * @ept: the rpmsg endpoint
187 * @data: payload of message
188 * @len: length of payload
189 * @dst: destination address
190 *
191 * This function sends @data of length @len to the remote @dst address.
192 * The message will be sent to the remote processor which the @ept
193 * endpoint belongs to, using @ept's address as source.
194 * In case there are no TX buffers available, the function will immediately
195 * return -ENOMEM without waiting until one becomes available.
196 *
197 * Can only be called from process context (for now).
198 *
199 * Returns 0 on success and an appropriate error value on failure.
200 */
201int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst)
202{
203 return ept->ops->trysendto(ept, data, len, dst);
204}
205EXPORT_SYMBOL(rpmsg_trysendto);
206
207/**
208 * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
209 * @ept: the rpmsg endpoint
210 * @src: source address
211 * @dst: destination address
212 * @data: payload of message
213 * @len: length of payload
214 *
215 * This function sends @data of length @len to the remote @dst address,
216 * and uses @src as the source address.
217 * The message will be sent to the remote processor which the @ept
218 * endpoint belongs to.
219 * In case there are no TX buffers available, the function will immediately
220 * return -ENOMEM without waiting until one becomes available.
221 *
222 * Can only be called from process context (for now).
223 *
224 * Returns 0 on success and an appropriate error value on failure.
225 */
226int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
227 void *data, int len)
228{
229 return ept->ops->trysend_offchannel(ept, src, dst, data, len);
230}
231EXPORT_SYMBOL(rpmsg_trysend_offchannel);
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index e5f256791fd3..184663276e51 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -299,19 +299,6 @@ __rpmsg_destroy_ept(struct virtproc_info *vrp, struct rpmsg_endpoint *ept)
299 kref_put(&ept->refcount, __ept_release); 299 kref_put(&ept->refcount, __ept_release);
300} 300}
301 301
302/**
303 * rpmsg_destroy_ept() - destroy an existing rpmsg endpoint
304 * @ept: endpoing to destroy
305 *
306 * Should be used by drivers to destroy an rpmsg endpoint previously
307 * created with rpmsg_create_ept().
308 */
309void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
310{
311 ept->ops->destroy_ept(ept);
312}
313EXPORT_SYMBOL(rpmsg_destroy_ept);
314
315static void virtio_rpmsg_destroy_ept(struct rpmsg_endpoint *ept) 302static void virtio_rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
316{ 303{
317 __rpmsg_destroy_ept(ept->rpdev->vrp, ept); 304 __rpmsg_destroy_ept(ept->rpdev->vrp, ept);
diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h
index d54458effd54..99efd598590e 100644
--- a/include/linux/rpmsg.h
+++ b/include/linux/rpmsg.h
@@ -259,150 +259,14 @@ struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *,
259 module_driver(__rpmsg_driver, register_rpmsg_driver, \ 259 module_driver(__rpmsg_driver, register_rpmsg_driver, \
260 unregister_rpmsg_driver) 260 unregister_rpmsg_driver)
261 261
262/** 262int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len);
263 * rpmsg_send() - send a message across to the remote processor 263int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);
264 * @ept: the rpmsg endpoint
265 * @data: payload of message
266 * @len: length of payload
267 *
268 * This function sends @data of length @len on the @ept endpoint.
269 * The message will be sent to the remote processor which the @ept
270 * endpoint belongs to, using @ept's address and its associated rpmsg
271 * device destination addresses.
272 * In case there are no TX buffers available, the function will block until
273 * one becomes available, or a timeout of 15 seconds elapses. When the latter
274 * happens, -ERESTARTSYS is returned.
275 *
276 * Can only be called from process context (for now).
277 *
278 * Returns 0 on success and an appropriate error value on failure.
279 */
280static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len)
281{
282 return ept->ops->send(ept, data, len);
283}
284
285/**
286 * rpmsg_sendto() - send a message across to the remote processor, specify dst
287 * @ept: the rpmsg endpoint
288 * @data: payload of message
289 * @len: length of payload
290 * @dst: destination address
291 *
292 * This function sends @data of length @len to the remote @dst address.
293 * The message will be sent to the remote processor which the @ept
294 * endpoint belongs to, using @ept's address as source.
295 * In case there are no TX buffers available, the function will block until
296 * one becomes available, or a timeout of 15 seconds elapses. When the latter
297 * happens, -ERESTARTSYS is returned.
298 *
299 * Can only be called from process context (for now).
300 *
301 * Returns 0 on success and an appropriate error value on failure.
302 */
303static inline
304int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst)
305{
306 return ept->ops->sendto(ept, data, len, dst);
307}
308
309/**
310 * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
311 * @ept: the rpmsg endpoint
312 * @src: source address
313 * @dst: destination address
314 * @data: payload of message
315 * @len: length of payload
316 *
317 * This function sends @data of length @len to the remote @dst address,
318 * and uses @src as the source address.
319 * The message will be sent to the remote processor which the @ept
320 * endpoint belongs to.
321 * In case there are no TX buffers available, the function will block until
322 * one becomes available, or a timeout of 15 seconds elapses. When the latter
323 * happens, -ERESTARTSYS is returned.
324 *
325 * Can only be called from process context (for now).
326 *
327 * Returns 0 on success and an appropriate error value on failure.
328 */
329static inline
330int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, 264int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
331 void *data, int len) 265 void *data, int len);
332{
333 return ept->ops->send_offchannel(ept, src, dst, data, len);
334}
335 266
336/** 267int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len);
337 * rpmsg_send() - send a message across to the remote processor 268int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);
338 * @ept: the rpmsg endpoint
339 * @data: payload of message
340 * @len: length of payload
341 *
342 * This function sends @data of length @len on the @ept endpoint.
343 * The message will be sent to the remote processor which the @ept
344 * endpoint belongs to, using @ept's address as source and its associated
345 * rpdev's address as destination.
346 * In case there are no TX buffers available, the function will immediately
347 * return -ENOMEM without waiting until one becomes available.
348 *
349 * Can only be called from process context (for now).
350 *
351 * Returns 0 on success and an appropriate error value on failure.
352 */
353static inline
354int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len)
355{
356 return ept->ops->trysend(ept, data, len);
357}
358
359/**
360 * rpmsg_sendto() - send a message across to the remote processor, specify dst
361 * @ept: the rpmsg endpoint
362 * @data: payload of message
363 * @len: length of payload
364 * @dst: destination address
365 *
366 * This function sends @data of length @len to the remote @dst address.
367 * The message will be sent to the remote processor which the @ept
368 * endpoint belongs to, using @ept's address as source.
369 * In case there are no TX buffers available, the function will immediately
370 * return -ENOMEM without waiting until one becomes available.
371 *
372 * Can only be called from process context (for now).
373 *
374 * Returns 0 on success and an appropriate error value on failure.
375 */
376static inline
377int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst)
378{
379 return ept->ops->trysendto(ept, data, len, dst);
380}
381
382/**
383 * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
384 * @ept: the rpmsg endpoint
385 * @src: source address
386 * @dst: destination address
387 * @data: payload of message
388 * @len: length of payload
389 *
390 * This function sends @data of length @len to the remote @dst address,
391 * and uses @src as the source address.
392 * The message will be sent to the remote processor which the @ept
393 * endpoint belongs to.
394 * In case there are no TX buffers available, the function will immediately
395 * return -ENOMEM without waiting until one becomes available.
396 *
397 * Can only be called from process context (for now).
398 *
399 * Returns 0 on success and an appropriate error value on failure.
400 */
401static inline
402int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, 269int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
403 void *data, int len) 270 void *data, int len);
404{
405 return ept->ops->trysend_offchannel(ept, src, dst, data, len);
406}
407 271
408#endif /* _LINUX_RPMSG_H */ 272#endif /* _LINUX_RPMSG_H */