greybus: svc: fix endianness for svc message
authorRui Miguel Silva <rui.silva@linaro.org>
Tue, 15 Sep 2015 14:33:51 +0000 (15:33 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 15 Sep 2015 16:05:33 +0000 (09:05 -0700)
Some fields in svc request were not being set with the correct
endianness, which will trigger the following sparse issues as example:

greybus/svc.c:116:22: warning: incorrect type in assignment (different base types)
greybus/svc.c:116:22:    expected unsigned short [unsigned] [assigned] [usertype] attr
greybus/svc.c:116:22:    got restricted __le16 [usertype] <noident>

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/greybus_protocols.h
drivers/staging/greybus/svc.c

index 9b2d1891640343ee7b24575edc368cc8650b550e..b3d0c57ea0730f20c3b52ba092290a7e67c821b5 100644 (file)
@@ -791,9 +791,9 @@ struct gb_svc_intf_reset_request {
 
 struct gb_svc_conn_create_request {
        __u8    intf1_id;
-       __u16   cport1_id;
+       __le16  cport1_id;
        __u8    intf2_id;
-       __u16   cport2_id;
+       __le16  cport2_id;
        __u8    tc;
        __u8    flags;
 } __packed;
@@ -801,32 +801,32 @@ struct gb_svc_conn_create_request {
 
 struct gb_svc_conn_destroy_request {
        __u8    intf1_id;
-       __u16   cport1_id;
+       __le16  cport1_id;
        __u8    intf2_id;
-       __u16   cport2_id;
+       __le16  cport2_id;
 } __packed;
 /* connection destroy response has no payload */
 
 struct gb_svc_dme_peer_get_request {
        __u8    intf_id;
-       __u16   attr;
-       __u16   selector;
+       __le16  attr;
+       __le16  selector;
 } __packed;
 
 struct gb_svc_dme_peer_get_response {
-       __u16   result_code;
-       __u32   attr_value;
+       __le16  result_code;
+       __le32  attr_value;
 } __packed;
 
 struct gb_svc_dme_peer_set_request {
        __u8    intf_id;
-       __u16   attr;
-       __u16   selector;
-       __u32   value;
+       __le16  attr;
+       __le16  selector;
+       __le32  value;
 } __packed;
 
 struct gb_svc_dme_peer_set_response {
-       __u16   result_code;
+       __le16  result_code;
 } __packed;
 
 struct gb_svc_route_create_request {
index 28f03dc463f35a5a21ef44e948d1df20a4ab516a..35e2fb525dfae211c9ef9e50c6afe2107dd4c76a 100644 (file)
@@ -183,9 +183,9 @@ int gb_svc_connection_create(struct gb_svc *svc,
        struct gb_svc_conn_create_request request;
 
        request.intf1_id = intf1_id;
-       request.cport1_id = cport1_id;
+       request.cport1_id = cpu_to_le16(cport1_id);
        request.intf2_id = intf2_id;
-       request.cport2_id = cport2_id;
+       request.cport2_id = cpu_to_le16(cport2_id);
        /*
         * XXX: fix connections paramaters to TC0 and all CPort flags
         * for now.
@@ -206,9 +206,9 @@ void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
        int ret;
 
        request.intf1_id = intf1_id;
-       request.cport1_id = cport1_id;
+       request.cport1_id = cpu_to_le16(cport1_id);
        request.intf2_id = intf2_id;
-       request.cport2_id = cport2_id;
+       request.cport2_id = cpu_to_le16(cport2_id);
 
        ret = gb_operation_sync(connection, GB_SVC_TYPE_CONN_DESTROY,
                                &request, sizeof(request), NULL, 0);