diff options
author | nsouch <nsouch@FreeBSD.org> | 1998-11-07 14:30:48 +0000 |
---|---|---|
committer | nsouch <nsouch@FreeBSD.org> | 1998-11-07 14:30:48 +0000 |
commit | f3f49dffcdd6172da688c1390be3c1baf4b6e906 (patch) | |
tree | f3668f6d6c88ea763cc69bf89e47c7fd15a24566 /sys | |
parent | 32bb859dc0e6ca97a9375024eb85461abfa753b8 (diff) | |
download | FreeBSD-src-f3f49dffcdd6172da688c1390be3c1baf4b6e906.zip FreeBSD-src-f3f49dffcdd6172da688c1390be3c1baf4b6e906.tar.gz |
Return to previous check_for_i2c_devices() behaviour.
Cast the cmd parameter to unsigned char in every smbus call.
Submitted by: Roger Hardiman <roger@cs.strath.ac.uk>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/bktr/bktr_core.c | 31 | ||||
-rw-r--r-- | sys/dev/bktr/bktr_i2c.c | 10 | ||||
-rw-r--r-- | sys/pci/brooktree848.c | 31 | ||||
-rw-r--r-- | sys/pci/bt848_i2c.c | 10 |
4 files changed, 34 insertions, 48 deletions
diff --git a/sys/dev/bktr/bktr_core.c b/sys/dev/bktr/bktr_core.c index 2a468dd..30a9dab 100644 --- a/sys/dev/bktr/bktr_core.c +++ b/sys/dev/bktr/bktr_core.c @@ -1,4 +1,4 @@ -/* $Id: brooktree848.c,v 1.56 1998/10/01 09:35:48 sos Exp $ */ +/* $Id: brooktree848.c,v 1.57 1998/10/31 11:26:38 nsouch Exp $ */ /* BT848 Driver for Brooktree's Bt848 based cards. The Brooktree BT848 Driver driver is based upon Mark Tinguely and Jim Lowe's driver for the Matrox Meteor PCI card . The @@ -4421,16 +4421,6 @@ readEEProm( bktr_ptr_t bktr, int offset, int count, u_char *data ) } #define ABSENT (-1) -static int -probeDevice(bktr_ptr_t bktr, u_char addr) -{ - int read; - read = i2cRead( bktr, addr); - if (read == ABSENT || read == 0) - return (0); - - return (1); -} /* * get a signature of the card @@ -4448,8 +4438,9 @@ signCard( bktr_ptr_t bktr, int offset, int count, u_char* sig ) sig[ x ] = 0; for ( x = 0; x < count; ++x ) { - if (probeDevice(bktr, (u_char)(2 * x + 1))) + if ( i2cRead( bktr, (2 * x) + 1 ) != ABSENT ) { sig[ x / 8 ] |= (1 << (x % 8) ); + } } return( 0 ); @@ -4468,12 +4459,17 @@ signCard( bktr_ptr_t bktr, int offset, int count, u_char* sig ) * (eg VideoLogic Captivator PCI rev. 2F with BT848A) */ static int check_for_i2c_devices( bktr_ptr_t bktr ){ - int x; + int x, temp_read; + int i2c_all_0 = 1; + int i2c_all_absent = 1; for ( x = 0; x < 128; ++x ) { - if (probeDevice(bktr, (u_char)(2 * x + 1))) - return (1); + temp_read = i2cRead( bktr, (2 * x) + 1 ); + if (temp_read != 0) i2c_all_0 = 0; + if (temp_read != ABSENT) i2c_all_absent = 0; } - return (0); + + if ((i2c_all_0) || (i2c_all_absent)) return 0; + else return 1; } /* @@ -4508,9 +4504,6 @@ probeCard( bktr_ptr_t bktr, int verbose ) int tuner_i2c_address = -1; any_i2c_devices = check_for_i2c_devices( bktr ); - if (bootverbose) - if (!any_i2c_devices) - printf("bktr: no I2C device found!\n"); bt848 = bktr->base; bt848->gpio_out_en = 0; diff --git a/sys/dev/bktr/bktr_i2c.c b/sys/dev/bktr/bktr_i2c.c index b2b7912..176d069 100644 --- a/sys/dev/bktr/bktr_i2c.c +++ b/sys/dev/bktr/bktr_i2c.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: bt848_i2c.c,v 1.1 1998/10/31 11:26:38 nsouch Exp $ * */ @@ -345,7 +345,7 @@ bti2c_smb_writeb(device_t dev, u_char slave, char cmd, char byte) struct bti2c_softc *sc = (struct bti2c_softc *)device_get_softc(dev); u_long data; - data = ((slave & 0xff) << 24) | ((byte & 0xff) << 16) | cmd; + data = ((slave & 0xff) << 24) | ((byte & 0xff) << 16) | (u_char)cmd; return (bti2c_write(sc->base, data)); } @@ -365,7 +365,7 @@ bti2c_smb_writew(device_t dev, u_char slave, char cmd, short word) high = (char)((word & 0xff00) >> 8); data = ((slave & 0xff) << 24) | ((low & 0xff) << 16) | - ((high & 0xff) << 8) | BT848_DATA_CTL_I2CW3B | cmd; + ((high & 0xff) << 8) | BT848_DATA_CTL_I2CW3B | (u_char)cmd; return (bti2c_write(sc->base, data)); } @@ -385,9 +385,9 @@ bti2c_smb_readb(device_t dev, u_char slave, char cmd, char *byte) /* clear status bits */ bti2c->int_stat = (BT848_INT_RACK | BT848_INT_I2CDONE); - bti2c->i2c_data_ctl = ((slave & 0xff) << 24) | cmd; + bti2c->i2c_data_ctl = ((slave & 0xff) << 24) | (u_char)cmd; - BTI2C_DEBUG(printf("r%lx/", (u_long)(((slave & 0xff) << 24) | cmd))); + BTI2C_DEBUG(printf("r%lx/", (u_long)(((slave & 0xff) << 24) | (u_char)cmd))); /* wait for completion */ for ( x = 0x7fffffff; x; --x ) { /* safety valve */ diff --git a/sys/pci/brooktree848.c b/sys/pci/brooktree848.c index 2a468dd..30a9dab 100644 --- a/sys/pci/brooktree848.c +++ b/sys/pci/brooktree848.c @@ -1,4 +1,4 @@ -/* $Id: brooktree848.c,v 1.56 1998/10/01 09:35:48 sos Exp $ */ +/* $Id: brooktree848.c,v 1.57 1998/10/31 11:26:38 nsouch Exp $ */ /* BT848 Driver for Brooktree's Bt848 based cards. The Brooktree BT848 Driver driver is based upon Mark Tinguely and Jim Lowe's driver for the Matrox Meteor PCI card . The @@ -4421,16 +4421,6 @@ readEEProm( bktr_ptr_t bktr, int offset, int count, u_char *data ) } #define ABSENT (-1) -static int -probeDevice(bktr_ptr_t bktr, u_char addr) -{ - int read; - read = i2cRead( bktr, addr); - if (read == ABSENT || read == 0) - return (0); - - return (1); -} /* * get a signature of the card @@ -4448,8 +4438,9 @@ signCard( bktr_ptr_t bktr, int offset, int count, u_char* sig ) sig[ x ] = 0; for ( x = 0; x < count; ++x ) { - if (probeDevice(bktr, (u_char)(2 * x + 1))) + if ( i2cRead( bktr, (2 * x) + 1 ) != ABSENT ) { sig[ x / 8 ] |= (1 << (x % 8) ); + } } return( 0 ); @@ -4468,12 +4459,17 @@ signCard( bktr_ptr_t bktr, int offset, int count, u_char* sig ) * (eg VideoLogic Captivator PCI rev. 2F with BT848A) */ static int check_for_i2c_devices( bktr_ptr_t bktr ){ - int x; + int x, temp_read; + int i2c_all_0 = 1; + int i2c_all_absent = 1; for ( x = 0; x < 128; ++x ) { - if (probeDevice(bktr, (u_char)(2 * x + 1))) - return (1); + temp_read = i2cRead( bktr, (2 * x) + 1 ); + if (temp_read != 0) i2c_all_0 = 0; + if (temp_read != ABSENT) i2c_all_absent = 0; } - return (0); + + if ((i2c_all_0) || (i2c_all_absent)) return 0; + else return 1; } /* @@ -4508,9 +4504,6 @@ probeCard( bktr_ptr_t bktr, int verbose ) int tuner_i2c_address = -1; any_i2c_devices = check_for_i2c_devices( bktr ); - if (bootverbose) - if (!any_i2c_devices) - printf("bktr: no I2C device found!\n"); bt848 = bktr->base; bt848->gpio_out_en = 0; diff --git a/sys/pci/bt848_i2c.c b/sys/pci/bt848_i2c.c index b2b7912..176d069 100644 --- a/sys/pci/bt848_i2c.c +++ b/sys/pci/bt848_i2c.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: bt848_i2c.c,v 1.1 1998/10/31 11:26:38 nsouch Exp $ * */ @@ -345,7 +345,7 @@ bti2c_smb_writeb(device_t dev, u_char slave, char cmd, char byte) struct bti2c_softc *sc = (struct bti2c_softc *)device_get_softc(dev); u_long data; - data = ((slave & 0xff) << 24) | ((byte & 0xff) << 16) | cmd; + data = ((slave & 0xff) << 24) | ((byte & 0xff) << 16) | (u_char)cmd; return (bti2c_write(sc->base, data)); } @@ -365,7 +365,7 @@ bti2c_smb_writew(device_t dev, u_char slave, char cmd, short word) high = (char)((word & 0xff00) >> 8); data = ((slave & 0xff) << 24) | ((low & 0xff) << 16) | - ((high & 0xff) << 8) | BT848_DATA_CTL_I2CW3B | cmd; + ((high & 0xff) << 8) | BT848_DATA_CTL_I2CW3B | (u_char)cmd; return (bti2c_write(sc->base, data)); } @@ -385,9 +385,9 @@ bti2c_smb_readb(device_t dev, u_char slave, char cmd, char *byte) /* clear status bits */ bti2c->int_stat = (BT848_INT_RACK | BT848_INT_I2CDONE); - bti2c->i2c_data_ctl = ((slave & 0xff) << 24) | cmd; + bti2c->i2c_data_ctl = ((slave & 0xff) << 24) | (u_char)cmd; - BTI2C_DEBUG(printf("r%lx/", (u_long)(((slave & 0xff) << 24) | cmd))); + BTI2C_DEBUG(printf("r%lx/", (u_long)(((slave & 0xff) << 24) | (u_char)cmd))); /* wait for completion */ for ( x = 0x7fffffff; x; --x ) { /* safety valve */ |