summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2008-05-05 14:55:01 +0000
committerkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2008-05-05 14:55:01 +0000
commitf5b83fa467b5eabb90c3e95e5934a2805946685b (patch)
treee703490a87968dae6fb9e357296afee0eb8ff15b /tools
parent7ef736ceccd67452dde6ef30361b1bd97de9074b (diff)
downloadi2c-tools-f5b83fa467b5eabb90c3e95e5934a2805946685b.tar.gz
Share the error string between all functionality checks.
git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5241 7894878c-1315-0410-8ee3-d5d059ff63e0
Diffstat (limited to 'tools')
-rw-r--r--tools/i2cbusses.h2
-rw-r--r--tools/i2cdump.c15
-rw-r--r--tools/i2cget.c12
-rw-r--r--tools/i2cset.c9
4 files changed, 14 insertions, 24 deletions
diff --git a/tools/i2cbusses.h b/tools/i2cbusses.h
index cbd794a..b089887 100644
--- a/tools/i2cbusses.h
+++ b/tools/i2cbusses.h
@@ -37,4 +37,6 @@ int parse_i2c_address(const char *address_arg);
int open_i2c_dev(const int i2cbus, char *filename, const int quiet);
int set_slave_addr(int file, int address, int force);
+#define MISSING_FUNC_FMT "Error: Adapter does not have %s capability\n"
+
#endif
diff --git a/tools/i2cdump.c b/tools/i2cdump.c
index 9138832..0d021c6 100644
--- a/tools/i2cdump.c
+++ b/tools/i2cdump.c
@@ -60,40 +60,35 @@ static int check_funcs(int file, int size, int pec)
switch(size) {
case I2C_SMBUS_BYTE:
if (!((funcs & I2C_FUNC_SMBUS_BYTE) == I2C_FUNC_SMBUS_BYTE)) {
- fprintf(stderr, "Error: Adapter does "
- "not have byte capability\n");
+ fprintf(stderr, MISSING_FUNC_FMT, "byte");
return -1;
}
break;
case I2C_SMBUS_BYTE_DATA:
if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
- fprintf(stderr, "Error: Adapter does "
- "not have byte read capability\n");
+ fprintf(stderr, MISSING_FUNC_FMT, "byte read");
return -1;
}
break;
case I2C_SMBUS_WORD_DATA:
if (!(funcs & I2C_FUNC_SMBUS_READ_WORD_DATA)) {
- fprintf(stderr, "Error: Adapter does "
- "not have word read capability\n");
+ fprintf(stderr, MISSING_FUNC_FMT, "word read");
return -1;
}
break;
case I2C_SMBUS_BLOCK_DATA:
if (!(funcs & I2C_FUNC_SMBUS_READ_BLOCK_DATA)) {
- fprintf(stderr, "Error: Adapter does "
- "not have smbus block read capability\n");
+ fprintf(stderr, MISSING_FUNC_FMT, "smbus block read");
return -1;
}
break;
case I2C_SMBUS_I2C_BLOCK_DATA:
if (!(funcs & I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
- fprintf(stderr, "Error: Adapter does "
- "not have i2c block read capability\n");
+ fprintf(stderr, MISSING_FUNC_FMT, "i2c block read");
return -1;
}
break;
diff --git a/tools/i2cget.c b/tools/i2cget.c
index 3bf3eb7..c3a3eec 100644
--- a/tools/i2cget.c
+++ b/tools/i2cget.c
@@ -63,30 +63,26 @@ static int check_funcs(int file, int size, int daddress, int pec)
switch (size) {
case I2C_SMBUS_BYTE:
if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE)) {
- fprintf(stderr, "Error: Adapter does "
- "not have read byte capability\n");
+ fprintf(stderr, MISSING_FUNC_FMT, "read byte");
return -1;
}
if (daddress >= 0
&& !(funcs & I2C_FUNC_SMBUS_WRITE_BYTE)) {
- fprintf(stderr, "Error: Adapter does "
- "not have write byte capability\n");
+ fprintf(stderr, MISSING_FUNC_FMT, "write byte");
return -1;
}
break;
case I2C_SMBUS_BYTE_DATA:
if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
- fprintf(stderr, "Error: Adapter does "
- "not have read byte data capability\n");
+ fprintf(stderr, MISSING_FUNC_FMT, "read byte");
return -1;
}
break;
case I2C_SMBUS_WORD_DATA:
if (!(funcs & I2C_FUNC_SMBUS_READ_WORD_DATA)) {
- fprintf(stderr, "Error: Adapter does "
- "not have read word data capability\n");
+ fprintf(stderr, MISSING_FUNC_FMT, "read word");
return -1;
}
break;
diff --git a/tools/i2cset.c b/tools/i2cset.c
index abba5a4..03ae22d 100644
--- a/tools/i2cset.c
+++ b/tools/i2cset.c
@@ -59,24 +59,21 @@ static int check_funcs(int file, int size, int pec)
switch (size) {
case I2C_SMBUS_BYTE:
if (!(funcs & I2C_FUNC_SMBUS_WRITE_BYTE)) {
- fprintf(stderr, "Error: Adapter does "
- "not have byte send capability\n");
+ fprintf(stderr, MISSING_FUNC_FMT, "byte send");
return -1;
}
break;
case I2C_SMBUS_BYTE_DATA:
if (!(funcs & I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) {
- fprintf(stderr, "Error: Adapter does "
- "not have byte write capability\n");
+ fprintf(stderr, MISSING_FUNC_FMT, "byte write");
return -1;
}
break;
case I2C_SMBUS_WORD_DATA:
if (!(funcs & I2C_FUNC_SMBUS_WRITE_WORD_DATA)) {
- fprintf(stderr, "Error: Adapter does "
- "not have word write capability\n");
+ fprintf(stderr, MISSING_FUNC_FMT, "word write");
return -1;
}
break;