forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 072de836f53be56a70cecf70b43ae43b7ce17376
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,44 @@
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
+
286322 /*
287
- * match an rpmsg channel with a channel info struct.
323
+ * match a rpmsg channel with a channel info struct.
288324 * this is used to make sure we're not creating rpmsg devices for channels
289325 * that already exist.
290326 */
....@@ -468,6 +504,10 @@
468504
469505 rpdev->ept = ept;
470506 rpdev->src = ept->addr;
507
+
508
+ if (rpdrv->signals)
509
+ ept->sig_cb = rpdrv->signals;
510
+
471511 }
472512
473513 err = rpdrv->probe(rpdev);
....@@ -505,7 +545,8 @@
505545 if (rpdev->ops->announce_destroy)
506546 err = rpdev->ops->announce_destroy(rpdev);
507547
508
- rpdrv->remove(rpdev);
548
+ if (rpdrv->remove)
549
+ rpdrv->remove(rpdev);
509550
510551 dev_pm_domain_detach(dev, true);
511552