aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Tivy2013-08-16 19:23:31 -0500
committerSuman Anna2014-08-29 15:22:08 -0500
commit3fa545f178ee6f2289f861dbd18103af2cc7351d (patch)
tree271d40f066380c07766901cd3ddc659b11738820
parentcafd726e6b1927329f5aab91d78c6eee3967ddaf (diff)
downloadkernel-video-3fa545f178ee6f2289f861dbd18103af2cc7351d.tar.gz
kernel-video-3fa545f178ee6f2289f861dbd18103af2cc7351d.tar.xz
kernel-video-3fa545f178ee6f2289f861dbd18103af2cc7351d.zip
rpmsg: add api for creating and deleting rpmsg channels
The rpmsg channels are currently created and deleted only through the device announcements from a remote processor. Two new exported functions, rpmsg_create_channel and rpmsg_destroy_channel, are added to be able to create and delete a rpmsg channel on a particular virtual processor. This is required for creating/deleting a channel from the HLOS-side (needed by the rpmsg socket driver). Signed-off-by: Robert Tivy <rtivy@ti.com> [s-anna@ti.com: add delete channel api and documentation] Signed-off-by: Suman Anna <s-anna@ti.com>
-rw-r--r--drivers/rpmsg/virtio_rpmsg_bus.c72
-rw-r--r--include/linux/rpmsg.h4
2 files changed, 70 insertions, 6 deletions
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index b142a0e5e4f..4ce5f43a54a 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -502,7 +502,7 @@ static int rpmsg_channel_match(struct device *dev, void *data)
502 * this function will be used to create both static and dynamic 502 * this function will be used to create both static and dynamic
503 * channels. 503 * channels.
504 */ 504 */
505static struct rpmsg_channel *rpmsg_create_channel(struct virtproc_info *vrp, 505static struct rpmsg_channel *__rpmsg_create_channel(struct virtproc_info *vrp,
506 struct rpmsg_channel_info *chinfo) 506 struct rpmsg_channel_info *chinfo)
507{ 507{
508 struct rpmsg_channel *rpdev; 508 struct rpmsg_channel *rpdev;
@@ -556,11 +556,42 @@ static struct rpmsg_channel *rpmsg_create_channel(struct virtproc_info *vrp,
556 return rpdev; 556 return rpdev;
557} 557}
558 558
559/**
560 * rpmsg_create_channel - create a rpmsg channel using its name, desc, id and
561 * address
562 * @vrp: the virtual processor on which this channel is being created
563 * @name: name of the rpmsg channel
564 * @desc: description of the rpmsg channel
565 * @src: source end-point address for the channel
566 * @dst: destination end-point address for the channel
567 *
568 * This function provides a means to create new rpmsg channels on a particular
569 * virtual processor. The caller supplies the address info, name and descriptor
570 * for the channel. This is useful when creating channels from the host side.
571 *
572 * Return: a pointer to a newly created rpmsg channel device on success,
573 * or NULL on failure
574 */
575struct rpmsg_channel *rpmsg_create_channel(struct virtproc_info *vrp,
576 const char *name, const char *desc,
577 int src, int dst)
578{
579 struct rpmsg_channel_info chinfo;
580
581 strncpy(chinfo.name, name, sizeof(chinfo.name));
582 strncpy(chinfo.desc, desc, sizeof(chinfo.desc));
583 chinfo.src = src;
584 chinfo.dst = dst;
585
586 return __rpmsg_create_channel(vrp, &chinfo);
587}
588EXPORT_SYMBOL(rpmsg_create_channel);
589
559/* 590/*
560 * find an existing channel using its name + address properties, 591 * find an existing channel using its name + address properties,
561 * and destroy it 592 * and destroy it
562 */ 593 */
563static int rpmsg_destroy_channel(struct virtproc_info *vrp, 594static int __rpmsg_destroy_channel(struct virtproc_info *vrp,
564 struct rpmsg_channel_info *chinfo) 595 struct rpmsg_channel_info *chinfo)
565{ 596{
566 struct virtio_device *vdev = vrp->vdev; 597 struct virtio_device *vdev = vrp->vdev;
@@ -577,6 +608,34 @@ static int rpmsg_destroy_channel(struct virtproc_info *vrp,
577 return 0; 608 return 0;
578} 609}
579 610
611/**
612 * rpmsg_destroy_channel - destroy a rpmsg channel
613 * @rpdev: rpmsg channel to be destroyed
614 *
615 * This function is the primary means to destroy a rpmsg channel that was
616 * created from the host-side. This API is strictly intended to be used only
617 * for channels created using the rpmsg_create_channel API.
618 *
619 * Return: 0 on success, or a failure code otherwise
620 */
621int rpmsg_destroy_channel(struct rpmsg_channel *rpdev)
622{
623 struct device *dev;
624 struct virtio_device *vdev = rpmsg_get_virtio_dev(rpdev);
625
626 if (!rpdev || !vdev)
627 return -EINVAL;
628
629 dev = &rpdev->dev;
630 if (dev->bus != &rpmsg_bus || dev->parent != &vdev->dev)
631 return -EINVAL;
632
633 device_unregister(dev);
634
635 return 0;
636}
637EXPORT_SYMBOL(rpmsg_destroy_channel);
638
580/* super simple buffer "allocator" that is just enough for now */ 639/* super simple buffer "allocator" that is just enough for now */
581static void *get_a_tx_buf(struct virtproc_info *vrp) 640static void *get_a_tx_buf(struct virtproc_info *vrp)
582{ 641{
@@ -964,13 +1023,14 @@ static void rpmsg_ns_cb(struct rpmsg_channel *rpdev, void *data, int len,
964 chinfo.dst = msg->addr; 1023 chinfo.dst = msg->addr;
965 1024
966 if (msg->flags & RPMSG_NS_DESTROY) { 1025 if (msg->flags & RPMSG_NS_DESTROY) {
967 ret = rpmsg_destroy_channel(vrp, &chinfo); 1026 ret = __rpmsg_destroy_channel(vrp, &chinfo);
968 if (ret) 1027 if (ret)
969 dev_err(dev, "rpmsg_destroy_channel failed: %d\n", ret); 1028 dev_err(dev, "__rpmsg_destroy_channel failed: %d\n",
1029 ret);
970 } else { 1030 } else {
971 newch = rpmsg_create_channel(vrp, &chinfo); 1031 newch = __rpmsg_create_channel(vrp, &chinfo);
972 if (!newch) 1032 if (!newch)
973 dev_err(dev, "rpmsg_create_channel failed\n"); 1033 dev_err(dev, "__rpmsg_create_channel failed\n");
974 } 1034 }
975} 1035}
976 1036
diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h
index 97aa98ccbfd..fe00b06536f 100644
--- a/include/linux/rpmsg.h
+++ b/include/linux/rpmsg.h
@@ -181,6 +181,10 @@ struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *,
181int 181int
182rpmsg_send_offchannel_raw(struct rpmsg_channel *, u32, u32, void *, int, bool); 182rpmsg_send_offchannel_raw(struct rpmsg_channel *, u32, u32, void *, int, bool);
183struct virtio_device *rpmsg_get_virtio_dev(struct rpmsg_channel *rpdev); 183struct virtio_device *rpmsg_get_virtio_dev(struct rpmsg_channel *rpdev);
184struct rpmsg_channel *rpmsg_create_channel(struct virtproc_info *vrp,
185 const char *name, const char *desc,
186 int src, int dst);
187int rpmsg_destroy_channel(struct rpmsg_channel *rpdev);
184 188
185/** 189/**
186 * rpmsg_send() - send a message across to the remote processor 190 * rpmsg_send() - send a message across to the remote processor