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 .name = "rpmsg",
29 * rpmsg_create_channel() - create a new rpmsg channel
30 * using its name and address info.
31 * @rpdev: rpmsg device
34 * Return: a pointer to the new rpmsg device on success, or NULL on error.
41 if (!rpdev->ops || !rpdev->ops->create_channel) {
42 dev_err(&rpdev->dev, "no create_channel ops found\n");
46 return rpdev->ops->create_channel(rpdev, chinfo);
51 * rpmsg_release_channel() - release a rpmsg channel
52 * using its name and address info.
53 * @rpdev: rpmsg device
62 return -EINVAL;
63 if (!rpdev->ops || !rpdev->ops->release_channel) {
64 dev_err(&rpdev->dev, "no release_channel ops found\n");
65 return -ENXIO;
68 return rpdev->ops->release_channel(rpdev, chinfo);
73 * rpmsg_create_ept() - create a new rpmsg_endpoint
74 * @rpdev: rpmsg channel device
77 * @chinfo: channel_info with the local rpmsg address to bind with @cb
79 * Every rpmsg address in the system is bound to an rx callback (so when
80 * inbound messages arrive, they are dispatched by the rpmsg bus using the
84 * bind a callback, and possibly some private data too, to an rpmsg address
88 * Simple rpmsg drivers need not call rpmsg_create_ept, because an endpoint
89 * is already created for them when they are probed by the rpmsg bus
90 * (using the rx callback provided when they registered to the rpmsg bus).
93 * endpoint, their rx callback is bound to their rpmsg address, and when
95 * equals to the src address of their rpmsg channel), the driver's handler
99 * additional rpmsg addresses, and bind them to different rx callbacks.
107 * dynamically assign them an available rpmsg address (drivers should have
119 return rpdev->ops->create_ept(rpdev, cb, priv, chinfo);
124 * rpmsg_destroy_ept() - destroy an existing rpmsg endpoint
127 * Should be used by drivers to destroy an rpmsg endpoint previously
133 if (ept && ept->ops)
134 ept->ops->destroy_ept(ept);
139 * rpmsg_send() - send a message across to the remote processor
140 * @ept: the rpmsg endpoint
146 * endpoint belongs to, using @ept's address and its associated rpmsg
150 * happens, -ERESTARTSYS is returned.
159 return -EINVAL;
160 if (!ept->ops->send)
161 return -ENXIO;
163 return ept->ops->send(ept, data, len);
168 * rpmsg_sendto() - send a message across to the remote processor, specify dst
169 * @ept: the rpmsg endpoint
179 * happens, -ERESTARTSYS is returned.
188 return -EINVAL;
189 if (!ept->ops->sendto)
190 return -ENXIO;
192 return ept->ops->sendto(ept, data, len, dst);
197 * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
198 * @ept: the rpmsg endpoint
210 * happens, -ERESTARTSYS is returned.
220 return -EINVAL;
221 if (!ept->ops->send_offchannel)
222 return -ENXIO;
224 return ept->ops->send_offchannel(ept, src, dst, data, len);
229 * rpmsg_trysend() - send a message across to the remote processor
230 * @ept: the rpmsg endpoint
239 * return -ENOMEM without waiting until one becomes available.
248 return -EINVAL;
249 if (!ept->ops->trysend)
250 return -ENXIO;
252 return ept->ops->trysend(ept, data, len);
257 * rpmsg_trysendto() - send a message across to the remote processor, specify dst
258 * @ept: the rpmsg endpoint
267 * return -ENOMEM without waiting until one becomes available.
276 return -EINVAL;
277 if (!ept->ops->trysendto)
278 return -ENXIO;
280 return ept->ops->trysendto(ept, data, len, dst);
285 * rpmsg_poll() - poll the endpoint's send buffers
286 * @ept: the rpmsg endpoint
297 if (!ept->ops->poll)
300 return ept->ops->poll(ept, filp, wait);
305 * rpmsg_trysend_offchannel() - send a message using explicit src/dst addresses
306 * @ept: the rpmsg endpoint
317 * return -ENOMEM without waiting until one becomes available.
327 return -EINVAL;
328 if (!ept->ops->trysend_offchannel)
329 return -ENXIO;
331 return ept->ops->trysend_offchannel(ept, src, dst, data, len);
336 * rpmsg_set_flow_control() - request remote to pause/resume transmission
337 * @ept: the rpmsg endpoint
346 return -EINVAL;
347 if (!ept->ops->set_flow_control)
348 return -EOPNOTSUPP;
350 return ept->ops->set_flow_control(ept, pause, dst);
355 * rpmsg_get_mtu() - get maximum transmission buffer size for sending message.
356 * @ept: the rpmsg endpoint
367 return -EINVAL;
368 if (!ept->ops->get_mtu)
369 return -ENOTSUPP;
371 return ept->ops->get_mtu(ept);
376 * match a rpmsg channel with a channel info struct.
377 * this is used to make sure we're not creating rpmsg devices for channels
385 if (chinfo->src != RPMSG_ADDR_ANY && chinfo->src != rpdev->src)
388 if (chinfo->dst != RPMSG_ADDR_ANY && chinfo->dst != rpdev->dst)
391 if (strncmp(chinfo->name, rpdev->id.name, RPMSG_NAME_SIZE))
414 return sprintf(buf, format_string, rpdev->path); \
429 return -ENOMEM; \
433 old = rpdev->member; \
435 rpdev->member = new; \
438 rpdev->member = NULL; \
452 return sprintf(buf, "%s\n", rpdev->member); \
456 /* for more info, see Documentation/ABI/testing/sysfs-bus-rpmsg */
457 rpmsg_show_attr(name, id.name, "%s\n");
470 if (len != -ENODEV)
473 return sprintf(buf, RPMSG_DEVICE_MODALIAS_FMT "\n", rpdev->id.name);
488 /* rpmsg devices and drivers are matched using the service name */
492 return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
495 /* match rpmsg channel and rpmsg driver */
500 const struct rpmsg_device_id *ids = rpdrv->id_table;
503 if (rpdev->driver_override)
504 return !strcmp(rpdev->driver_override, drv->name);
507 for (i = 0; ids[i].name[0]; i++)
509 rpdev->id.driver_data = ids[i].driver_data;
522 if (ret != -ENODEV)
526 rpdev->id.name);
530 * when an rpmsg driver is probed with a channel, we seamlessly create
531 * it an endpoint, binding its rx callback to a unique local rpmsg
535 * processor (needed in case the driver is exposing an rpmsg service).
540 struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver);
549 if (rpdrv->callback) {
550 strscpy(chinfo.name, rpdev->id.name, sizeof(chinfo.name));
551 chinfo.src = rpdev->src;
554 ept = rpmsg_create_ept(rpdev, rpdrv->callback, NULL, chinfo);
557 err = -ENOMEM;
561 rpdev->ept = ept;
562 rpdev->src = ept->addr;
564 ept->flow_cb = rpdrv->flowcontrol;
567 err = rpdrv->probe(rpdev);
573 if (ept && rpdev->ops->announce_create) {
574 err = rpdev->ops->announce_create(rpdev);
584 if (rpdrv->remove)
585 rpdrv->remove(rpdev);
596 struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver);
598 if (rpdev->ops->announce_destroy)
599 rpdev->ops->announce_destroy(rpdev);
601 if (rpdrv->remove)
602 rpdrv->remove(rpdev);
606 if (rpdev->ept)
607 rpmsg_destroy_ept(rpdev->ept);
611 .name = "rpmsg",
620 * A helper for registering rpmsg device with driver override and name.
626 struct device *dev = &rpdev->dev;
630 strscpy_pad(rpdev->id.name, driver_override, RPMSG_NAME_SIZE);
632 dev_set_name(dev, "%s.%s.%d.%d", dev_name(dev->parent),
633 rpdev->id.name, rpdev->src, rpdev->dst);
635 dev->bus = &rpmsg_bus;
639 ret = driver_set_override(dev, &rpdev->driver_override,
652 kfree(rpdev->driver_override);
653 rpdev->driver_override = NULL;
668 * find an existing channel using its name + address properties,
678 return -EINVAL;
689 * __register_rpmsg_driver() - register an rpmsg driver with the rpmsg bus
697 rpdrv->drv.bus = &rpmsg_bus;
698 rpdrv->drv.owner = owner;
699 return driver_register(&rpdrv->drv);
704 * unregister_rpmsg_driver() - unregister an rpmsg driver from the rpmsg bus
711 driver_unregister(&rpdrv->drv);
722 pr_err("failed to register rpmsg class\n");
728 pr_err("failed to register rpmsg bus: %d\n", ret);