From 13f7d150e0334b90e8900b041f8d2aba6a0962b3 Mon Sep 17 00:00:00 2001 From: "Mark D. Studebaker" Date: Sun, 9 Jan 2000 22:45:57 +0000 Subject: [PATCH] (mds) Change ioctl from I2C_SLAVE to I2C_SLAVE_FORCE so that you can run i2cdump even when a driver is installed. Add a cat of /proc/bus/i2c to the help function to help users with the bus number argument. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@690 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/dump/i2cdump.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/prog/dump/i2cdump.c b/prog/dump/i2cdump.c index 1337605e..bfeda10a 100644 --- a/prog/dump/i2cdump.c +++ b/prog/dump/i2cdump.c @@ -27,8 +27,18 @@ void help(void) { + FILE *fptr; + char s[100]; + fprintf(stderr,"Syntax: i2cdump I2CBUS ADDRESS MODE\n"); fprintf(stderr," MODE may be 'b' or 'w'\n"); + fprintf(stderr," I2CBUS is an integer\n"); + if((fptr = fopen("/proc/bus/i2c", "r"))) { + fprintf(stderr," Installed I2C busses:\n"); + while(fgets(s, 100, fptr)) + fprintf(stderr, " %s", s); + fclose(fptr); + } } int main(int argc, char *argv[]) @@ -91,7 +101,9 @@ int main(int argc, char *argv[]) exit(1); } - if (ioctl(file,I2C_SLAVE,address) < 0) { + /* use FORCE so that we can look at registers even when + a driver is also running */ + if (ioctl(file,I2C_SLAVE_FORCE,address) < 0) { fprintf(stderr,"Error: Could not set address to %d: %s\n",address, strerror(errno)); exit(1);