]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: move versioning from svc message header to handshake function
authorMatt Porter <mporter@linaro.org>
Thu, 18 Sep 2014 19:25:42 +0000 (15:25 -0400)
committerGreg Kroah-Hartman <greg@kroah.com>
Fri, 19 Sep 2014 03:06:08 +0000 (20:06 -0700)
The Greybus spec has been updated to improve the efficiency of the
version major/minor information that had been previously carried in
every SVC message header. The version major/minor is now provided
as part of the handshake function.

Update the SVC msg header and handshake function payload definitions
and move the version major/minor validation into the SVC handshake
handling routine.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/ap.c
drivers/staging/greybus/svc_msg.h

index c2c5aa654e7ec31bbc1bd65b1f3a4fcd591448de..2a60de0cec89c0368c57741b5c53e34bb6df917a 100644 (file)
@@ -65,7 +65,15 @@ static void svc_handshake(struct svc_function_handshake *handshake,
 {
        struct svc_msg *svc_msg;
 
-       /* A new SVC communication channel, let's verify it was for us */
+       /* A new SVC communication channel, let's verify a supported version */
+       if ((handshake->version_major != GREYBUS_VERSION_MAJOR) &&
+           (handshake->version_minor != GREYBUS_VERSION_MINOR)) {
+               dev_dbg(hd->parent, "received invalid greybus version %d:%d\n",
+                       handshake->version_major, handshake->version_minor);
+               return;
+       }
+
+       /* Validate that the handshake came from the SVC */
        if (handshake->handshake_type != SVC_HANDSHAKE_SVC_HELLO) {
                /* we don't know what to do with this, log it and return */
                dev_dbg(hd->parent, "received invalid handshake type %d\n",
@@ -162,11 +170,6 @@ static struct svc_msg *convert_ap_message(struct ap_msg *ap_msg)
 
        svc_msg = (struct svc_msg *)ap_msg->data;
 
-       /* Verify the version is something we can handle with this code */
-       if ((svc_msg->header.version_major != GREYBUS_VERSION_MAJOR) &&
-           (svc_msg->header.version_minor != GREYBUS_VERSION_MINOR))
-               return NULL;
-
        return svc_msg;
 }
 
index 3f1a93499aee546cba2fbe89bea28f37ecc0c8d2..e84e01cf3cce1a0a73dc7a0b37aa801ba14686a5 100644 (file)
@@ -30,8 +30,6 @@ enum svc_msg_type {
 struct svc_msg_header {
        __u8    function_id;    /* enum svc_function_id */
        __u8    message_type;
-       __u8    version_major;
-       __u8    version_minor;
        __le16  payload_length;
 };
 
@@ -42,6 +40,8 @@ enum svc_function_handshake_type {
 };
 
 struct svc_function_handshake {
+       __u8    version_major;
+       __u8    version_minor;
        __u8    handshake_type; /* enum svc_function_handshake_type */
 };