hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/rpmsg/rpmsg_core.c
....@@ -46,7 +46,7 @@
4646 * equals to the src address of their rpmsg channel), the driver's handler
4747 * is invoked to process it.
4848 *
49
- * That said, more complicated drivers might do need to allocate
49
+ * That said, more complicated drivers might need to allocate
5050 * additional rpmsg addresses, and bind them to different rx callbacks.
5151 * To accomplish that, those drivers need to call this function.
5252 *
....@@ -81,7 +81,7 @@
8181 */
8282 void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
8383 {
84
- if (ept)
84
+ if (ept && ept->ops)
8585 ept->ops->destroy_ept(ept);
8686 }
8787 EXPORT_SYMBOL(rpmsg_destroy_ept);
....@@ -177,7 +177,7 @@
177177 EXPORT_SYMBOL(rpmsg_send_offchannel);
178178
179179 /**
180
- * rpmsg_send() - send a message across to the remote processor
180
+ * rpmsg_trysend() - send a message across to the remote processor
181181 * @ept: the rpmsg endpoint
182182 * @data: payload of message
183183 * @len: length of payload
....@@ -205,7 +205,7 @@
205205 EXPORT_SYMBOL(rpmsg_trysend);
206206
207207 /**
208
- * rpmsg_sendto() - send a message across to the remote processor, specify dst
208
+ * rpmsg_trysendto() - send a message across to the remote processor, specify dst
209209 * @ept: the rpmsg endpoint
210210 * @data: payload of message
211211 * @len: length of payload
....@@ -253,7 +253,7 @@
253253 EXPORT_SYMBOL(rpmsg_poll);
254254
255255 /**
256
- * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
256
+ * rpmsg_trysend_offchannel() - send a message using explicit src/dst addresses
257257 * @ept: the rpmsg endpoint
258258 * @src: source address
259259 * @dst: destination address
....@@ -283,8 +283,67 @@
283283 }
284284 EXPORT_SYMBOL(rpmsg_trysend_offchannel);
285285
286
+/**
287
+ * rpmsg_get_signals() - get the signals for this endpoint
288
+ * @ept: the rpmsg endpoint
289
+ *
290
+ * Returns signal bits on success and an appropriate error value on failure.
291
+ */
292
+int rpmsg_get_signals(struct rpmsg_endpoint *ept)
293
+{
294
+ if (WARN_ON(!ept))
295
+ return -EINVAL;
296
+ if (!ept->ops->get_signals)
297
+ return -ENXIO;
298
+
299
+ return ept->ops->get_signals(ept);
300
+}
301
+EXPORT_SYMBOL(rpmsg_get_signals);
302
+
303
+/**
304
+ * rpmsg_set_signals() - set the remote signals for this endpoint
305
+ * @ept: the rpmsg endpoint
306
+ * @set: set mask for signals
307
+ * @clear: clear mask for signals
308
+ *
309
+ * Returns 0 on success and an appropriate error value on failure.
310
+ */
311
+int rpmsg_set_signals(struct rpmsg_endpoint *ept, u32 set, u32 clear)
312
+{
313
+ if (WARN_ON(!ept))
314
+ return -EINVAL;
315
+ if (!ept->ops->set_signals)
316
+ return -ENXIO;
317
+
318
+ return ept->ops->set_signals(ept, set, clear);
319
+}
320
+EXPORT_SYMBOL(rpmsg_set_signals);
321
+
322
+#ifdef CONFIG_NO_GKI
323
+/**
324
+ * rpmsg_get_mtu() - get maximum transmission buffer size for sending message.
325
+ * @ept: the rpmsg endpoint
326
+ *
327
+ * This function returns maximum buffer size available for a single outgoing message.
328
+ *
329
+ * Return: the maximum transmission size on success and an appropriate error
330
+ * value on failure.
331
+ */
332
+
333
+ssize_t rpmsg_get_mtu(struct rpmsg_endpoint *ept)
334
+{
335
+ if (WARN_ON(!ept))
336
+ return -EINVAL;
337
+ if (!ept->ops->get_mtu)
338
+ return -ENOTSUPP;
339
+
340
+ return ept->ops->get_mtu(ept);
341
+}
342
+EXPORT_SYMBOL(rpmsg_get_mtu);
343
+#endif
344
+
286345 /*
287
- * match an rpmsg channel with a channel info struct.
346
+ * match a rpmsg channel with a channel info struct.
288347 * this is used to make sure we're not creating rpmsg devices for channels
289348 * that already exist.
290349 */
....@@ -468,6 +527,10 @@
468527
469528 rpdev->ept = ept;
470529 rpdev->src = ept->addr;
530
+
531
+ if (rpdrv->signals)
532
+ ept->sig_cb = rpdrv->signals;
533
+
471534 }
472535
473536 err = rpdrv->probe(rpdev);
....@@ -505,7 +568,8 @@
505568 if (rpdev->ops->announce_destroy)
506569 err = rpdev->ops->announce_destroy(rpdev);
507570
508
- rpdrv->remove(rpdev);
571
+ if (rpdrv->remove)
572
+ rpdrv->remove(rpdev);
509573
510574 dev_pm_domain_detach(dev, true);
511575