From 63441be375b2aa1b62ac47f1424e9779c34fffa9 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 7 Feb 2013 12:27:43 +1100 Subject: [PATCH] rtc-ds1307-long-block-operations-bugfix-fix rework code to avoid 80-column overflows Cc: Bertrand Achard Signed-off-by: Andrew Morton --- drivers/rtc/rtc-ds1307.c | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 327ad5b1e541..a65621c42170 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -259,45 +259,45 @@ static s32 ds1307_write_block_data(const struct i2c_client *client, u8 command, static s32 ds1307_native_smbus_write_block_data(const struct i2c_client *client, u8 command, u8 length, const u8 *values) { - if (length <= I2C_SMBUS_BLOCK_MAX) { + u8 suboffset = 0; + + if (length <= I2C_SMBUS_BLOCK_MAX) return i2c_smbus_write_i2c_block_data(client, command, length, values); - } else { - u8 suboffset = 0; - while (suboffset < length) { - s32 retval = i2c_smbus_write_i2c_block_data(client, - command+suboffset, - min(I2C_SMBUS_BLOCK_MAX, length-suboffset), - values+suboffset); - if (retval < 0) - return retval; - - suboffset += I2C_SMBUS_BLOCK_MAX; - } - return length; + + while (suboffset < length) { + s32 retval = i2c_smbus_write_i2c_block_data(client, + command + suboffset, + min(I2C_SMBUS_BLOCK_MAX, length - suboffset), + values + suboffset); + if (retval < 0) + return retval; + + suboffset += I2C_SMBUS_BLOCK_MAX; } + return length; } static s32 ds1307_native_smbus_read_block_data(const struct i2c_client *client, u8 command, u8 length, u8 *values) { - if (length <= I2C_SMBUS_BLOCK_MAX) { + u8 suboffset = 0; + + if (length <= I2C_SMBUS_BLOCK_MAX) return i2c_smbus_read_i2c_block_data(client, command, length, values); - } else { - u8 suboffset = 0; - while (suboffset < length) { - s32 retval = i2c_smbus_read_i2c_block_data(client, - command+suboffset, - min(I2C_SMBUS_BLOCK_MAX, length-suboffset), - values+suboffset); - if (retval < 0) - return retval; - - suboffset += I2C_SMBUS_BLOCK_MAX; - } - return length; + + while (suboffset < length) { + s32 retval = i2c_smbus_read_i2c_block_data(client, + command + suboffset, + min(I2C_SMBUS_BLOCK_MAX, length - suboffset), + values + suboffset); + if (retval < 0) + return retval; + + suboffset += I2C_SMBUS_BLOCK_MAX; } + return length; } /*----------------------------------------------------------------------*/ -- 2.39.5