
The approach sxmo_wakeafter uses is flawed because the kernel isn't obligated to pass control to it after suspend. I'm pretty sure it normally gets called when the kernel updates the system clock. Since we're waiting for some time after every suspend we're not actually using opportunistic suspend. It's much simpler to read wakeup_count to ask the kernel to wait until there's no active locks. Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
26 lines
779 B
Bash
Executable File
26 lines
779 B
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
# Copyright 2022 Sxmo Contributors
|
|
|
|
# This script is executed as root
|
|
# from the init process and sets
|
|
# some device-specific permissions
|
|
|
|
if [ -e /proc/device-tree/compatible ]; then
|
|
device="$(tr -c '\0[:alnum:].,-' '_' < /proc/device-tree/compatible |
|
|
tr '\0' '\n' | head -n1)"
|
|
deviceprofile="$(command -v "sxmo_deviceprofile_$device.sh")"
|
|
# shellcheck disable=SC1090
|
|
[ -f "$deviceprofile" ] && . "$deviceprofile"
|
|
fi
|
|
|
|
# the defaults are best guesses
|
|
# users can override this in sxmo_deviceprofile_mydevice.sh
|
|
files="${SXMO_SYS_FILES:-"/sys/power/state /sys/power/mem_sleep /dev/rtc0"}"
|
|
|
|
for file in $files /sys/power/wakeup_count; do
|
|
[ -e "$file" ] && chmod a+rw "$file"
|
|
done
|
|
|
|
chmod -R a+rw /sys/class/wakeup/*
|