diff options
author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2016-10-21 13:25:37 -0400 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2016-10-31 18:45:18 -0400 |
commit | 2c8a57088045a58958372d405586c16e3e12f4e1 (patch) | |
tree | 94f7a751234a6f8815edf0a80ef5820be66a9c26 /include/linux/rpmsg.h | |
parent | 93e9324431c9628224886f979dcd59d377b0818a (diff) |
rpmsg: Provide function stubs for API
Provide function stubs for the rpmsg API to allow clients to be compile
tested without having CONFIG_RPMSG enabled.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'include/linux/rpmsg.h')
-rw-r--r-- | include/linux/rpmsg.h | 123 |
1 files changed, 113 insertions, 10 deletions
diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index 7ad6c205f110..18f9e1ae4b7e 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | #include <linux/types.h> | 38 | #include <linux/types.h> |
39 | #include <linux/device.h> | 39 | #include <linux/device.h> |
40 | #include <linux/err.h> | ||
40 | #include <linux/mod_devicetable.h> | 41 | #include <linux/mod_devicetable.h> |
41 | #include <linux/kref.h> | 42 | #include <linux/kref.h> |
42 | #include <linux/mutex.h> | 43 | #include <linux/mutex.h> |
@@ -134,6 +135,8 @@ struct rpmsg_driver { | |||
134 | int (*callback)(struct rpmsg_device *, void *, int, void *, u32); | 135 | int (*callback)(struct rpmsg_device *, void *, int, void *, u32); |
135 | }; | 136 | }; |
136 | 137 | ||
138 | #if IS_ENABLED(CONFIG_RPMSG) | ||
139 | |||
137 | int register_rpmsg_device(struct rpmsg_device *dev); | 140 | int register_rpmsg_device(struct rpmsg_device *dev); |
138 | void unregister_rpmsg_device(struct rpmsg_device *dev); | 141 | void unregister_rpmsg_device(struct rpmsg_device *dev); |
139 | int __register_rpmsg_driver(struct rpmsg_driver *drv, struct module *owner); | 142 | int __register_rpmsg_driver(struct rpmsg_driver *drv, struct module *owner); |
@@ -143,6 +146,116 @@ struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *, | |||
143 | rpmsg_rx_cb_t cb, void *priv, | 146 | rpmsg_rx_cb_t cb, void *priv, |
144 | struct rpmsg_channel_info chinfo); | 147 | struct rpmsg_channel_info chinfo); |
145 | 148 | ||
149 | int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len); | ||
150 | int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); | ||
151 | int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, | ||
152 | void *data, int len); | ||
153 | |||
154 | int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len); | ||
155 | int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); | ||
156 | int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, | ||
157 | void *data, int len); | ||
158 | |||
159 | #else | ||
160 | |||
161 | static inline int register_rpmsg_device(struct rpmsg_device *dev) | ||
162 | { | ||
163 | return -ENXIO; | ||
164 | } | ||
165 | |||
166 | static inline void unregister_rpmsg_device(struct rpmsg_device *dev) | ||
167 | { | ||
168 | /* This shouldn't be possible */ | ||
169 | WARN_ON(1); | ||
170 | } | ||
171 | |||
172 | static inline int __register_rpmsg_driver(struct rpmsg_driver *drv, | ||
173 | struct module *owner) | ||
174 | { | ||
175 | /* This shouldn't be possible */ | ||
176 | WARN_ON(1); | ||
177 | |||
178 | return -ENXIO; | ||
179 | } | ||
180 | |||
181 | static inline void unregister_rpmsg_driver(struct rpmsg_driver *drv) | ||
182 | { | ||
183 | /* This shouldn't be possible */ | ||
184 | WARN_ON(1); | ||
185 | } | ||
186 | |||
187 | static inline void rpmsg_destroy_ept(struct rpmsg_endpoint *ept) | ||
188 | { | ||
189 | /* This shouldn't be possible */ | ||
190 | WARN_ON(1); | ||
191 | } | ||
192 | |||
193 | static inline struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev, | ||
194 | rpmsg_rx_cb_t cb, | ||
195 | void *priv, | ||
196 | struct rpmsg_channel_info chinfo) | ||
197 | { | ||
198 | /* This shouldn't be possible */ | ||
199 | WARN_ON(1); | ||
200 | |||
201 | return ERR_PTR(-ENXIO); | ||
202 | } | ||
203 | |||
204 | static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len) | ||
205 | { | ||
206 | /* This shouldn't be possible */ | ||
207 | WARN_ON(1); | ||
208 | |||
209 | return -ENXIO; | ||
210 | } | ||
211 | |||
212 | static inline int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, | ||
213 | u32 dst) | ||
214 | { | ||
215 | /* This shouldn't be possible */ | ||
216 | WARN_ON(1); | ||
217 | |||
218 | return -ENXIO; | ||
219 | |||
220 | } | ||
221 | |||
222 | static inline int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, | ||
223 | u32 dst, void *data, int len) | ||
224 | { | ||
225 | /* This shouldn't be possible */ | ||
226 | WARN_ON(1); | ||
227 | |||
228 | return -ENXIO; | ||
229 | } | ||
230 | |||
231 | static inline int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len) | ||
232 | { | ||
233 | /* This shouldn't be possible */ | ||
234 | WARN_ON(1); | ||
235 | |||
236 | return -ENXIO; | ||
237 | } | ||
238 | |||
239 | static inline int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, | ||
240 | int len, u32 dst) | ||
241 | { | ||
242 | /* This shouldn't be possible */ | ||
243 | WARN_ON(1); | ||
244 | |||
245 | return -ENXIO; | ||
246 | } | ||
247 | |||
248 | static inline int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, | ||
249 | u32 dst, void *data, int len) | ||
250 | { | ||
251 | /* This shouldn't be possible */ | ||
252 | WARN_ON(1); | ||
253 | |||
254 | return -ENXIO; | ||
255 | } | ||
256 | |||
257 | #endif /* IS_ENABLED(CONFIG_RPMSG) */ | ||
258 | |||
146 | /* use a macro to avoid include chaining to get THIS_MODULE */ | 259 | /* use a macro to avoid include chaining to get THIS_MODULE */ |
147 | #define register_rpmsg_driver(drv) \ | 260 | #define register_rpmsg_driver(drv) \ |
148 | __register_rpmsg_driver(drv, THIS_MODULE) | 261 | __register_rpmsg_driver(drv, THIS_MODULE) |
@@ -159,14 +272,4 @@ struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *, | |||
159 | module_driver(__rpmsg_driver, register_rpmsg_driver, \ | 272 | module_driver(__rpmsg_driver, register_rpmsg_driver, \ |
160 | unregister_rpmsg_driver) | 273 | unregister_rpmsg_driver) |
161 | 274 | ||
162 | int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len); | ||
163 | int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); | ||
164 | int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, | ||
165 | void *data, int len); | ||
166 | |||
167 | int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len); | ||
168 | int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); | ||
169 | int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, | ||
170 | void *data, int len); | ||
171 | |||
172 | #endif /* _LINUX_RPMSG_H */ | 275 | #endif /* _LINUX_RPMSG_H */ |