]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/kernel-video.git/commitdiff
rpmsg: add a description field
authorOhad Ben-Cohen <ohad@wizery.com>
Sun, 4 Nov 2012 10:08:21 +0000 (12:08 +0200)
committerSuman Anna <s-anna@ti.com>
Fri, 30 Aug 2013 23:11:05 +0000 (18:11 -0500)
Add a new description field to the rpmsg bus infrastructure
that can be passed onto the rpmsg client drivers for additional
information. The current rpmsg bus client drivers need to have
a fixed id_table for proper matching, this new field can allow
flexibility for the client drivers (eg: like creating unique
cdevs).

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
drivers/rpmsg/virtio_rpmsg_bus.c
include/linux/rpmsg.h

index 20c2bc4ea738834ba51179b86f98ec2c8ab102d2..20203e97312dea6a430cbc5a90c99fa87e4d5111 100644 (file)
@@ -73,11 +73,13 @@ struct virtproc_info {
 /**
  * struct rpmsg_channel_info - internal channel info representation
  * @name: name of service
+ * @desc: description of service
  * @src: local address
  * @dst: destination address
  */
 struct rpmsg_channel_info {
        char name[RPMSG_NAME_SIZE];
+       char desc[RPMSG_NAME_SIZE];
        u32 src;
        u32 dst;
 };
@@ -131,6 +133,7 @@ field##_show(struct device *dev,                                    \
 rpmsg_show_attr(name, id.name, "%s\n");
 rpmsg_show_attr(src, src, "0x%x\n");
 rpmsg_show_attr(dst, dst, "0x%x\n");
+rpmsg_show_attr(desc, desc, "%s\n");
 rpmsg_show_attr(announce, announce ? "true" : "false", "%s\n");
 
 /*
@@ -151,6 +154,7 @@ static ssize_t modalias_show(struct device *dev,
 
 static struct device_attribute rpmsg_dev_attrs[] = {
        __ATTR_RO(name),
+       __ATTR_RO(desc),
        __ATTR_RO(modalias),
        __ATTR_RO(dst),
        __ATTR_RO(src),
@@ -158,7 +162,7 @@ static struct device_attribute rpmsg_dev_attrs[] = {
        __ATTR_NULL
 };
 
-/* rpmsg devices and drivers are matched using the service name */
+/* rpmsg devices and drivers are matched using the service name only */
 static inline int rpmsg_id_match(const struct rpmsg_channel *rpdev,
                                  const struct rpmsg_device_id *id)
 {
@@ -490,6 +494,9 @@ static int rpmsg_channel_match(struct device *dev, void *data)
        if (strncmp(chinfo->name, rpdev->id.name, RPMSG_NAME_SIZE))
                return 0;
 
+       if (strncmp(chinfo->desc, rpdev->desc, RPMSG_NAME_SIZE))
+               return 0;
+
        /* found a match ! */
        return 1;
 }
@@ -511,8 +518,9 @@ static struct rpmsg_channel *rpmsg_create_channel(struct virtproc_info *vrp,
        if (tmp) {
                /* decrement the matched device's refcount back */
                put_device(tmp);
-               dev_err(dev, "channel %s:%x:%x already exist\n",
-                               chinfo->name, chinfo->src, chinfo->dst);
+               dev_err(dev, "channel %s:%s:%x:%x already exist\n",
+                               chinfo->name, chinfo->desc,
+                               chinfo->src, chinfo->dst);
                return NULL;
        }
 
@@ -525,6 +533,7 @@ static struct rpmsg_channel *rpmsg_create_channel(struct virtproc_info *vrp,
        rpdev->vrp = vrp;
        rpdev->src = chinfo->src;
        rpdev->dst = chinfo->dst;
+       strncpy(rpdev->desc, chinfo->desc, RPMSG_NAME_SIZE);
 
        /*
         * rpmsg server channels has predefined local address (for now),
@@ -954,6 +963,7 @@ static void rpmsg_ns_cb(struct rpmsg_channel *rpdev, void *data, int len,
                        msg->name, msg->addr);
 
        strncpy(chinfo.name, msg->name, sizeof(chinfo.name));
+       strncpy(chinfo.desc, msg->desc, sizeof(chinfo.desc));
        chinfo.src = RPMSG_ADDR_ANY;
        chinfo.dst = msg->addr;
 
index 8e9cfa213a9c19ac47aaeec914f6c15db4ab71ee..97aa98ccbfda5efdd775b8cbfc345a36a8382235 100644 (file)
@@ -66,7 +66,8 @@ struct rpmsg_hdr {
 
 /**
  * struct rpmsg_ns_msg - dynamic name service announcement message
- * @name: name of remote service that is published
+ * @name: name of remote service that is being published
+ * @desc: description of remote service
  * @addr: address of remote service that is published
  * @flags: indicates whether service is created or destroyed
  *
@@ -78,6 +79,7 @@ struct rpmsg_hdr {
  */
 struct rpmsg_ns_msg {
        char name[RPMSG_NAME_SIZE];
+       char desc[RPMSG_NAME_SIZE];
        u32 addr;
        u32 flags;
 } __packed;
@@ -102,6 +104,7 @@ struct virtproc_info;
  * @vrp: the remote processor this channel belongs to
  * @dev: the device struct
  * @id: device id (used to match between rpmsg drivers and devices)
+ * @desc: description of remote service
  * @src: local address
  * @dst: destination address
  * @ept: the rpmsg endpoint of this channel
@@ -111,6 +114,7 @@ struct rpmsg_channel {
        struct virtproc_info *vrp;
        struct device dev;
        struct rpmsg_device_id id;
+       char desc[RPMSG_NAME_SIZE];
        u32 src;
        u32 dst;
        struct rpmsg_endpoint *ept;