fru-device: Fix issue with i2c scan race condition
Add various changes to help fix the i2c scan race condition that may
result in some i2c bus not being scan properly resulting in missing
device in production.
- Reuse old dbus name if possible to avoid making dbus call to
nonexistent object.
- Manage i2c fd better to avoid misleading error messages
- Handle stall i2c bus better and continue the scan without blocking
- Retry on stalled buses
Tested:
```
/sys/kernel/debug/i2c-fault-injector/i2c-gpio-bus-2# echo 10 > lose_arbitration
// # Wait until the error happen due to timeout
^C
```
```
$ /tmp/fru-device
Error reading bus 2
device at bus 3 address 85 busy
device at bus 44 address 80 busy
device at bus 46 address 80 busy
device at bus 47 address 80 busy
device at bus 48 address 80 busy
device at bus 49 address 80 busy
device at bus 50 address 80 busy
device at bus 51 address 80 busy
device at bus 52 address 85 busy
device at bus 53 address 85 busy
device at bus 54 address 85 busy
device at bus 55 address 85 busy
device at bus 56 address 85 busy
device at bus 57 address 85 busy
device at bus 58 address 85 busy
device at bus 59 address 85 busy
Retrying /dev/i2c-2 in 5 seconds...
File descriptor at bus 2 is closed due to timeout
All I2C devices discovered successfully.
```
Fusion-Link:
- platform11: http://fusion2/231966c3-f095-3c48-af26-e059e31031a1
- platform11: http://fusion2/f4c6b8a2-9880-31a9-81d9-eefdc5c688be
- platform5: http://fusion2/92294a57-ee71-3bba-90b3-4641d3d77397
- platform15: http://fusion2/aa309fa8-6643-372d-ad6b-b039f2b1c56c
- platform17: http://fusion2/245ae348-8202-38ef-936c-82a3511035ce
Google-Bug-Id: 471844579
Change-Id: I867877475151e14abdd788561693d3c8b47e8e48
Signed-off-by: Willy Tu <wltu@google.com>
7 files changed