Lines Matching +full:rpmsg +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0
8 * Ohad Ben-Cohen <ohad@wizery.com>
16 #include <linux/rpmsg.h>
24 * rpmsg_create_channel() - create a new rpmsg channel
25 * using its name and address info.
26 * @rpdev: rpmsg device
29 * Returns a pointer to the new rpmsg device on success, or NULL on error.
36 if (!rpdev->ops || !rpdev->ops->create_channel) { in rpmsg_create_channel()
37 dev_err(&rpdev->dev, "no create_channel ops found\n"); in rpmsg_create_channel()
41 return rpdev->ops->create_channel(rpdev, chinfo); in rpmsg_create_channel()
46 * rpmsg_release_channel() - release a rpmsg channel
47 * using its name and address info.
48 * @rpdev: rpmsg device
57 return -EINVAL; in rpmsg_release_channel()
58 if (!rpdev->ops || !rpdev->ops->release_channel) { in rpmsg_release_channel()
59 dev_err(&rpdev->dev, "no release_channel ops found\n"); in rpmsg_release_channel()
60 return -ENXIO; in rpmsg_release_channel()
63 return rpdev->ops->release_channel(rpdev, chinfo); in rpmsg_release_channel()
68 * rpmsg_create_ept() - create a new rpmsg_endpoint
69 * @rpdev: rpmsg channel device
72 * @chinfo: channel_info with the local rpmsg address to bind with @cb
74 * Every rpmsg address in the system is bound to an rx callback (so when
75 * inbound messages arrive, they are dispatched by the rpmsg bus using the
79 * bind a callback, and possibly some private data too, to an rpmsg address
83 * Simple rpmsg drivers need not call rpmsg_create_ept, because an endpoint
84 * is already created for them when they are probed by the rpmsg bus
85 * (using the rx callback provided when they registered to the rpmsg bus).
88 * endpoint, their rx callback is bound to their rpmsg address, and when
90 * equals to the src address of their rpmsg channel), the driver's handler
94 * additional rpmsg addresses, and bind them to different rx callbacks.
102 * dynamically assign them an available rpmsg address (drivers should have
114 return rpdev->ops->create_ept(rpdev, cb, priv, chinfo); in rpmsg_create_ept()
119 * rpmsg_destroy_ept() - destroy an existing rpmsg endpoint
122 * Should be used by drivers to destroy an rpmsg endpoint previously
128 if (ept && ept->ops) in rpmsg_destroy_ept()
129 ept->ops->destroy_ept(ept); in rpmsg_destroy_ept()
134 * rpmsg_send() - send a message across to the remote processor
135 * @ept: the rpmsg endpoint
141 * endpoint belongs to, using @ept's address and its associated rpmsg
145 * happens, -ERESTARTSYS is returned.
154 return -EINVAL; in rpmsg_send()
155 if (!ept->ops->send) in rpmsg_send()
156 return -ENXIO; in rpmsg_send()
158 return ept->ops->send(ept, data, len); in rpmsg_send()
163 * rpmsg_sendto() - send a message across to the remote processor, specify dst
164 * @ept: the rpmsg endpoint
174 * happens, -ERESTARTSYS is returned.
183 return -EINVAL; in rpmsg_sendto()
184 if (!ept->ops->sendto) in rpmsg_sendto()
185 return -ENXIO; in rpmsg_sendto()
187 return ept->ops->sendto(ept, data, len, dst); in rpmsg_sendto()
192 * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
193 * @ept: the rpmsg endpoint
205 * happens, -ERESTARTSYS is returned.
215 return -EINVAL; in rpmsg_send_offchannel()
216 if (!ept->ops->send_offchannel) in rpmsg_send_offchannel()
217 return -ENXIO; in rpmsg_send_offchannel()
219 return ept->ops->send_offchannel(ept, src, dst, data, len); in rpmsg_send_offchannel()
224 * rpmsg_trysend() - send a message across to the remote processor
225 * @ept: the rpmsg endpoint
234 * return -ENOMEM without waiting until one becomes available.
243 return -EINVAL; in rpmsg_trysend()
244 if (!ept->ops->trysend) in rpmsg_trysend()
245 return -ENXIO; in rpmsg_trysend()
247 return ept->ops->trysend(ept, data, len); in rpmsg_trysend()
252 * rpmsg_trysendto() - send a message across to the remote processor, specify dst
253 * @ept: the rpmsg endpoint
262 * return -ENOMEM without waiting until one becomes available.
271 return -EINVAL; in rpmsg_trysendto()
272 if (!ept->ops->trysendto) in rpmsg_trysendto()
273 return -ENXIO; in rpmsg_trysendto()
275 return ept->ops->trysendto(ept, data, len, dst); in rpmsg_trysendto()
280 * rpmsg_poll() - poll the endpoint's send buffers
281 * @ept: the rpmsg endpoint
292 if (!ept->ops->poll) in rpmsg_poll()
295 return ept->ops->poll(ept, filp, wait); in rpmsg_poll()
300 * rpmsg_trysend_offchannel() - send a message using explicit src/dst addresses
301 * @ept: the rpmsg endpoint
312 * return -ENOMEM without waiting until one becomes available.
322 return -EINVAL; in rpmsg_trysend_offchannel()
323 if (!ept->ops->trysend_offchannel) in rpmsg_trysend_offchannel()
324 return -ENXIO; in rpmsg_trysend_offchannel()
326 return ept->ops->trysend_offchannel(ept, src, dst, data, len); in rpmsg_trysend_offchannel()
331 * match a rpmsg channel with a channel info struct.
332 * this is used to make sure we're not creating rpmsg devices for channels
340 if (chinfo->src != RPMSG_ADDR_ANY && chinfo->src != rpdev->src) in rpmsg_device_match()
343 if (chinfo->dst != RPMSG_ADDR_ANY && chinfo->dst != rpdev->dst) in rpmsg_device_match()
346 if (strncmp(chinfo->name, rpdev->id.name, RPMSG_NAME_SIZE)) in rpmsg_device_match()
369 return sprintf(buf, format_string, rpdev->path); \
383 return -ENOMEM; \
387 old = rpdev->member; \
389 rpdev->member = new; \
392 rpdev->member = NULL; \
406 return sprintf(buf, "%s\n", rpdev->member); \
410 /* for more info, see Documentation/ABI/testing/sysfs-bus-rpmsg */
411 rpmsg_show_attr(name, id.name, "%s\n");
424 if (len != -ENODEV) in modalias_show()
427 return sprintf(buf, RPMSG_DEVICE_MODALIAS_FMT "\n", rpdev->id.name); in modalias_show()
442 /* rpmsg devices and drivers are matched using the service name */
446 return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0; in rpmsg_id_match()
449 /* match rpmsg channel and rpmsg driver */
454 const struct rpmsg_device_id *ids = rpdrv->id_table; in rpmsg_dev_match()
457 if (rpdev->driver_override) in rpmsg_dev_match()
458 return !strcmp(rpdev->driver_override, drv->name); in rpmsg_dev_match()
461 for (i = 0; ids[i].name[0]; i++) in rpmsg_dev_match()
463 rpdev->id.driver_data = ids[i].driver_data; in rpmsg_dev_match()
476 if (ret != -ENODEV) in rpmsg_uevent()
480 rpdev->id.name); in rpmsg_uevent()
484 * when an rpmsg driver is probed with a channel, we seamlessly create
485 * it an endpoint, binding its rx callback to a unique local rpmsg
489 * processor (needed in case the driver is exposing an rpmsg service).
494 struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver); in rpmsg_dev_probe()
503 if (rpdrv->callback) { in rpmsg_dev_probe()
504 strncpy(chinfo.name, rpdev->id.name, RPMSG_NAME_SIZE); in rpmsg_dev_probe()
505 chinfo.src = rpdev->src; in rpmsg_dev_probe()
508 ept = rpmsg_create_ept(rpdev, rpdrv->callback, NULL, chinfo); in rpmsg_dev_probe()
511 err = -ENOMEM; in rpmsg_dev_probe()
515 rpdev->ept = ept; in rpmsg_dev_probe()
516 rpdev->src = ept->addr; in rpmsg_dev_probe()
519 err = rpdrv->probe(rpdev); in rpmsg_dev_probe()
527 if (ept && rpdev->ops->announce_create) in rpmsg_dev_probe()
528 err = rpdev->ops->announce_create(rpdev); in rpmsg_dev_probe()
536 struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver); in rpmsg_dev_remove()
538 if (rpdev->ops->announce_destroy) in rpmsg_dev_remove()
539 rpdev->ops->announce_destroy(rpdev); in rpmsg_dev_remove()
541 if (rpdrv->remove) in rpmsg_dev_remove()
542 rpdrv->remove(rpdev); in rpmsg_dev_remove()
546 if (rpdev->ept) in rpmsg_dev_remove()
547 rpmsg_destroy_ept(rpdev->ept); in rpmsg_dev_remove()
551 .name = "rpmsg",
561 struct device *dev = &rpdev->dev; in rpmsg_register_device()
564 dev_set_name(&rpdev->dev, "%s.%s.%d.%d", dev_name(dev->parent), in rpmsg_register_device()
565 rpdev->id.name, rpdev->src, rpdev->dst); in rpmsg_register_device()
567 rpdev->dev.bus = &rpmsg_bus; in rpmsg_register_device()
569 ret = device_register(&rpdev->dev); in rpmsg_register_device()
572 put_device(&rpdev->dev); in rpmsg_register_device()
580 * find an existing channel using its name + address properties,
590 return -EINVAL; in rpmsg_unregister_device()
601 * __register_rpmsg_driver() - register an rpmsg driver with the rpmsg bus
609 rpdrv->drv.bus = &rpmsg_bus; in __register_rpmsg_driver()
610 rpdrv->drv.owner = owner; in __register_rpmsg_driver()
611 return driver_register(&rpdrv->drv); in __register_rpmsg_driver()
616 * unregister_rpmsg_driver() - unregister an rpmsg driver from the rpmsg bus
623 driver_unregister(&rpdrv->drv); in unregister_rpmsg_driver()
634 pr_err("failed to register rpmsg bus: %d\n", ret); in rpmsg_init()