From cb505753d14b3c85693968a162eef4f42526e99e Mon Sep 17 00:00:00 2001 From: Kyosti Malkki Date: Sun, 28 Mar 1999 14:06:38 +0000 Subject: [PATCH] =?UTF-8?q?(Ky=C3=B6sti)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed i2c_probe to actually try some addresses, and change the client->addr _only_ when we get a match. * Algo-bit now scans the bus before registering it. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@346 7894878c-1315-0410-8ee3-d5d059ff63e0 --- i2c/MODIFICATIONS | 4 ++++ i2c/algo-bit.c | 14 +++----------- i2c/i2c-core.c | 7 +++---- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/i2c/MODIFICATIONS b/i2c/MODIFICATIONS index e9baf111..b9ed164d 100644 --- a/i2c/MODIFICATIONS +++ b/i2c/MODIFICATIONS @@ -11,6 +11,10 @@ The current version of Simon's code is called mod-19990118.tar.gz. Here come the changes: +! Fixed i2c_probe bug + +* Algo-bit now scans the bus before registering the adapter. + ! Renamed #define HW_B_MB to HW_B_VIA in i2c.h ! Added '#include ' to i2c.h, to make it compile with 2.2 diff --git a/i2c/algo-bit.c b/i2c/algo-bit.c index 6ea2b997..9ede4c92 100644 --- a/i2c/algo-bit.c +++ b/i2c/algo-bit.c @@ -571,7 +571,6 @@ int i2c_bit_add_bus(struct bit_adapter *adap) i2c_adap->timeout = 100; /* default values, should */ i2c_adap->retries = 3; /* be replaced by defines */ i2c_adaps[i] = i2c_adap; - i2c_add_adapter(i2c_adap); /* scan bus */ if (bit_scan) { @@ -587,6 +586,9 @@ int i2c_bit_add_bus(struct bit_adapter *adap) } printk("\n"); } + + i2c_add_adapter(i2c_adap); + return 0; } @@ -655,13 +657,3 @@ void cleanup_module(void) i2c_del_algorithm(&bit_algo); } #endif - - - - - - - - - - diff --git a/i2c/i2c-core.c b/i2c/i2c-core.c index 412cb3c5..271bc1c9 100644 --- a/i2c/i2c-core.c +++ b/i2c/i2c-core.c @@ -418,22 +418,21 @@ int i2c_probe(struct i2c_client *client, int low_addr, int hi_addr) { int i; struct i2c_msg msg; - struct i2c_msg *pmsg = &msg; msg.flags=client->flags & (I2C_M_TENMASK | I2C_M_TEN ); msg.buf = NULL; msg.len = 0; I2C_LOCK(client->adapter); for (i = low_addr; i <= hi_addr; i++) { - client->addr=i; + msg.addr=i; /* TODO: implement a control statement in the algo layer * that does address lookup only. */ if (1 == client->adapter-> - algo->master_xfer(client->adapter,pmsg,1)) + algo->master_xfer(client->adapter,&msg,1)) break; } I2C_UNLOCK(client->adapter); - return (i <= hi_addr) ? i : -1; + return (i <= hi_addr) ? (client->addr=i) : -1; } /* +++ frodo * return id number for a specific adapter