Kobo: Yet another attempt at working around the hangs on the latest NXP boards (#10771)

* Notification: Drop the fencing from #10083; it never actually helped, and had subtle side-effects we could do without.
* VirtualKeyBoard: Flash on close, otherwise, some of the fast refresh glitches may be burned into the working buffer until a flash. Making sure we flash ourselves prevent it from sticking around on the page ;).
* util: Move `writeToSysfs` to base (i.e., `ffi/util`), as we need it there (and it actually makes more sense there anyway ;p).
* Bump base for https://github.com/koreader/koreader-base/pull/1645, which is where the actual workaround (hopefully) lives.

Re #8414, #9806, #10558
This commit is contained in:
NiLuJe
2023-08-01 23:53:10 +02:00
committed by GitHub
parent 689d9e2976
commit 9c8e55b3e5
9 changed files with 51 additions and 59 deletions

View File

@@ -5,13 +5,9 @@ This module contains miscellaneous helper functions for the KOReader frontend.
local BaseUtil = require("ffi/util")
local Utf8Proc = require("ffi/utf8proc")
local lfs = require("libs/libkoreader-lfs")
local logger = require("logger")
local _ = require("gettext")
local C_ = _.pgettext
local T = BaseUtil.template
local ffi = require("ffi")
local C = ffi.C
require("ffi/posix_h")
local lshift = bit.lshift
local rshift = bit.rshift
@@ -833,26 +829,6 @@ function util.removeFile(file)
end
end
function util.writeToSysfs(val, file)
-- NOTE: We do things by hand via ffi, because io.write uses fwrite,
-- which isn't a great fit for procfs/sysfs (e.g., we lose failure cases like EBUSY,
-- as it only reports failures to write to the *stream*, not to the disk/file!).
local fd = C.open(file, bit.bor(C.O_WRONLY, C.O_CLOEXEC)) -- procfs/sysfs, we shouldn't need O_TRUNC
if fd == -1 then
logger.err("Cannot open file `" .. file .. "`:", ffi.string(C.strerror(ffi.errno())))
return
end
val = tostring(val)
local bytes = #val
local nw = C.write(fd, val, bytes)
if nw == -1 then
logger.err("Cannot write `" .. val .. "` to file `" .. file .. "`:", ffi.string(C.strerror(ffi.errno())))
end
C.close(fd)
-- NOTE: Allows the caller to possibly handle short writes (not that these should ever happen here).
return nw == bytes
end
-- Gets total, used and available bytes for the mountpoint that holds a given directory.
-- @string path of the directory
-- @treturn table with total, used and available bytes