Linux Audio

Check our new training course

Loading...
v5.14.15
  1/* SPDX-License-Identifier: BSD-3-Clause */
  2/*
  3 * Remote processor messaging
  4 *
  5 * Copyright (C) 2011 Texas Instruments, Inc.
  6 * Copyright (C) 2011 Google, Inc.
  7 * All rights reserved.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  8 */
  9
 10#ifndef _LINUX_RPMSG_H
 11#define _LINUX_RPMSG_H
 12
 13#include <linux/types.h>
 14#include <linux/device.h>
 15#include <linux/err.h>
 16#include <linux/mod_devicetable.h>
 17#include <linux/kref.h>
 18#include <linux/mutex.h>
 19#include <linux/poll.h>
 20#include <linux/rpmsg/byteorder.h>
 21#include <uapi/linux/rpmsg.h>
 22
 23struct rpmsg_device;
 24struct rpmsg_endpoint;
 25struct rpmsg_device_ops;
 26struct rpmsg_endpoint_ops;
 27
 28/**
 29 * struct rpmsg_channel_info - channel info representation
 30 * @name: name of service
 31 * @src: local address
 32 * @dst: destination address
 
 
 
 
 
 
 33 */
 34struct rpmsg_channel_info {
 35	char name[RPMSG_NAME_SIZE];
 36	u32 src;
 37	u32 dst;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 38};
 39
 
 
 
 
 40/**
 41 * rpmsg_device - device that belong to the rpmsg bus
 
 42 * @dev: the device struct
 43 * @id: device id (used to match between rpmsg drivers and devices)
 44 * @driver_override: driver name to force a match
 45 * @src: local address
 46 * @dst: destination address
 47 * @ept: the rpmsg endpoint of this channel
 48 * @announce: if set, rpmsg will announce the creation/removal of this channel
 49 * @little_endian: True if transport is using little endian byte representation
 50 */
 51struct rpmsg_device {
 
 52	struct device dev;
 53	struct rpmsg_device_id id;
 54	char *driver_override;
 55	u32 src;
 56	u32 dst;
 57	struct rpmsg_endpoint *ept;
 58	bool announce;
 59	bool little_endian;
 60
 61	const struct rpmsg_device_ops *ops;
 62};
 63
 64typedef int (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32);
 65
 66/**
 67 * struct rpmsg_endpoint - binds a local rpmsg address to its user
 68 * @rpdev: rpmsg channel device
 69 * @refcount: when this drops to zero, the ept is deallocated
 70 * @cb: rx callback handler
 71 * @cb_lock: must be taken before accessing/changing @cb
 72 * @addr: local rpmsg address
 73 * @priv: private data for the driver's use
 74 *
 75 * In essence, an rpmsg endpoint represents a listener on the rpmsg bus, as
 76 * it binds an rpmsg address with an rx callback handler.
 77 *
 78 * Simple rpmsg drivers shouldn't use this struct directly, because
 79 * things just work: every rpmsg driver provides an rx callback upon
 80 * registering to the bus, and that callback is then bound to its rpmsg
 81 * address when the driver is probed. When relevant inbound messages arrive
 82 * (i.e. messages which their dst address equals to the src address of
 83 * the rpmsg channel), the driver's handler is invoked to process it.
 84 *
 85 * More complicated drivers though, that do need to allocate additional rpmsg
 86 * addresses, and bind them to different rx callbacks, must explicitly
 87 * create additional endpoints by themselves (see rpmsg_create_ept()).
 88 */
 89struct rpmsg_endpoint {
 90	struct rpmsg_device *rpdev;
 91	struct kref refcount;
 92	rpmsg_rx_cb_t cb;
 93	struct mutex cb_lock;
 94	u32 addr;
 95	void *priv;
 96
 97	const struct rpmsg_endpoint_ops *ops;
 98};
 99
100/**
101 * struct rpmsg_driver - rpmsg driver struct
102 * @drv: underlying device driver
103 * @id_table: rpmsg ids serviced by this driver
104 * @probe: invoked when a matching rpmsg channel (i.e. device) is found
105 * @remove: invoked when the rpmsg channel is removed
106 * @callback: invoked when an inbound message is received on the channel
107 */
108struct rpmsg_driver {
109	struct device_driver drv;
110	const struct rpmsg_device_id *id_table;
111	int (*probe)(struct rpmsg_device *dev);
112	void (*remove)(struct rpmsg_device *dev);
113	int (*callback)(struct rpmsg_device *, void *, int, void *, u32);
114};
115
116static inline u16 rpmsg16_to_cpu(struct rpmsg_device *rpdev, __rpmsg16 val)
117{
118	if (!rpdev)
119		return __rpmsg16_to_cpu(rpmsg_is_little_endian(), val);
120	else
121		return __rpmsg16_to_cpu(rpdev->little_endian, val);
122}
123
124static inline __rpmsg16 cpu_to_rpmsg16(struct rpmsg_device *rpdev, u16 val)
125{
126	if (!rpdev)
127		return __cpu_to_rpmsg16(rpmsg_is_little_endian(), val);
128	else
129		return __cpu_to_rpmsg16(rpdev->little_endian, val);
130}
131
132static inline u32 rpmsg32_to_cpu(struct rpmsg_device *rpdev, __rpmsg32 val)
133{
134	if (!rpdev)
135		return __rpmsg32_to_cpu(rpmsg_is_little_endian(), val);
136	else
137		return __rpmsg32_to_cpu(rpdev->little_endian, val);
138}
139
140static inline __rpmsg32 cpu_to_rpmsg32(struct rpmsg_device *rpdev, u32 val)
141{
142	if (!rpdev)
143		return __cpu_to_rpmsg32(rpmsg_is_little_endian(), val);
144	else
145		return __cpu_to_rpmsg32(rpdev->little_endian, val);
146}
147
148static inline u64 rpmsg64_to_cpu(struct rpmsg_device *rpdev, __rpmsg64 val)
149{
150	if (!rpdev)
151		return __rpmsg64_to_cpu(rpmsg_is_little_endian(), val);
152	else
153		return __rpmsg64_to_cpu(rpdev->little_endian, val);
154}
155
156static inline __rpmsg64 cpu_to_rpmsg64(struct rpmsg_device *rpdev, u64 val)
157{
158	if (!rpdev)
159		return __cpu_to_rpmsg64(rpmsg_is_little_endian(), val);
160	else
161		return __cpu_to_rpmsg64(rpdev->little_endian, val);
162}
163
164#if IS_ENABLED(CONFIG_RPMSG)
165
166int rpmsg_register_device(struct rpmsg_device *rpdev);
167int rpmsg_unregister_device(struct device *parent,
168			    struct rpmsg_channel_info *chinfo);
169int __register_rpmsg_driver(struct rpmsg_driver *drv, struct module *owner);
170void unregister_rpmsg_driver(struct rpmsg_driver *drv);
171void rpmsg_destroy_ept(struct rpmsg_endpoint *);
172struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *,
173					rpmsg_rx_cb_t cb, void *priv,
174					struct rpmsg_channel_info chinfo);
175
176int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len);
177int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);
178int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
179			  void *data, int len);
180
181int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len);
182int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);
183int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
184			     void *data, int len);
185
186__poll_t rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp,
187			poll_table *wait);
188
189#else
190
191static inline int rpmsg_register_device(struct rpmsg_device *rpdev)
192{
193	return -ENXIO;
194}
195
196static inline int rpmsg_unregister_device(struct device *parent,
197					  struct rpmsg_channel_info *chinfo)
198{
199	/* This shouldn't be possible */
200	WARN_ON(1);
201
202	return -ENXIO;
203}
204
205static inline int __register_rpmsg_driver(struct rpmsg_driver *drv,
206					  struct module *owner)
207{
208	/* This shouldn't be possible */
209	WARN_ON(1);
210
211	return -ENXIO;
212}
213
214static inline void unregister_rpmsg_driver(struct rpmsg_driver *drv)
215{
216	/* This shouldn't be possible */
217	WARN_ON(1);
218}
219
220static inline void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
221{
222	/* This shouldn't be possible */
223	WARN_ON(1);
224}
225
226static inline struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev,
227						      rpmsg_rx_cb_t cb,
228						      void *priv,
229						      struct rpmsg_channel_info chinfo)
230{
231	/* This shouldn't be possible */
232	WARN_ON(1);
233
234	return ERR_PTR(-ENXIO);
235}
236
237static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len)
238{
239	/* This shouldn't be possible */
240	WARN_ON(1);
241
242	return -ENXIO;
243}
244
245static inline int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len,
246			       u32 dst)
247{
248	/* This shouldn't be possible */
249	WARN_ON(1);
250
251	return -ENXIO;
252
253}
254
255static inline int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src,
256					u32 dst, void *data, int len)
257{
258	/* This shouldn't be possible */
259	WARN_ON(1);
260
261	return -ENXIO;
262}
263
264static inline int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265{
266	/* This shouldn't be possible */
267	WARN_ON(1);
268
269	return -ENXIO;
270}
271
272static inline int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data,
273				  int len, u32 dst)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274{
275	/* This shouldn't be possible */
276	WARN_ON(1);
277
278	return -ENXIO;
279}
280
281static inline int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src,
282					   u32 dst, void *data, int len)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283{
284	/* This shouldn't be possible */
285	WARN_ON(1);
286
287	return -ENXIO;
288}
289
290static inline __poll_t rpmsg_poll(struct rpmsg_endpoint *ept,
291				      struct file *filp, poll_table *wait)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292{
293	/* This shouldn't be possible */
294	WARN_ON(1);
295
296	return 0;
297}
298
299#endif /* IS_ENABLED(CONFIG_RPMSG) */
300
301/* use a macro to avoid include chaining to get THIS_MODULE */
302#define register_rpmsg_driver(drv) \
303	__register_rpmsg_driver(drv, THIS_MODULE)
304
305/**
306 * module_rpmsg_driver() - Helper macro for registering an rpmsg driver
307 * @__rpmsg_driver: rpmsg_driver struct
 
 
 
 
 
 
 
 
 
 
 
308 *
309 * Helper macro for rpmsg drivers which do not do anything special in module
310 * init/exit. This eliminates a lot of boilerplate.  Each module may only
311 * use this macro once, and calling it replaces module_init() and module_exit()
312 */
313#define module_rpmsg_driver(__rpmsg_driver) \
314	module_driver(__rpmsg_driver, register_rpmsg_driver, \
315			unregister_rpmsg_driver)
 
 
 
316
317#endif /* _LINUX_RPMSG_H */
v3.15
 
  1/*
  2 * Remote processor messaging
  3 *
  4 * Copyright (C) 2011 Texas Instruments, Inc.
  5 * Copyright (C) 2011 Google, Inc.
  6 * All rights reserved.
  7 *
  8 * Redistribution and use in source and binary forms, with or without
  9 * modification, are permitted provided that the following conditions
 10 * are met:
 11 *
 12 * * Redistributions of source code must retain the above copyright
 13 *   notice, this list of conditions and the following disclaimer.
 14 * * Redistributions in binary form must reproduce the above copyright
 15 *   notice, this list of conditions and the following disclaimer in
 16 *   the documentation and/or other materials provided with the
 17 *   distribution.
 18 * * Neither the name Texas Instruments nor the names of its
 19 *   contributors may be used to endorse or promote products derived
 20 *   from this software without specific prior written permission.
 21 *
 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 33 */
 34
 35#ifndef _LINUX_RPMSG_H
 36#define _LINUX_RPMSG_H
 37
 38#include <linux/types.h>
 39#include <linux/device.h>
 
 40#include <linux/mod_devicetable.h>
 41#include <linux/kref.h>
 42#include <linux/mutex.h>
 43
 44/* The feature bitmap for virtio rpmsg */
 45#define VIRTIO_RPMSG_F_NS	0 /* RP supports name service notifications */
 
 
 
 
 
 46
 47/**
 48 * struct rpmsg_hdr - common header for all rpmsg messages
 49 * @src: source address
 
 50 * @dst: destination address
 51 * @reserved: reserved for future use
 52 * @len: length of payload (in bytes)
 53 * @flags: message flags
 54 * @data: @len bytes of message payload data
 55 *
 56 * Every message sent(/received) on the rpmsg bus begins with this header.
 57 */
 58struct rpmsg_hdr {
 
 59	u32 src;
 60	u32 dst;
 61	u32 reserved;
 62	u16 len;
 63	u16 flags;
 64	u8 data[0];
 65} __packed;
 66
 67/**
 68 * struct rpmsg_ns_msg - dynamic name service announcement message
 69 * @name: name of remote service that is published
 70 * @addr: address of remote service that is published
 71 * @flags: indicates whether service is created or destroyed
 72 *
 73 * This message is sent across to publish a new service, or announce
 74 * about its removal. When we receive these messages, an appropriate
 75 * rpmsg channel (i.e device) is created/destroyed. In turn, the ->probe()
 76 * or ->remove() handler of the appropriate rpmsg driver will be invoked
 77 * (if/as-soon-as one is registered).
 78 */
 79struct rpmsg_ns_msg {
 80	char name[RPMSG_NAME_SIZE];
 81	u32 addr;
 82	u32 flags;
 83} __packed;
 84
 85/**
 86 * enum rpmsg_ns_flags - dynamic name service announcement flags
 87 *
 88 * @RPMSG_NS_CREATE: a new remote service was just created
 89 * @RPMSG_NS_DESTROY: a known remote service was just destroyed
 90 */
 91enum rpmsg_ns_flags {
 92	RPMSG_NS_CREATE		= 0,
 93	RPMSG_NS_DESTROY	= 1,
 94};
 95
 96#define RPMSG_ADDR_ANY		0xFFFFFFFF
 97
 98struct virtproc_info;
 99
100/**
101 * rpmsg_channel - devices that belong to the rpmsg bus are called channels
102 * @vrp: the remote processor this channel belongs to
103 * @dev: the device struct
104 * @id: device id (used to match between rpmsg drivers and devices)
 
105 * @src: local address
106 * @dst: destination address
107 * @ept: the rpmsg endpoint of this channel
108 * @announce: if set, rpmsg will announce the creation/removal of this channel
 
109 */
110struct rpmsg_channel {
111	struct virtproc_info *vrp;
112	struct device dev;
113	struct rpmsg_device_id id;
 
114	u32 src;
115	u32 dst;
116	struct rpmsg_endpoint *ept;
117	bool announce;
 
 
 
118};
119
120typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, u32);
121
122/**
123 * struct rpmsg_endpoint - binds a local rpmsg address to its user
124 * @rpdev: rpmsg channel device
125 * @refcount: when this drops to zero, the ept is deallocated
126 * @cb: rx callback handler
127 * @cb_lock: must be taken before accessing/changing @cb
128 * @addr: local rpmsg address
129 * @priv: private data for the driver's use
130 *
131 * In essence, an rpmsg endpoint represents a listener on the rpmsg bus, as
132 * it binds an rpmsg address with an rx callback handler.
133 *
134 * Simple rpmsg drivers shouldn't use this struct directly, because
135 * things just work: every rpmsg driver provides an rx callback upon
136 * registering to the bus, and that callback is then bound to its rpmsg
137 * address when the driver is probed. When relevant inbound messages arrive
138 * (i.e. messages which their dst address equals to the src address of
139 * the rpmsg channel), the driver's handler is invoked to process it.
140 *
141 * More complicated drivers though, that do need to allocate additional rpmsg
142 * addresses, and bind them to different rx callbacks, must explicitly
143 * create additional endpoints by themselves (see rpmsg_create_ept()).
144 */
145struct rpmsg_endpoint {
146	struct rpmsg_channel *rpdev;
147	struct kref refcount;
148	rpmsg_rx_cb_t cb;
149	struct mutex cb_lock;
150	u32 addr;
151	void *priv;
 
 
152};
153
154/**
155 * struct rpmsg_driver - rpmsg driver struct
156 * @drv: underlying device driver
157 * @id_table: rpmsg ids serviced by this driver
158 * @probe: invoked when a matching rpmsg channel (i.e. device) is found
159 * @remove: invoked when the rpmsg channel is removed
160 * @callback: invoked when an inbound message is received on the channel
161 */
162struct rpmsg_driver {
163	struct device_driver drv;
164	const struct rpmsg_device_id *id_table;
165	int (*probe)(struct rpmsg_channel *dev);
166	void (*remove)(struct rpmsg_channel *dev);
167	void (*callback)(struct rpmsg_channel *, void *, int, void *, u32);
168};
169
170int register_rpmsg_device(struct rpmsg_channel *dev);
171void unregister_rpmsg_device(struct rpmsg_channel *dev);
172int register_rpmsg_driver(struct rpmsg_driver *drv);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173void unregister_rpmsg_driver(struct rpmsg_driver *drv);
174void rpmsg_destroy_ept(struct rpmsg_endpoint *);
175struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *,
176				rpmsg_rx_cb_t cb, void *priv, u32 addr);
177int
178rpmsg_send_offchannel_raw(struct rpmsg_channel *, u32, u32, void *, int, bool);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
180/**
181 * rpmsg_send() - send a message across to the remote processor
182 * @rpdev: the rpmsg channel
183 * @data: payload of message
184 * @len: length of payload
185 *
186 * This function sends @data of length @len on the @rpdev channel.
187 * The message will be sent to the remote processor which the @rpdev
188 * channel belongs to, using @rpdev's source and destination addresses.
189 * In case there are no TX buffers available, the function will block until
190 * one becomes available, or a timeout of 15 seconds elapses. When the latter
191 * happens, -ERESTARTSYS is returned.
192 *
193 * Can only be called from process context (for now).
194 *
195 * Returns 0 on success and an appropriate error value on failure.
196 */
197static inline int rpmsg_send(struct rpmsg_channel *rpdev, void *data, int len)
 
 
 
 
 
198{
199	u32 src = rpdev->src, dst = rpdev->dst;
 
200
201	return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true);
202}
203
204/**
205 * rpmsg_sendto() - send a message across to the remote processor, specify dst
206 * @rpdev: the rpmsg channel
207 * @data: payload of message
208 * @len: length of payload
209 * @dst: destination address
210 *
211 * This function sends @data of length @len to the remote @dst address.
212 * The message will be sent to the remote processor which the @rpdev
213 * channel belongs to, using @rpdev's source address.
214 * In case there are no TX buffers available, the function will block until
215 * one becomes available, or a timeout of 15 seconds elapses. When the latter
216 * happens, -ERESTARTSYS is returned.
217 *
218 * Can only be called from process context (for now).
219 *
220 * Returns 0 on success and an appropriate error value on failure.
221 */
222static inline
223int rpmsg_sendto(struct rpmsg_channel *rpdev, void *data, int len, u32 dst)
224{
225	u32 src = rpdev->src;
 
226
227	return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true);
228}
229
230/**
231 * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
232 * @rpdev: the rpmsg channel
233 * @src: source address
234 * @dst: destination address
235 * @data: payload of message
236 * @len: length of payload
237 *
238 * This function sends @data of length @len to the remote @dst address,
239 * and uses @src as the source address.
240 * The message will be sent to the remote processor which the @rpdev
241 * channel belongs to.
242 * In case there are no TX buffers available, the function will block until
243 * one becomes available, or a timeout of 15 seconds elapses. When the latter
244 * happens, -ERESTARTSYS is returned.
245 *
246 * Can only be called from process context (for now).
247 *
248 * Returns 0 on success and an appropriate error value on failure.
249 */
250static inline
251int rpmsg_send_offchannel(struct rpmsg_channel *rpdev, u32 src, u32 dst,
252							void *data, int len)
253{
254	return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true);
 
 
 
255}
256
257/**
258 * rpmsg_send() - send a message across to the remote processor
259 * @rpdev: the rpmsg channel
260 * @data: payload of message
261 * @len: length of payload
262 *
263 * This function sends @data of length @len on the @rpdev channel.
264 * The message will be sent to the remote processor which the @rpdev
265 * channel belongs to, using @rpdev's source and destination addresses.
266 * In case there are no TX buffers available, the function will immediately
267 * return -ENOMEM without waiting until one becomes available.
268 *
269 * Can only be called from process context (for now).
270 *
271 * Returns 0 on success and an appropriate error value on failure.
272 */
273static inline
274int rpmsg_trysend(struct rpmsg_channel *rpdev, void *data, int len)
275{
276	u32 src = rpdev->src, dst = rpdev->dst;
 
277
278	return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false);
279}
280
281/**
282 * rpmsg_sendto() - send a message across to the remote processor, specify dst
283 * @rpdev: the rpmsg channel
284 * @data: payload of message
285 * @len: length of payload
286 * @dst: destination address
287 *
288 * This function sends @data of length @len to the remote @dst address.
289 * The message will be sent to the remote processor which the @rpdev
290 * channel belongs to, using @rpdev's source address.
291 * In case there are no TX buffers available, the function will immediately
292 * return -ENOMEM without waiting until one becomes available.
293 *
294 * Can only be called from process context (for now).
295 *
296 * Returns 0 on success and an appropriate error value on failure.
297 */
298static inline
299int rpmsg_trysendto(struct rpmsg_channel *rpdev, void *data, int len, u32 dst)
300{
301	u32 src = rpdev->src;
 
302
303	return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false);
304}
305
 
 
 
 
 
 
306/**
307 * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
308 * @rpdev: the rpmsg channel
309 * @src: source address
310 * @dst: destination address
311 * @data: payload of message
312 * @len: length of payload
313 *
314 * This function sends @data of length @len to the remote @dst address,
315 * and uses @src as the source address.
316 * The message will be sent to the remote processor which the @rpdev
317 * channel belongs to.
318 * In case there are no TX buffers available, the function will immediately
319 * return -ENOMEM without waiting until one becomes available.
320 *
321 * Can only be called from process context (for now).
322 *
323 * Returns 0 on success and an appropriate error value on failure.
324 */
325static inline
326int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev, u32 src, u32 dst,
327							void *data, int len)
328{
329	return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false);
330}
331
332#endif /* _LINUX_RPMSG_H */