|
@@ -239,6 +239,7 @@ static int i2c_reset ( struct bit_basher *basher ) {
|
239
|
239
|
* pull SDA low while SCL is high (which creates a start
|
240
|
240
|
* condition).
|
241
|
241
|
*/
|
|
242
|
+ open_bit ( basher );
|
242
|
243
|
setscl ( basher, 0 );
|
243
|
244
|
setsda ( basher, 1 );
|
244
|
245
|
for ( i = 0 ; i < I2C_RESET_MAX_CYCLES ; i++ ) {
|
|
@@ -251,6 +252,7 @@ static int i2c_reset ( struct bit_basher *basher ) {
|
251
|
252
|
i2c_stop ( basher );
|
252
|
253
|
DBGC ( basher, "I2CBIT %p reset after %d attempts\n",
|
253
|
254
|
basher, ( i + 1 ) );
|
|
255
|
+ close_bit ( basher );
|
254
|
256
|
return 0;
|
255
|
257
|
}
|
256
|
258
|
setscl ( basher, 0 );
|
|
@@ -258,6 +260,7 @@ static int i2c_reset ( struct bit_basher *basher ) {
|
258
|
260
|
|
259
|
261
|
DBGC ( basher, "I2CBIT %p could not reset after %d attempts\n",
|
260
|
262
|
basher, i );
|
|
263
|
+ close_bit ( basher );
|
261
|
264
|
return -ETIMEDOUT;
|
262
|
265
|
}
|
263
|
266
|
|
|
@@ -285,6 +288,8 @@ static int i2c_bit_read ( struct i2c_interface *i2c,
|
285
|
288
|
DBGC ( basher, "I2CBIT %p reading from device %x: ",
|
286
|
289
|
basher, i2cdev->dev_addr );
|
287
|
290
|
|
|
291
|
+ open_bit ( basher );
|
|
292
|
+
|
288
|
293
|
for ( ; ; data++, offset++ ) {
|
289
|
294
|
|
290
|
295
|
/* Select device for writing */
|
|
@@ -312,6 +317,7 @@ static int i2c_bit_read ( struct i2c_interface *i2c,
|
312
|
317
|
|
313
|
318
|
DBGC ( basher, "%s\n", ( rc ? "failed" : "" ) );
|
314
|
319
|
i2c_stop ( basher );
|
|
320
|
+ close_bit ( basher );
|
315
|
321
|
return rc;
|
316
|
322
|
}
|
317
|
323
|
|
|
@@ -339,6 +345,8 @@ static int i2c_bit_write ( struct i2c_interface *i2c,
|
339
|
345
|
DBGC ( basher, "I2CBIT %p writing to device %x: ",
|
340
|
346
|
basher, i2cdev->dev_addr );
|
341
|
347
|
|
|
348
|
+ open_bit ( basher );
|
|
349
|
+
|
342
|
350
|
for ( ; ; data++, offset++ ) {
|
343
|
351
|
|
344
|
352
|
/* Select device for writing */
|
|
@@ -359,9 +367,10 @@ static int i2c_bit_write ( struct i2c_interface *i2c,
|
359
|
367
|
if ( ( rc = i2c_send_byte ( basher, *data ) ) != 0 )
|
360
|
368
|
break;
|
361
|
369
|
}
|
362
|
|
-
|
|
370
|
+
|
363
|
371
|
DBGC ( basher, "%s\n", ( rc ? "failed" : "" ) );
|
364
|
372
|
i2c_stop ( basher );
|
|
373
|
+ close_bit ( basher );
|
365
|
374
|
return rc;
|
366
|
375
|
}
|
367
|
376
|
|