-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
smbus: eeprom: work around #416 by reading in 128 chunks
Related: #416
- Loading branch information
1 parent
eba1900
commit b21200c
Showing
1 changed file
with
16 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,7 +167,22 @@ def load_eeprom(self, address): | |
dev = f'{self._number}-{address:04x}' | ||
try: | ||
name = self._i2c_dev.joinpath(dev, 'name').read_text().strip() | ||
eeprom = self._i2c_dev.joinpath(dev, 'eeprom').read_bytes() | ||
|
||
# work around a bug in the kernel by reading the ee1004 eeprom | ||
# in small enough chunks | ||
# related: #416 ("DDR4 support broken on Linux 5.16.3") | ||
# related: https://lore.kernel.org/lkml/[email protected]/ | ||
eeprom_path = self._i2c_dev.joinpath(dev, 'eeprom') | ||
eeprom_size = eeprom_path.stat().st_size | ||
_LOGGER.debug('path=%s, size=%s', eeprom_path, eeprom_size) | ||
with eeprom_path.open(mode='rb', buffering=0) as f: | ||
eeprom = bytearray() | ||
while len(eeprom) < eeprom_size: | ||
b = f.read(128) | ||
if not b: | ||
break | ||
eeprom.extend(b) | ||
|
||
return LinuxEeprom(name, eeprom) | ||
except FileNotFoundError: | ||
return None | ||
|