1.1 --- a/pkg/devices/lib/i2c/src/jz4730.cc Sat Jan 16 23:48:09 2021 +0100
1.2 +++ b/pkg/devices/lib/i2c/src/jz4730.cc Sat Jan 30 23:38:45 2021 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * I2C support for the JZ4730.
1.6 *
1.7 - * Copyright (C) 2017, 2018, 2020 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2017, 2018, 2020, 2021 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -179,6 +179,8 @@
1.13 if (!set_address(address, true))
1.14 return 0;
1.15
1.16 + // Wait for an opportunity to begin reading.
1.17 +
1.18 do
1.19 {
1.20 if (!wait_for_irq(1000000))
1.21 @@ -186,6 +188,16 @@
1.22 }
1.23 while (transferring() || (!data_valid() && !nack()));
1.24
1.25 + // Device apparently unavailable.
1.26 +
1.27 + if (nack())
1.28 + {
1.29 + stop();
1.30 + return nread;
1.31 + }
1.32 +
1.33 + // Attempt to read from the device.
1.34 +
1.35 while (nread < length)
1.36 {
1.37 do