fpgaotsu:change mtd dev mode for plf option bits
@@ -234,11 +234,12 @@ class mtd(loggable):
Raises:
IOError: if the device is not erase or write operation failed.
"""
+ with open(self._devpath, 'wa') as fp:
try:
iodata = struct.pack('II', start, nbytes)
- fcntl.ioctl(self._fp.fileno(), self.IOCTL_MTD_MEMERASE, iodata)
- self._fp.seek(start)
- os.write(self._fp.fileno(), data)
+ fcntl.ioctl(fp.fileno(), self.IOCTL_MTD_MEMERASE, iodata)
+ fp.seek(start)
+ os.write(fp.fileno(), data)
except IOError as err:
self.log.exception('failed to replace data: %s', err)
raise
