aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2006-01-18 17:14:55 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-23 17:21:51 -0500
commit7656032b904b936eca65a41afa1f2b3603195657 (patch)
tree13144edd4480448c901d9ae8cfb92f882c29c009 /drivers/i2c
parent93766d2de6a3f7eead3fda57fd4638b90d6691fa (diff)
[PATCH] i2c: Speed up block transfers
Speed up i2c_smbus_write_block_data and i2c_smbus_read_i2c_block_data a bit by using memcpy instead of an explicit loop. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-core.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 97334433e534..2b0c555aa011 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -920,12 +920,11 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command,
920 u8 length, u8 *values) 920 u8 length, u8 *values)
921{ 921{
922 union i2c_smbus_data data; 922 union i2c_smbus_data data;
923 int i; 923
924 if (length > I2C_SMBUS_BLOCK_MAX) 924 if (length > I2C_SMBUS_BLOCK_MAX)
925 length = I2C_SMBUS_BLOCK_MAX; 925 length = I2C_SMBUS_BLOCK_MAX;
926 for (i = 1; i <= length; i++)
927 data.block[i] = values[i-1];
928 data.block[0] = length; 926 data.block[0] = length;
927 memcpy(&data.block[1], values, length);
929 return i2c_smbus_xfer(client->adapter,client->addr,client->flags, 928 return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
930 I2C_SMBUS_WRITE,command, 929 I2C_SMBUS_WRITE,command,
931 I2C_SMBUS_BLOCK_DATA,&data); 930 I2C_SMBUS_BLOCK_DATA,&data);
@@ -935,16 +934,14 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command,
935s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) 934s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values)
936{ 935{
937 union i2c_smbus_data data; 936 union i2c_smbus_data data;
938 int i; 937
939 if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, 938 if (i2c_smbus_xfer(client->adapter,client->addr,client->flags,
940 I2C_SMBUS_READ,command, 939 I2C_SMBUS_READ,command,
941 I2C_SMBUS_I2C_BLOCK_DATA,&data)) 940 I2C_SMBUS_I2C_BLOCK_DATA,&data))
942 return -1; 941 return -1;
943 else { 942
944 for (i = 1; i <= data.block[0]; i++) 943 memcpy(values, &data.block[1], data.block[0]);
945 values[i-1] = data.block[i]; 944 return data.block[0];
946 return data.block[0];
947 }
948} 945}
949 946
950s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, 947s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command,