]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
Change read_bit() to return 0 or -1UL, rather than 0 or 1.
authorMichael Brown <mcb30@etherboot.org>
Mon, 12 Jun 2006 19:29:50 +0000 (19:29 +0000)
committerMichael Brown <mcb30@etherboot.org>
Mon, 12 Jun 2006 19:29:50 +0000 (19:29 +0000)
src/drivers/bitbash/bitbash.c
src/drivers/bitbash/i2c_bit.c
src/include/gpxe/i2c.h

index 270c1b922cb6ccb267afbbfff173e712055c2654..92abe1a707cf2a86eaf162db6adb6c23c0e8dfb8 100644 (file)
@@ -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 );
 }
index 9524d63122ffb44983d5f95bdf77e7d59f2a407e..cc73968b7dd8585a7284df9a9d1e77965b1fd672 100644 (file)
@@ -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 */
index e282810be8fdd13b6a88b755861f308790f0bbdb..bfaee8fb57bc17de25e3bdacefe39618bc756511 100644 (file)
@@ -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,
 };