Commit 7225acf4 authored by Farid Hammane's avatar Farid Hammane Committed by Jean Delvare

i2c-core: Fix some coding style issues

Fix up coding style issues found by the checkpatch.pl tool.
Signed-off-by: default avatarFarid Hammane <farid.hammane@gmail.com>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent b8680784
...@@ -1221,10 +1221,10 @@ EXPORT_SYMBOL(i2c_transfer); ...@@ -1221,10 +1221,10 @@ EXPORT_SYMBOL(i2c_transfer);
* *
* Returns negative errno, or else the number of bytes written. * Returns negative errno, or else the number of bytes written.
*/ */
int i2c_master_send(struct i2c_client *client,const char *buf ,int count) int i2c_master_send(struct i2c_client *client, const char *buf, int count)
{ {
int ret; int ret;
struct i2c_adapter *adap=client->adapter; struct i2c_adapter *adap = client->adapter;
struct i2c_msg msg; struct i2c_msg msg;
msg.addr = client->addr; msg.addr = client->addr;
...@@ -1248,9 +1248,9 @@ EXPORT_SYMBOL(i2c_master_send); ...@@ -1248,9 +1248,9 @@ EXPORT_SYMBOL(i2c_master_send);
* *
* Returns negative errno, or else the number of bytes read. * Returns negative errno, or else the number of bytes read.
*/ */
int i2c_master_recv(struct i2c_client *client, char *buf ,int count) int i2c_master_recv(struct i2c_client *client, char *buf, int count)
{ {
struct i2c_adapter *adap=client->adapter; struct i2c_adapter *adap = client->adapter;
struct i2c_msg msg; struct i2c_msg msg;
int ret; int ret;
...@@ -1452,7 +1452,7 @@ i2c_new_probed_device(struct i2c_adapter *adap, ...@@ -1452,7 +1452,7 @@ i2c_new_probed_device(struct i2c_adapter *adap,
} }
EXPORT_SYMBOL_GPL(i2c_new_probed_device); EXPORT_SYMBOL_GPL(i2c_new_probed_device);
struct i2c_adapter* i2c_get_adapter(int id) struct i2c_adapter *i2c_get_adapter(int id)
{ {
struct i2c_adapter *adapter; struct i2c_adapter *adapter;
...@@ -1479,7 +1479,7 @@ static u8 crc8(u16 data) ...@@ -1479,7 +1479,7 @@ static u8 crc8(u16 data)
{ {
int i; int i;
for(i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
if (data & 0x8000) if (data & 0x8000)
data = data ^ POLY; data = data ^ POLY;
data = data << 1; data = data << 1;
...@@ -1492,7 +1492,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count) ...@@ -1492,7 +1492,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
{ {
int i; int i;
for(i = 0; i < count; i++) for (i = 0; i < count; i++)
crc = crc8((crc ^ p[i]) << 8); crc = crc8((crc ^ p[i]) << 8);
return crc; return crc;
} }
...@@ -1562,7 +1562,7 @@ EXPORT_SYMBOL(i2c_smbus_read_byte); ...@@ -1562,7 +1562,7 @@ EXPORT_SYMBOL(i2c_smbus_read_byte);
*/ */
s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value)
{ {
return i2c_smbus_xfer(client->adapter,client->addr,client->flags, return i2c_smbus_xfer(client->adapter, client->addr, client->flags,
I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
} }
EXPORT_SYMBOL(i2c_smbus_write_byte); EXPORT_SYMBOL(i2c_smbus_write_byte);
...@@ -1600,9 +1600,9 @@ s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value) ...@@ -1600,9 +1600,9 @@ s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value)
{ {
union i2c_smbus_data data; union i2c_smbus_data data;
data.byte = value; data.byte = value;
return i2c_smbus_xfer(client->adapter,client->addr,client->flags, return i2c_smbus_xfer(client->adapter, client->addr, client->flags,
I2C_SMBUS_WRITE,command, I2C_SMBUS_WRITE, command,
I2C_SMBUS_BYTE_DATA,&data); I2C_SMBUS_BYTE_DATA, &data);
} }
EXPORT_SYMBOL(i2c_smbus_write_byte_data); EXPORT_SYMBOL(i2c_smbus_write_byte_data);
...@@ -1639,9 +1639,9 @@ s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value) ...@@ -1639,9 +1639,9 @@ s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value)
{ {
union i2c_smbus_data data; union i2c_smbus_data data;
data.word = value; data.word = value;
return i2c_smbus_xfer(client->adapter,client->addr,client->flags, return i2c_smbus_xfer(client->adapter, client->addr, client->flags,
I2C_SMBUS_WRITE,command, I2C_SMBUS_WRITE, command,
I2C_SMBUS_WORD_DATA,&data); I2C_SMBUS_WORD_DATA, &data);
} }
EXPORT_SYMBOL(i2c_smbus_write_word_data); EXPORT_SYMBOL(i2c_smbus_write_word_data);
...@@ -1718,9 +1718,9 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, ...@@ -1718,9 +1718,9 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command,
length = I2C_SMBUS_BLOCK_MAX; length = I2C_SMBUS_BLOCK_MAX;
data.block[0] = length; data.block[0] = length;
memcpy(&data.block[1], values, length); memcpy(&data.block[1], values, length);
return i2c_smbus_xfer(client->adapter,client->addr,client->flags, return i2c_smbus_xfer(client->adapter, client->addr, client->flags,
I2C_SMBUS_WRITE,command, I2C_SMBUS_WRITE, command,
I2C_SMBUS_BLOCK_DATA,&data); I2C_SMBUS_BLOCK_DATA, &data);
} }
EXPORT_SYMBOL(i2c_smbus_write_block_data); EXPORT_SYMBOL(i2c_smbus_write_block_data);
...@@ -1762,10 +1762,10 @@ EXPORT_SYMBOL(i2c_smbus_write_i2c_block_data); ...@@ -1762,10 +1762,10 @@ EXPORT_SYMBOL(i2c_smbus_write_i2c_block_data);
/* Simulate a SMBus command using the i2c protocol /* Simulate a SMBus command using the i2c protocol
No checking of parameters is done! */ No checking of parameters is done! */
static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
unsigned short flags, unsigned short flags,
char read_write, u8 command, int size, char read_write, u8 command, int size,
union i2c_smbus_data * data) union i2c_smbus_data *data)
{ {
/* So we need to generate a series of msgs. In the case of writing, we /* So we need to generate a series of msgs. In the case of writing, we
need to use only one message; when reading, we need two. We initialize need to use only one message; when reading, we need two. We initialize
...@@ -1773,7 +1773,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, ...@@ -1773,7 +1773,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
simpler. */ simpler. */
unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3];
unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2];
int num = read_write == I2C_SMBUS_READ?2:1; int num = read_write == I2C_SMBUS_READ ? 2 : 1;
struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 },
{ addr, flags | I2C_M_RD, 0, msgbuf1 } { addr, flags | I2C_M_RD, 0, msgbuf1 }
}; };
...@@ -1782,7 +1782,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, ...@@ -1782,7 +1782,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
int status; int status;
msgbuf0[0] = command; msgbuf0[0] = command;
switch(size) { switch (size) {
case I2C_SMBUS_QUICK: case I2C_SMBUS_QUICK:
msg[0].len = 0; msg[0].len = 0;
/* Special case: The read/write field is used as data */ /* Special case: The read/write field is used as data */
...@@ -1809,7 +1809,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, ...@@ -1809,7 +1809,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
if (read_write == I2C_SMBUS_READ) if (read_write == I2C_SMBUS_READ)
msg[1].len = 2; msg[1].len = 2;
else { else {
msg[0].len=3; msg[0].len = 3;
msgbuf0[1] = data->word & 0xff; msgbuf0[1] = data->word & 0xff;
msgbuf0[2] = data->word >> 8; msgbuf0[2] = data->word >> 8;
} }
...@@ -1902,26 +1902,26 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, ...@@ -1902,26 +1902,26 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
} }
if (read_write == I2C_SMBUS_READ) if (read_write == I2C_SMBUS_READ)
switch(size) { switch (size) {
case I2C_SMBUS_BYTE: case I2C_SMBUS_BYTE:
data->byte = msgbuf0[0]; data->byte = msgbuf0[0];
break; break;
case I2C_SMBUS_BYTE_DATA: case I2C_SMBUS_BYTE_DATA:
data->byte = msgbuf1[0]; data->byte = msgbuf1[0];
break; break;
case I2C_SMBUS_WORD_DATA: case I2C_SMBUS_WORD_DATA:
case I2C_SMBUS_PROC_CALL: case I2C_SMBUS_PROC_CALL:
data->word = msgbuf1[0] | (msgbuf1[1] << 8); data->word = msgbuf1[0] | (msgbuf1[1] << 8);
break; break;
case I2C_SMBUS_I2C_BLOCK_DATA: case I2C_SMBUS_I2C_BLOCK_DATA:
for (i = 0; i < data->block[0]; i++) for (i = 0; i < data->block[0]; i++)
data->block[i+1] = msgbuf1[i]; data->block[i+1] = msgbuf1[i];
break; break;
case I2C_SMBUS_BLOCK_DATA: case I2C_SMBUS_BLOCK_DATA:
case I2C_SMBUS_BLOCK_PROC_CALL: case I2C_SMBUS_BLOCK_PROC_CALL:
for (i = 0; i < msgbuf1[0] + 1; i++) for (i = 0; i < msgbuf1[0] + 1; i++)
data->block[i] = msgbuf1[i]; data->block[i] = msgbuf1[i];
break; break;
} }
return 0; return 0;
} }
...@@ -1966,7 +1966,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags, ...@@ -1966,7 +1966,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
} }
rt_mutex_unlock(&adapter->bus_lock); rt_mutex_unlock(&adapter->bus_lock);
} else } else
res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, res = i2c_smbus_xfer_emulated(adapter, addr, flags, read_write,
command, protocol, data); command, protocol, data);
return res; return res;
......
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