Commit f10127cd authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: staging: atomisp: fix endianess issues

There are lots of be-related warnings there, as it doesn't properly
mark what data uses bigendian.

Warnings fixed:

    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:134:15: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:134:15:    expected unsigned short [unsigned] [short] [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:134:15:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:140:26: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:140:26: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:140:26: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:140:26: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:144:26: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:144:26: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:144:26: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:144:26: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:144:26: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:144:26: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:256:27: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:256:27:    expected unsigned short [unsigned] [usertype] addr
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:256:27:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:302:25: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:302:25:    expected unsigned short [unsigned] [short] [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:302:25:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:306:25: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:306:25:    expected unsigned int [unsigned] [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:306:25:    got restricted __be32 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:97:24: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:97:24: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:97:24: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:97:24: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:99:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:99:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:99:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:99:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:99:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:99:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:134:15: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:134:15:    expected unsigned short [unsigned] [short] [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:134:15:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:141:24: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:141:24:    expected unsigned short [unsigned] [short] [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:141:24:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:177:27: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:177:27:    expected unsigned short [unsigned] [usertype] addr
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:177:27:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:198:25: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:198:25:    expected unsigned short [unsigned] [short] [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:198:25:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:88:24: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:88:24: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:88:24: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:88:24: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:90:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:90:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:90:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:90:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:90:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:90:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:125:15: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:125:15:    expected unsigned short [unsigned] [short] [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:125:15:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:132:24: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:132:24:    expected unsigned short [unsigned] [short] [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:132:24:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:168:27: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:168:27:    expected unsigned short [unsigned] [usertype] addr
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:168:27:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:189:25: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:189:25:    expected unsigned short [unsigned] [short] [usertype] <noident>
    drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:189:25:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:176:24: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:176:24: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:176:24: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:176:24: warning: cast to restricted __be16
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:178:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:178:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:178:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:178:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:178:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:178:24: warning: cast to restricted __be32
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:205:13: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:205:13:    expected unsigned short [unsigned] [usertype] val
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:205:13:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:276:15: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:276:15:    expected unsigned short [unsigned] [short] [usertype] <noident>
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:276:15:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:283:24: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:283:24:    expected unsigned short [unsigned] [short] [usertype] <noident>
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:283:24:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:319:27: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:319:27:    expected unsigned short [unsigned] [usertype] addr
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:319:27:    got restricted __be16 [usertype] <noident>
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:340:25: warning: incorrect type in assignment (different base types)
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:340:25:    expected unsigned short [unsigned] [short] [usertype] <noident>
    drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c:340:25:    got restricted __be16 [usertype] <noident>
Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent c3a9880f
...@@ -107,7 +107,7 @@ mt9m114_write_reg(struct i2c_client *client, u16 data_length, u16 reg, u32 val) ...@@ -107,7 +107,7 @@ mt9m114_write_reg(struct i2c_client *client, u16 data_length, u16 reg, u32 val)
int num_msg; int num_msg;
struct i2c_msg msg; struct i2c_msg msg;
unsigned char data[6] = {0}; unsigned char data[6] = {0};
u16 *wreg; __be16 *wreg;
int retry = 0; int retry = 0;
if (!client->adapter) { if (!client->adapter) {
...@@ -130,18 +130,20 @@ mt9m114_write_reg(struct i2c_client *client, u16 data_length, u16 reg, u32 val) ...@@ -130,18 +130,20 @@ mt9m114_write_reg(struct i2c_client *client, u16 data_length, u16 reg, u32 val)
msg.buf = data; msg.buf = data;
/* high byte goes out first */ /* high byte goes out first */
wreg = (u16 *)data; wreg = (void *)data;
*wreg = cpu_to_be16(reg); *wreg = cpu_to_be16(reg);
if (data_length == MISENSOR_8BIT) { if (data_length == MISENSOR_8BIT) {
data[2] = (u8)(val); data[2] = (u8)(val);
} else if (data_length == MISENSOR_16BIT) { } else if (data_length == MISENSOR_16BIT) {
u16 *wdata = (u16 *)&data[2]; u16 *wdata = (void *)&data[2];
*wdata = be16_to_cpu((u16)val);
*wdata = be16_to_cpu(*(__be16 *)&data[2]);
} else { } else {
/* MISENSOR_32BIT */ /* MISENSOR_32BIT */
u32 *wdata = (u32 *)&data[2]; u32 *wdata = (void *)&data[2];
*wdata = be32_to_cpu(val);
*wdata = be32_to_cpu(*(__be32 *)&data[2]);
} }
num_msg = i2c_transfer(client->adapter, &msg, 1); num_msg = i2c_transfer(client->adapter, &msg, 1);
...@@ -245,6 +247,7 @@ static int __mt9m114_flush_reg_array(struct i2c_client *client, ...@@ -245,6 +247,7 @@ static int __mt9m114_flush_reg_array(struct i2c_client *client,
const int num_msg = 1; const int num_msg = 1;
int ret; int ret;
int retry = 0; int retry = 0;
__be16 *data16 = (void *)&ctrl->buffer.addr;
if (ctrl->index == 0) if (ctrl->index == 0)
return 0; return 0;
...@@ -253,7 +256,7 @@ static int __mt9m114_flush_reg_array(struct i2c_client *client, ...@@ -253,7 +256,7 @@ static int __mt9m114_flush_reg_array(struct i2c_client *client,
msg.addr = client->addr; msg.addr = client->addr;
msg.flags = 0; msg.flags = 0;
msg.len = 2 + ctrl->index; msg.len = 2 + ctrl->index;
ctrl->buffer.addr = cpu_to_be16(ctrl->buffer.addr); *data16 = cpu_to_be16(ctrl->buffer.addr);
msg.buf = (u8 *)&ctrl->buffer; msg.buf = (u8 *)&ctrl->buffer;
ret = i2c_transfer(client->adapter, &msg, num_msg); ret = i2c_transfer(client->adapter, &msg, num_msg);
...@@ -282,8 +285,8 @@ static int __mt9m114_buf_reg_array(struct i2c_client *client, ...@@ -282,8 +285,8 @@ static int __mt9m114_buf_reg_array(struct i2c_client *client,
struct mt9m114_write_ctrl *ctrl, struct mt9m114_write_ctrl *ctrl,
const struct misensor_reg *next) const struct misensor_reg *next)
{ {
u16 *data16; __be16 *data16;
u32 *data32; __be32 *data32;
int err; int err;
/* Insufficient buffer? Let's flush and get more free space. */ /* Insufficient buffer? Let's flush and get more free space. */
...@@ -298,11 +301,11 @@ static int __mt9m114_buf_reg_array(struct i2c_client *client, ...@@ -298,11 +301,11 @@ static int __mt9m114_buf_reg_array(struct i2c_client *client,
ctrl->buffer.data[ctrl->index] = (u8)next->val; ctrl->buffer.data[ctrl->index] = (u8)next->val;
break; break;
case MISENSOR_16BIT: case MISENSOR_16BIT:
data16 = (u16 *)&ctrl->buffer.data[ctrl->index]; data16 = (__be16 *)&ctrl->buffer.data[ctrl->index];
*data16 = cpu_to_be16((u16)next->val); *data16 = cpu_to_be16((u16)next->val);
break; break;
case MISENSOR_32BIT: case MISENSOR_32BIT:
data32 = (u32 *)&ctrl->buffer.data[ctrl->index]; data32 = (__be32 *)&ctrl->buffer.data[ctrl->index];
*data32 = cpu_to_be32(next->val); *data32 = cpu_to_be32(next->val);
break; break;
default: default:
......
...@@ -94,9 +94,9 @@ static int ov2680_read_reg(struct i2c_client *client, ...@@ -94,9 +94,9 @@ static int ov2680_read_reg(struct i2c_client *client,
if (data_length == OV2680_8BIT) if (data_length == OV2680_8BIT)
*val = (u8)data[0]; *val = (u8)data[0];
else if (data_length == OV2680_16BIT) else if (data_length == OV2680_16BIT)
*val = be16_to_cpu(*(u16 *)&data[0]); *val = be16_to_cpu(*(__be16 *)&data[0]);
else else
*val = be32_to_cpu(*(u32 *)&data[0]); *val = be32_to_cpu(*(__be32 *)&data[0]);
//dev_dbg(&client->dev, "++++i2c read adr%x = %x\n", reg,*val); //dev_dbg(&client->dev, "++++i2c read adr%x = %x\n", reg,*val);
return 0; return 0;
} }
...@@ -121,7 +121,7 @@ static int ov2680_write_reg(struct i2c_client *client, u16 data_length, ...@@ -121,7 +121,7 @@ static int ov2680_write_reg(struct i2c_client *client, u16 data_length,
{ {
int ret; int ret;
unsigned char data[4] = {0}; unsigned char data[4] = {0};
u16 *wreg = (u16 *)data; __be16 *wreg = (void *)data;
const u16 len = data_length + sizeof(u16); /* 16-bit address + data */ const u16 len = data_length + sizeof(u16); /* 16-bit address + data */
if (data_length != OV2680_8BIT && data_length != OV2680_16BIT) { if (data_length != OV2680_8BIT && data_length != OV2680_16BIT) {
...@@ -137,7 +137,8 @@ static int ov2680_write_reg(struct i2c_client *client, u16 data_length, ...@@ -137,7 +137,8 @@ static int ov2680_write_reg(struct i2c_client *client, u16 data_length,
data[2] = (u8)(val); data[2] = (u8)(val);
} else { } else {
/* OV2680_16BIT */ /* OV2680_16BIT */
u16 *wdata = (u16 *)&data[2]; __be16 *wdata = (void *)&data[2];
*wdata = cpu_to_be16(val); *wdata = cpu_to_be16(val);
} }
...@@ -169,12 +170,13 @@ static int __ov2680_flush_reg_array(struct i2c_client *client, ...@@ -169,12 +170,13 @@ static int __ov2680_flush_reg_array(struct i2c_client *client,
struct ov2680_write_ctrl *ctrl) struct ov2680_write_ctrl *ctrl)
{ {
u16 size; u16 size;
__be16 *data16 = (void *)&ctrl->buffer.addr;
if (ctrl->index == 0) if (ctrl->index == 0)
return 0; return 0;
size = sizeof(u16) + ctrl->index; /* 16-bit address + data */ size = sizeof(u16) + ctrl->index; /* 16-bit address + data */
ctrl->buffer.addr = cpu_to_be16(ctrl->buffer.addr); *data16 = cpu_to_be16(ctrl->buffer.addr);
ctrl->index = 0; ctrl->index = 0;
return ov2680_i2c_write(client, size, (u8 *)&ctrl->buffer); return ov2680_i2c_write(client, size, (u8 *)&ctrl->buffer);
...@@ -185,7 +187,7 @@ static int __ov2680_buf_reg_array(struct i2c_client *client, ...@@ -185,7 +187,7 @@ static int __ov2680_buf_reg_array(struct i2c_client *client,
const struct ov2680_reg *next) const struct ov2680_reg *next)
{ {
int size; int size;
u16 *data16; __be16 *data16;
switch (next->type) { switch (next->type) {
case OV2680_8BIT: case OV2680_8BIT:
...@@ -194,7 +196,7 @@ static int __ov2680_buf_reg_array(struct i2c_client *client, ...@@ -194,7 +196,7 @@ static int __ov2680_buf_reg_array(struct i2c_client *client,
break; break;
case OV2680_16BIT: case OV2680_16BIT:
size = 2; size = 2;
data16 = (u16 *)&ctrl->buffer.data[ctrl->index]; data16 = (void *)&ctrl->buffer.data[ctrl->index];
*data16 = cpu_to_be16((u16)next->val); *data16 = cpu_to_be16((u16)next->val);
break; break;
default: default:
......
...@@ -85,9 +85,9 @@ static int ov2722_read_reg(struct i2c_client *client, ...@@ -85,9 +85,9 @@ static int ov2722_read_reg(struct i2c_client *client,
if (data_length == OV2722_8BIT) if (data_length == OV2722_8BIT)
*val = (u8)data[0]; *val = (u8)data[0];
else if (data_length == OV2722_16BIT) else if (data_length == OV2722_16BIT)
*val = be16_to_cpu(*(u16 *)&data[0]); *val = be16_to_cpu(*(__be16 *)&data[0]);
else else
*val = be32_to_cpu(*(u32 *)&data[0]); *val = be32_to_cpu(*(__be32 *)&data[0]);
return 0; return 0;
} }
...@@ -112,7 +112,7 @@ static int ov2722_write_reg(struct i2c_client *client, u16 data_length, ...@@ -112,7 +112,7 @@ static int ov2722_write_reg(struct i2c_client *client, u16 data_length,
{ {
int ret; int ret;
unsigned char data[4] = {0}; unsigned char data[4] = {0};
u16 *wreg = (u16 *)data; __be16 *wreg = (__be16 *)data;
const u16 len = data_length + sizeof(u16); /* 16-bit address + data */ const u16 len = data_length + sizeof(u16); /* 16-bit address + data */
if (data_length != OV2722_8BIT && data_length != OV2722_16BIT) { if (data_length != OV2722_8BIT && data_length != OV2722_16BIT) {
...@@ -128,7 +128,8 @@ static int ov2722_write_reg(struct i2c_client *client, u16 data_length, ...@@ -128,7 +128,8 @@ static int ov2722_write_reg(struct i2c_client *client, u16 data_length,
data[2] = (u8)(val); data[2] = (u8)(val);
} else { } else {
/* OV2722_16BIT */ /* OV2722_16BIT */
u16 *wdata = (u16 *)&data[2]; __be16 *wdata = (__be16 *)&data[2];
*wdata = cpu_to_be16(val); *wdata = cpu_to_be16(val);
} }
...@@ -160,12 +161,13 @@ static int __ov2722_flush_reg_array(struct i2c_client *client, ...@@ -160,12 +161,13 @@ static int __ov2722_flush_reg_array(struct i2c_client *client,
struct ov2722_write_ctrl *ctrl) struct ov2722_write_ctrl *ctrl)
{ {
u16 size; u16 size;
__be16 *data16 = (void *)&ctrl->buffer.addr;
if (ctrl->index == 0) if (ctrl->index == 0)
return 0; return 0;
size = sizeof(u16) + ctrl->index; /* 16-bit address + data */ size = sizeof(u16) + ctrl->index; /* 16-bit address + data */
ctrl->buffer.addr = cpu_to_be16(ctrl->buffer.addr); *data16 = cpu_to_be16(ctrl->buffer.addr);
ctrl->index = 0; ctrl->index = 0;
return ov2722_i2c_write(client, size, (u8 *)&ctrl->buffer); return ov2722_i2c_write(client, size, (u8 *)&ctrl->buffer);
...@@ -176,7 +178,7 @@ static int __ov2722_buf_reg_array(struct i2c_client *client, ...@@ -176,7 +178,7 @@ static int __ov2722_buf_reg_array(struct i2c_client *client,
const struct ov2722_reg *next) const struct ov2722_reg *next)
{ {
int size; int size;
u16 *data16; __be16 *data16;
switch (next->type) { switch (next->type) {
case OV2722_8BIT: case OV2722_8BIT:
...@@ -185,7 +187,7 @@ static int __ov2722_buf_reg_array(struct i2c_client *client, ...@@ -185,7 +187,7 @@ static int __ov2722_buf_reg_array(struct i2c_client *client,
break; break;
case OV2722_16BIT: case OV2722_16BIT:
size = 2; size = 2;
data16 = (u16 *)&ctrl->buffer.data[ctrl->index]; data16 = (void *)&ctrl->buffer.data[ctrl->index];
*data16 = cpu_to_be16((u16)next->val); *data16 = cpu_to_be16((u16)next->val);
break; break;
default: default:
......
...@@ -173,9 +173,9 @@ static int ov5693_read_reg(struct i2c_client *client, ...@@ -173,9 +173,9 @@ static int ov5693_read_reg(struct i2c_client *client,
if (data_length == OV5693_8BIT) if (data_length == OV5693_8BIT)
*val = (u8)data[0]; *val = (u8)data[0];
else if (data_length == OV5693_16BIT) else if (data_length == OV5693_16BIT)
*val = be16_to_cpu(*(u16 *)&data[0]); *val = be16_to_cpu(*(__be16 *)&data[0]);
else else
*val = be32_to_cpu(*(u32 *)&data[0]); *val = be32_to_cpu(*(__be32 *)&data[0]);
return 0; return 0;
} }
...@@ -200,13 +200,13 @@ static int vcm_dw_i2c_write(struct i2c_client *client, u16 data) ...@@ -200,13 +200,13 @@ static int vcm_dw_i2c_write(struct i2c_client *client, u16 data)
struct i2c_msg msg; struct i2c_msg msg;
const int num_msg = 1; const int num_msg = 1;
int ret; int ret;
u16 val; __be16 val;
val = cpu_to_be16(data); val = cpu_to_be16(data);
msg.addr = VCM_ADDR; msg.addr = VCM_ADDR;
msg.flags = 0; msg.flags = 0;
msg.len = OV5693_16BIT; msg.len = OV5693_16BIT;
msg.buf = (u8 *)&val; msg.buf = (void *)&val;
ret = i2c_transfer(client->adapter, &msg, 1); ret = i2c_transfer(client->adapter, &msg, 1);
...@@ -263,7 +263,7 @@ static int ov5693_write_reg(struct i2c_client *client, u16 data_length, ...@@ -263,7 +263,7 @@ static int ov5693_write_reg(struct i2c_client *client, u16 data_length,
{ {
int ret; int ret;
unsigned char data[4] = {0}; unsigned char data[4] = {0};
u16 *wreg = (u16 *)data; __be16 *wreg = (void *)data;
const u16 len = data_length + sizeof(u16); /* 16-bit address + data */ const u16 len = data_length + sizeof(u16); /* 16-bit address + data */
if (data_length != OV5693_8BIT && data_length != OV5693_16BIT) { if (data_length != OV5693_8BIT && data_length != OV5693_16BIT) {
...@@ -279,7 +279,8 @@ static int ov5693_write_reg(struct i2c_client *client, u16 data_length, ...@@ -279,7 +279,8 @@ static int ov5693_write_reg(struct i2c_client *client, u16 data_length,
data[2] = (u8)(val); data[2] = (u8)(val);
} else { } else {
/* OV5693_16BIT */ /* OV5693_16BIT */
u16 *wdata = (u16 *)&data[2]; __be16 *wdata = (void *)&data[2];
*wdata = cpu_to_be16(val); *wdata = cpu_to_be16(val);
} }
...@@ -311,15 +312,17 @@ static int __ov5693_flush_reg_array(struct i2c_client *client, ...@@ -311,15 +312,17 @@ static int __ov5693_flush_reg_array(struct i2c_client *client,
struct ov5693_write_ctrl *ctrl) struct ov5693_write_ctrl *ctrl)
{ {
u16 size; u16 size;
__be16 *reg = (void *)&ctrl->buffer.addr;
if (ctrl->index == 0) if (ctrl->index == 0)
return 0; return 0;
size = sizeof(u16) + ctrl->index; /* 16-bit address + data */ size = sizeof(u16) + ctrl->index; /* 16-bit address + data */
ctrl->buffer.addr = cpu_to_be16(ctrl->buffer.addr);
*reg = cpu_to_be16(ctrl->buffer.addr);
ctrl->index = 0; ctrl->index = 0;
return ov5693_i2c_write(client, size, (u8 *)&ctrl->buffer); return ov5693_i2c_write(client, size, (u8 *)reg);
} }
static int __ov5693_buf_reg_array(struct i2c_client *client, static int __ov5693_buf_reg_array(struct i2c_client *client,
...@@ -327,7 +330,7 @@ static int __ov5693_buf_reg_array(struct i2c_client *client, ...@@ -327,7 +330,7 @@ static int __ov5693_buf_reg_array(struct i2c_client *client,
const struct ov5693_reg *next) const struct ov5693_reg *next)
{ {
int size; int size;
u16 *data16; __be16 *data16;
switch (next->type) { switch (next->type) {
case OV5693_8BIT: case OV5693_8BIT:
...@@ -336,7 +339,8 @@ static int __ov5693_buf_reg_array(struct i2c_client *client, ...@@ -336,7 +339,8 @@ static int __ov5693_buf_reg_array(struct i2c_client *client,
break; break;
case OV5693_16BIT: case OV5693_16BIT:
size = 2; size = 2;
data16 = (u16 *)&ctrl->buffer.data[ctrl->index];
data16 = (void *)&ctrl->buffer.data[ctrl->index];
*data16 = cpu_to_be16((u16)next->val); *data16 = cpu_to_be16((u16)next->val);
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment