diff options
author | Thibaut VARÈNE <hacks@slashdirt.org> | 2020-04-20 13:48:02 +0200 |
---|---|---|
committer | Koen Vandeputte <koen.vandeputte@ncentric.com> | 2020-05-08 15:17:17 +0200 |
commit | 02a9d3d6a932cdf707f8bcf4555d095839ce8d24 (patch) | |
tree | 8e1f51e4fc3403954c44ce516b1e51d15b0109c1 | |
parent | 8f4735297bbfb24976e06bb4f2f115be29a99404 (diff) | |
download | upstream-02a9d3d6a932cdf707f8bcf4555d095839ce8d24.tar.gz upstream-02a9d3d6a932cdf707f8bcf4555d095839ce8d24.tar.bz2 upstream-02a9d3d6a932cdf707f8bcf4555d095839ce8d24.zip |
package/base-files: add caldata_sysfsload_from_file()
This routine enables loading caldata binary via the kernel sysfs loader
See https://www.kernel.org/doc/html/v4.19/driver-api/firmware/fallback-mechanisms.html
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
-rw-r--r-- | package/base-files/Makefile | 2 | ||||
-rw-r--r-- | package/base-files/files/lib/functions/caldata.sh | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/package/base-files/Makefile b/package/base-files/Makefile index f1f0f17a60..d8e7c31878 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/feeds.mk PKG_NAME:=base-files -PKG_RELEASE:=219 +PKG_RELEASE:=220 PKG_FLAGS:=nonshared PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ diff --git a/package/base-files/files/lib/functions/caldata.sh b/package/base-files/files/lib/functions/caldata.sh index 5e969e3409..6862da7164 100644 --- a/package/base-files/files/lib/functions/caldata.sh +++ b/package/base-files/files/lib/functions/caldata.sh @@ -68,6 +68,21 @@ caldata_from_file() { caldata_die "failed to extract calibration data from $source" } +caldata_sysfsload_from_file() { + local source=$1 + local offset=$(($2)) + local count=$(($3)) + + # test extract to /dev/null first + dd if=$source of=/dev/null iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \ + caldata_die "failed to extract calibration data from $source" + + # can't fail now + echo 1 > /sys/$DEVPATH/loading + dd if=$source of=/sys/$DEVPATH/data iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null + echo 0 > /sys/$DEVPATH/loading +} + caldata_valid() { local expected="$1" local target=$2 |