From 8cc44b8c9ce10d3bd6bb79f2bdbf4ff465b45438 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 24 Apr 2008 12:43:40 +0000 Subject: [PATCH] Whitespace cleanups. git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5210 7894878c-1315-0410-8ee3-d5d059ff63e0 --- tools/i2cbusses.c | 20 ++++++++++---------- tools/i2cdetect.c | 46 ++++++++++++++++++++++----------------------- tools/i2cdump.c | 56 +++++++++++++++++++++++++++---------------------------- tools/i2cget.c | 38 ++++++++++++++++++------------------- tools/i2cset.c | 20 ++++++++++---------- 5 files changed, 90 insertions(+), 90 deletions(-) diff --git a/tools/i2cbusses.c b/tools/i2cbusses.c index 47280a9..af53f30 100644 --- a/tools/i2cbusses.c +++ b/tools/i2cbusses.c @@ -1,6 +1,6 @@ /* i2cbusses: Print the installed i2c busses for both 2.4 and 2.6 kernels. - Part of user-space programs to access for I2C + Part of user-space programs to access for I2C devices. Copyright (c) 1999-2003 Frodo Looijaard and Mark D. Studebaker @@ -225,7 +225,7 @@ struct i2c_adap *gather_i2c_busses(void) if(f == NULL) { sprintf(n, "%s/%s/device", sysfs, de->d_name); if(!(ddir = opendir(n))) - continue; + continue; while ((dde = readdir(ddir)) != NULL) { if (!strcmp(dde->d_name, ".")) continue; @@ -233,7 +233,7 @@ struct i2c_adap *gather_i2c_busses(void) continue; if ((!strncmp(dde->d_name, "i2c-", 4))) { sprintf(n, "%s/%s/device/%s/name", - sysfs, de->d_name, dde->d_name); + sysfs, de->d_name, dde->d_name); if((f = fopen(n, "r"))) goto found; } @@ -359,7 +359,7 @@ int parse_i2c_address(const char *address_arg) } if (address < 0x03 || address > 0x77) { fprintf(stderr, "Error: Chip address out of range " - "(0x03-0x77)!\n"); + "(0x03-0x77)!\n"); return -2; } @@ -381,16 +381,16 @@ int open_i2c_dev(const int i2cbus, char *filename, const int quiet) if (file < 0 && !quiet) { if (errno == ENOENT) { fprintf(stderr, "Error: Could not open file " - "`/dev/i2c-%d' or `/dev/i2c/%d': %s\n", - i2cbus, i2cbus, strerror(ENOENT)); + "`/dev/i2c-%d' or `/dev/i2c/%d': %s\n", + i2cbus, i2cbus, strerror(ENOENT)); } else { fprintf(stderr, "Error: Could not open file " - "`%s': %s\n", filename, strerror(errno)); + "`%s': %s\n", filename, strerror(errno)); if (errno == EACCES) fprintf(stderr, "Run as root?\n"); } } - + return file; } @@ -400,8 +400,8 @@ int set_slave_addr(int file, int address, int force) even when a driver is also running */ if (ioctl(file, force ? I2C_SLAVE_FORCE : I2C_SLAVE, address) < 0) { fprintf(stderr, - "Error: Could not set address to 0x%02x: %s\n", - address, strerror(errno)); + "Error: Could not set address to 0x%02x: %s\n", + address, strerror(errno)); return -errno; } diff --git a/tools/i2cdetect.c b/tools/i2cdetect.c index 33f01a8..4750db5 100644 --- a/tools/i2cdetect.c +++ b/tools/i2cdetect.c @@ -37,11 +37,11 @@ static void help(void) { fprintf(stderr, - "Usage: i2cdetect [-y] [-a] [-q|-r] I2CBUS [FIRST LAST]\n" - " i2cdetect -F I2CBUS\n" - " i2cdetect -l\n" - " I2CBUS is an integer or an I2C bus name\n" - " If provided, FIRST and LAST limit the probing range.\n"); + "Usage: i2cdetect [-y] [-a] [-q|-r] I2CBUS [FIRST LAST]\n" + " i2cdetect -F I2CBUS\n" + " i2cdetect -l\n" + " I2CBUS is an integer or an I2C bus name\n" + " If provided, FIRST and LAST limit the probing range.\n"); } static int scan_i2c_bus(int file, int mode, int first, int last) @@ -69,8 +69,8 @@ static int scan_i2c_bus(int file, int mode, int first, int last) continue; } else { fprintf(stderr, "Error: Could not set " - "address to 0x%02x: %s\n", i+j, - strerror(errno)); + "address to 0x%02x: %s\n", i+j, + strerror(errno)); return -1; } } @@ -151,7 +151,7 @@ static const struct func all_func[] = { static void print_functionality(unsigned long funcs) { int i; - + for (i = 0; all_func[i].value; i++) { printf("%-32s %s\n", all_func[i].name, (funcs & all_func[i].value) ? "yes" : "no"); @@ -202,15 +202,15 @@ int main(int argc, char *argv[]) case 'F': if (mode != MODE_AUTO && mode != MODE_FUNC) { fprintf(stderr, "Error: Different modes " - "specified!\n"); + "specified!\n"); exit(1); } mode = MODE_FUNC; break; - case 'r': + case 'r': if (mode == MODE_QUICK) { fprintf(stderr, "Error: Different modes " - "specified!\n"); + "specified!\n"); exit(1); } mode = MODE_READ; @@ -218,7 +218,7 @@ int main(int argc, char *argv[]) case 'q': if (mode == MODE_READ) { fprintf(stderr, "Error: Different modes " - "specified!\n"); + "specified!\n"); exit(1); } mode = MODE_QUICK; @@ -264,13 +264,13 @@ int main(int argc, char *argv[]) tmp = strtol(argv[flags+2], &end, 0); if (*end) { fprintf(stderr, "Error: FIRST argment not a " - "number!\n"); + "number!\n"); help(); exit(1); } if (tmp < first || tmp > last) { fprintf(stderr, "Error: FIRST argument out of range " - "(0x%02x-0x%02x)!\n", first, last); + "(0x%02x-0x%02x)!\n", first, last); help(); exit(1); } @@ -279,13 +279,13 @@ int main(int argc, char *argv[]) tmp = strtol(argv[flags+3], &end, 0); if (*end) { fprintf(stderr, "Error: LAST argment not a " - "number!\n"); + "number!\n"); help(); exit(1); } if (tmp < first || tmp > last) { fprintf(stderr, "Error: LAST argument out of range " - "(0x%02x-0x%02x)!\n", first, last); + "(0x%02x-0x%02x)!\n", first, last); help(); exit(1); } @@ -302,7 +302,7 @@ int main(int argc, char *argv[]) if (ioctl(file, I2C_FUNCS, &funcs) < 0) { fprintf(stderr, "Error: Could not get the adapter " - "functionality matrix: %s\n", strerror(errno)); + "functionality matrix: %s\n", strerror(errno)); close(file); exit(1); } @@ -317,13 +317,13 @@ int main(int argc, char *argv[]) if (mode != MODE_READ && !(funcs & I2C_FUNC_SMBUS_QUICK)) { fprintf(stderr, "Error: Can't use SMBus Quick Write command " - "on this bus (ISA bus?)\n"); + "on this bus (ISA bus?)\n"); close(file); exit(1); } if (mode != MODE_QUICK && !(funcs & I2C_FUNC_SMBUS_READ_BYTE)) { fprintf(stderr, "Error: Can't use SMBus Read Byte command " - "on this bus (ISA bus?)\n"); + "on this bus (ISA bus?)\n"); close(file); exit(1); } @@ -332,13 +332,13 @@ int main(int argc, char *argv[]) char s[2]; fprintf(stderr, "WARNING! This program can confuse your I2C " - "bus, cause data loss and worse!\n"); + "bus, cause data loss and worse!\n"); fprintf(stderr, "I will probe file %s%s.\n", filename, - mode==MODE_QUICK?" using quick write commands": - mode==MODE_READ?" using read byte commands":""); + mode==MODE_QUICK?" using quick write commands": + mode==MODE_READ?" using read byte commands":""); fprintf(stderr, "I will probe address range 0x%02x-0x%02x.\n", - first, last); + first, last); fprintf(stderr, "Continue? [Y/n] "); fflush(stderr); diff --git a/tools/i2cdump.c b/tools/i2cdump.c index c4de81b..1e049ec 100644 --- a/tools/i2cdump.c +++ b/tools/i2cdump.c @@ -33,17 +33,17 @@ static void help(void) { fprintf(stderr, - "Usage: i2cdump [-f] [-y] [-r first-last] I2CBUS ADDRESS [MODE] [BANK [BANKREG]]\n" - " I2CBUS is an integer or an I2C bus name\n" - " ADDRESS is an integer (0x03 - 0x77)\n" - " MODE is one of:\n" + "Usage: i2cdump [-f] [-y] [-r first-last] I2CBUS ADDRESS [MODE] [BANK [BANKREG]]\n" + " I2CBUS is an integer or an I2C bus name\n" + " ADDRESS is an integer (0x03 - 0x77)\n" + " MODE is one of:\n" " b (byte, default)\n" " w (word)\n" " W (word on even register addresses)\n" " s (SMBus block)\n" " i (I2C block)\n" - " c (consecutive byte)\n" - " Append p for SMBus PEC\n"); + " c (consecutive byte)\n" + " Append p for SMBus PEC\n"); } int main(int argc, char *argv[]) @@ -153,13 +153,13 @@ int main(int argc, char *argv[]) bankreg = strtol(argv[flags+5], &end, 0); if (*end || size == I2C_SMBUS_BLOCK_DATA) { fprintf(stderr, "Error: Invalid bank register " - "number!\n"); + "number!\n"); help(); exit(1); } if (bankreg < 0 || bankreg > 0xff) { fprintf(stderr, "Error: bank out of range " - "(0-0xff)!\n"); + "(0-0xff)!\n"); help(); exit(1); } @@ -194,7 +194,7 @@ int main(int argc, char *argv[]) /* Fall through */ default: fprintf(stderr, - "Error: Range parameter not compatible with selected mode!\n"); + "Error: Range parameter not compatible with selected mode!\n"); exit(1); } } @@ -207,7 +207,7 @@ int main(int argc, char *argv[]) /* check adapter functionality */ if (ioctl(file, I2C_FUNCS, &funcs) < 0) { fprintf(stderr, "Error: Could not get the adapter " - "functionality matrix: %s\n", strerror(errno)); + "functionality matrix: %s\n", strerror(errno)); exit(1); } @@ -248,8 +248,8 @@ int main(int argc, char *argv[]) case I2C_SMBUS_I2C_BLOCK_DATA: if (!(funcs & I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { fprintf(stderr, "Error: Adapter for i2c bus %d does " - "not have i2c block read capability\n", - i2cbus); + "not have i2c block read capability\n", + i2cbus); exit(1); } break; @@ -261,42 +261,42 @@ int main(int argc, char *argv[]) if (pec) { if (ioctl(file, I2C_PEC, 1) < 0) { fprintf(stderr, "Error: Could not set PEC: %s\n", - strerror(errno)); + strerror(errno)); exit(1); } if (!(funcs & (I2C_FUNC_SMBUS_PEC | I2C_FUNC_I2C))) { fprintf(stderr, "Warning: Adapter for i2c bus %d does " - "not seem to actually support PEC\n", i2cbus); + "not seem to actually support PEC\n", i2cbus); } } if (!yes) { fprintf(stderr, "WARNING! This program can confuse your I2C " - "bus, cause data loss and worse!\n"); + "bus, cause data loss and worse!\n"); fprintf(stderr, "I will probe file %s, address 0x%x, mode " - "%s\n", filename, address, - size == I2C_SMBUS_BLOCK_DATA ? "smbus block" : - size == I2C_SMBUS_I2C_BLOCK_DATA ? "i2c block" : - size == I2C_SMBUS_BYTE ? "byte consecutive read" : - size == I2C_SMBUS_BYTE_DATA ? "byte" : "word"); + "%s\n", filename, address, + size == I2C_SMBUS_BLOCK_DATA ? "smbus block" : + size == I2C_SMBUS_I2C_BLOCK_DATA ? "i2c block" : + size == I2C_SMBUS_BYTE ? "byte consecutive read" : + size == I2C_SMBUS_BYTE_DATA ? "byte" : "word"); if (pec) fprintf(stderr, "PEC checking enabled.\n"); if (even) fprintf(stderr, "Only probing even register " - "addresses.\n"); + "addresses.\n"); if (bank) { if (size == I2C_SMBUS_BLOCK_DATA) fprintf(stderr, "Using command 0x%02x.\n", - bank); + bank); else fprintf(stderr, "Probing bank %d using bank " - "register 0x%02x.\n", bank, bankreg); + "register 0x%02x.\n", bank, bankreg); } if (range) { fprintf(stderr, - "Probe range limited to 0x%02x-0x%02x.\n", - first, last); + "Probe range limited to 0x%02x-0x%02x.\n", + first, last); } fprintf(stderr, "Continue? [Y/n] "); @@ -346,7 +346,7 @@ int main(int argc, char *argv[]) } if (res <= 0) { fprintf(stderr, "Error: Block read failed, " - "return code %d\n", res); + "return code %d\n", res); exit(1); } if (res >= 256) @@ -362,7 +362,7 @@ int main(int argc, char *argv[]) res = i2c_smbus_write_byte(file, first); if(res != 0) { fprintf(stderr, "Error: Write start address " - "failed, return code %d\n", res); + "failed, return code %d\n", res); exit(1); } } @@ -395,7 +395,7 @@ int main(int argc, char *argv[]) i2c_smbus_read_byte_data(file, i+j); } else if (size == I2C_SMBUS_WORD_DATA) { res = i2c_smbus_read_word_data(file, - i+j); + i+j); if (res < 0) { block[i+j] = res; block[i+j+1] = res; diff --git a/tools/i2cget.c b/tools/i2cget.c index 70d7dc3..90dc271 100644 --- a/tools/i2cget.c +++ b/tools/i2cget.c @@ -38,14 +38,14 @@ static void help(void) __attribute__ ((noreturn)); static void help(void) { fprintf(stderr, - "Usage: i2cget [-f] [-y] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n" - " I2CBUS is an integer or an I2C bus name\n" - " ADDRESS is an integer (0x03 - 0x77)\n" - " MODE is one of:\n" - " b (read byte data, default)\n" - " w (read word data)\n" - " c (write byte/read byte)\n" - " Append p for SMBus PEC\n"); + "Usage: i2cget [-f] [-y] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]\n" + " I2CBUS is an integer or an I2C bus name\n" + " ADDRESS is an integer (0x03 - 0x77)\n" + " MODE is one of:\n" + " b (read byte data, default)\n" + " w (read word data)\n" + " c (write byte/read byte)\n" + " Append p for SMBus PEC\n"); exit(1); } @@ -56,7 +56,7 @@ static int check_funcs(int file, int i2cbus, int size, int daddress, int pec) /* check adapter functionality */ if (ioctl(file, I2C_FUNCS, &funcs) < 0) { fprintf(stderr, "Error: Could not get the adapter " - "functionality matrix: %s\n", strerror(errno)); + "functionality matrix: %s\n", strerror(errno)); return -1; } @@ -64,13 +64,13 @@ static int check_funcs(int file, int i2cbus, int size, int daddress, int pec) case I2C_SMBUS_BYTE: if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE)) { fprintf(stderr, "Error: Adapter for i2c bus %d does " - "not have read byte capability\n", i2cbus); + "not have read byte capability\n", i2cbus); return -1; } if (daddress >= 0 && !(funcs & I2C_FUNC_SMBUS_WRITE_BYTE)) { fprintf(stderr, "Error: Adapter for i2c bus %d does " - "not have write byte capability\n", i2cbus); + "not have write byte capability\n", i2cbus); return -1; } break; @@ -78,7 +78,7 @@ static int check_funcs(int file, int i2cbus, int size, int daddress, int pec) case I2C_SMBUS_BYTE_DATA: if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA)) { fprintf(stderr, "Error: Adapter for i2c bus %d does " - "not have read byte data capability\n", i2cbus); + "not have read byte data capability\n", i2cbus); return -1; } break; @@ -86,7 +86,7 @@ static int check_funcs(int file, int i2cbus, int size, int daddress, int pec) case I2C_SMBUS_WORD_DATA: if (!(funcs & I2C_FUNC_SMBUS_READ_WORD_DATA)) { fprintf(stderr, "Error: Adapter for i2c bus %d does " - "not have read word data capability\n", i2cbus); + "not have read word data capability\n", i2cbus); return -1; } break; @@ -95,7 +95,7 @@ static int check_funcs(int file, int i2cbus, int size, int daddress, int pec) if (pec && !(funcs & (I2C_FUNC_SMBUS_PEC | I2C_FUNC_I2C))) { fprintf(stderr, "Warning: Adapter for i2c bus %d does " - "not seem to support PEC\n", i2cbus); + "not seem to support PEC\n", i2cbus); } return 0; @@ -121,9 +121,9 @@ static int confirm(const char *filename, int address, int size, int daddress, if (size == I2C_SMBUS_BYTE && daddress >= 0 && pec) { fprintf(stderr, "WARNING! All I2C chips and some SMBus chips " - "will interpret a write\nbyte command with PEC as a" - "write byte data command, effectively writing a\n" - "value into a register!\n"); + "will interpret a write\nbyte command with PEC as a" + "write byte data command, effectively writing a\n" + "value into a register!\n"); dont++; } @@ -223,11 +223,11 @@ int main(int argc, char *argv[]) exit(1); if (!yes && !confirm(filename, address, size, daddress, pec)) - exit(0); + exit(0); if (pec && ioctl(file, I2C_PEC, 1) < 0) { fprintf(stderr, "Error: Could not set PEC: %s\n", - strerror(errno)); + strerror(errno)); exit(1); } diff --git a/tools/i2cset.c b/tools/i2cset.c index d8d400a..d578c06 100644 --- a/tools/i2cset.c +++ b/tools/i2cset.c @@ -36,12 +36,12 @@ static void help(void) { fprintf(stderr, "Usage: i2cset [-f] [-y] I2CBUS CHIP-ADDRESS DATA-ADDRESS VALUE [MODE] [MASK]\n" - " I2CBUS is an integer or an I2C bus name\n" - " ADDRESS is an integer (0x03 - 0x77)\n" - " MODE is one of:\n" - " b (byte, default)\n" + " I2CBUS is an integer or an I2C bus name\n" + " ADDRESS is an integer (0x03 - 0x77)\n" + " MODE is one of:\n" + " b (byte, default)\n" " w (word)\n" - " Append p for SMBus PEC\n"); + " Append p for SMBus PEC\n"); exit(1); } @@ -52,7 +52,7 @@ static int check_funcs(int file, int i2cbus, int size, int pec) /* check adapter functionality */ if (ioctl(file, I2C_FUNCS, &funcs) < 0) { fprintf(stderr, "Error: Could not get the adapter " - "functionality matrix: %s\n", strerror(errno)); + "functionality matrix: %s\n", strerror(errno)); return -1; } @@ -60,7 +60,7 @@ static int check_funcs(int file, int i2cbus, int size, int pec) case I2C_SMBUS_BYTE_DATA: if (!(funcs & I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { fprintf(stderr, "Error: Adapter for i2c bus %d does " - "not have byte write capability\n", i2cbus); + "not have byte write capability\n", i2cbus); return -1; } break; @@ -68,7 +68,7 @@ static int check_funcs(int file, int i2cbus, int size, int pec) case I2C_SMBUS_WORD_DATA: if (!(funcs & I2C_FUNC_SMBUS_WRITE_WORD_DATA)) { fprintf(stderr, "Error: Adapter for i2c bus %d does " - "not have word write capability\n", i2cbus); + "not have word write capability\n", i2cbus); return -1; } break; @@ -77,7 +77,7 @@ static int check_funcs(int file, int i2cbus, int size, int pec) if (pec && !(funcs & (I2C_FUNC_SMBUS_PEC | I2C_FUNC_I2C))) { fprintf(stderr, "Warning: Adapter for i2c bus %d does " - "not seem to support PEC\n", i2cbus); + "not seem to support PEC\n", i2cbus); } return 0; @@ -244,7 +244,7 @@ int main(int argc, char *argv[]) if (pec && ioctl(file, I2C_PEC, 1) < 0) { fprintf(stderr, "Error: Could not set PEC: %s\n", - strerror(errno)); + strerror(errno)); close(file); exit(1); }