From 51a36f1cfbb45609c5e50b2257f4030b956316ae Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 12 Jun 2006 19:29:50 +0000 Subject: [PATCH] Change read_bit() to return 0 or -1UL, rather than 0 or 1. --- src/drivers/bitbash/bitbash.c | 6 ++++-- src/drivers/bitbash/i2c_bit.c | 2 +- src/include/gpxe/i2c.h | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/drivers/bitbash/bitbash.c b/src/drivers/bitbash/bitbash.c index 270c1b92..92abe1a7 100644 --- a/src/drivers/bitbash/bitbash.c +++ b/src/drivers/bitbash/bitbash.c @@ -48,8 +48,10 @@ void write_bit ( struct bit_basher *basher, unsigned int bit_id, * @v bit_id Bit number * @ret data Value read * - * @c data will always be either 0 or 1. + * @c data will always be either 0 or -1UL. The idea is that the + * caller can simply binary-AND the returned value with whatever mask + * it needs to apply. */ int read_bit ( struct bit_basher *basher, unsigned int bit_id ) { - return ( basher->read ( basher, bit_id ) ? 1 : 0 ); + return ( basher->read ( basher, bit_id ) ? -1UL : 0 ); } diff --git a/src/drivers/bitbash/i2c_bit.c b/src/drivers/bitbash/i2c_bit.c index 9524d631..cc73968b 100644 --- a/src/drivers/bitbash/i2c_bit.c +++ b/src/drivers/bitbash/i2c_bit.c @@ -153,7 +153,7 @@ static uint8_t i2c_recv_byte ( struct bit_basher *basher ) { /* Receive byte */ for ( i = 8 ; i ; i-- ) { value <<= 1; - value |= i2c_recv_bit ( basher ); + value |= ( i2c_recv_bit ( basher ) & 0x1 ); } /* Send NACK */ diff --git a/src/include/gpxe/i2c.h b/src/include/gpxe/i2c.h index e282810b..bfaee8fb 100644 --- a/src/include/gpxe/i2c.h +++ b/src/include/gpxe/i2c.h @@ -82,7 +82,9 @@ struct i2c_bit_basher { /** Bit indices used for I2C bit-bashing interface */ enum { + /** Serial clock */ I2C_BIT_SCL = 0, + /** Serial data */ I2C_BIT_SDA, };