]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
rtc-ds1307-long-block-operations-bugfix-fix
authorAndrew Morton <akpm@linux-foundation.org>
Wed, 20 Feb 2013 02:15:39 +0000 (13:15 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Feb 2013 05:53:23 +0000 (16:53 +1100)
rework code to avoid 80-column overflows

Cc: Bertrand Achard <ba@cykian.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/rtc/rtc-ds1307.c

index 327ad5b1e541a0fe04a8910d3fa71468c4f9d826..a65621c42170e99748021c7d835563eac90a63dc 100644 (file)
@@ -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;
 }
 
 /*----------------------------------------------------------------------*/