greybus: camera: Fix endian conversion issues
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Fri, 18 Dec 2015 19:23:21 +0000 (21:23 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 22 Dec 2015 00:34:46 +0000 (16:34 -0800)
Convert all Greybus operation fields between CPU and protocol
endianness.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reported-by: Rui Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/camera.c

index b7d9384e9471c205c8954a9fd8ab3333fe61a778..545ed632901ada4a58c4df988e53d65318791132 100644 (file)
@@ -103,9 +103,9 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
        for (i = 0; i < nstreams; ++i) {
                struct gb_camera_stream_config_request *cfg = &req->config[i];
 
-               cfg->width = streams[i].width;
-               cfg->height = streams[i].height;
-               cfg->format = streams[i].format;
+               cfg->width = cpu_to_le16(streams[i].width);
+               cfg->height = cpu_to_le16(streams[i].height);
+               cfg->format = cpu_to_le16(streams[i].format);
                cfg->padding = 0;
        }
 
@@ -131,13 +131,13 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
        for (i = 0; i < nstreams; ++i) {
                struct gb_camera_stream_config_response *cfg = &resp->config[i];
 
-               streams[i].width = cfg->width;
-               streams[i].height = cfg->height;
-               streams[i].format = cfg->format;
+               streams[i].width = le16_to_cpu(cfg->width);
+               streams[i].height = le16_to_cpu(cfg->height);
+               streams[i].format = le16_to_cpu(cfg->format);
                streams[i].vc = cfg->virtual_channel;
                streams[i].dt[0] = cfg->data_type[0];
                streams[i].dt[1] = cfg->data_type[1];
-               streams[i].max_size = cfg->max_size;
+               streams[i].max_size = le32_to_cpu(cfg->max_size);
 
                if (cfg->padding[0] || cfg->padding[1] || cfg->padding[2]) {
                        gcam_dbg(gcam, "stream #%u padding != 0", i);
@@ -169,10 +169,10 @@ static int gb_camera_capture(struct gb_camera *gcam, u32 request_id,
        if (!req)
                return -ENOMEM;
 
-       req->request_id = request_id;
+       req->request_id = cpu_to_le32(request_id);
        req->streams = streams;
        req->padding = 0;
-       req->num_frames = num_frames;
+       req->num_frames = cpu_to_le16(num_frames);
        memcpy(req->settings, settings, settings_size);
 
        return gb_operation_sync(gcam->connection, GB_CAMERA_TYPE_CAPTURE,
@@ -190,7 +190,7 @@ static int gb_camera_flush(struct gb_camera *gcam, u32 *request_id)
                return ret;
 
        if (request_id)
-               *request_id = resp.request_id;
+               *request_id = le32_to_cpu(resp.request_id);
 
        return 0;
 }