+suspend_real() {
+ delay=0
+
+ # FIXME: fix the kernel and get rid of this
+ suspend_net
+
+ # get rid of modules that prevent suspend due to bugs
+ modules="$(lsmod | awk '{print $1}' | xargs echo)"
+ blacklist="ehci_hcd g_zero g_audio g_ether g_serial g_midi gadgetfs g_file_storage
+ g_mass_storage g_printer g_cdc g_multi g_hid g_dbgp g_nokia g_webcam g_ncm g_acm_ms"
+ restore_list=""
+ for mod in $modules; do
+ if echo $blacklist | grep -q "\<$mod\>"; then
+ restore_list="$restore_list $mod"
+ rmmod $mod
+ delay=1 # enough?
+ fi
+ done
+
+ # must unmount cards because they will be "ejected" on suspend
+ # (some filesystems may even deadlock if we don't do this due to bugs)
+ grep "/dev/mmcblk" /proc/mounts | awk '{print $1}' | xargs umount -r
+
+ sleep $delay
+ echo mem > /sys/power/state
+
+ # if we are here, either we already resumed or the suspend failed
+ if [ -n "$restore_list" ]; then
+ modprobe $restore_list
+ fi
+
+ resume_net
+ echo 255 > /sys/class/leds/pandora\:\:power/brightness
+
+ # wait here a bit to prevent this script from running again (keep op_power.lock)
+ # in case user did resume using the power switch.
+ sleep 2
+}
+
+suspend_() {
+ # dim power LED
+ echo 16 > /sys/class/leds/pandora\:\:power/brightness
+
+ if [ -e /sys/power/state ]; then
+ suspend_real
+ else
+ lowPowerOn
+ fi
+}
+
+resume() {
+ if [ -e /sys/power/state ]; then
+ # nothing to do
+ echo "resume called unexpectedly" >&2
+ else
+ lowPowerOff
+ fi
+}
+
+suspend_check() {
+ if [ -e /sys/power/state ]; then
+ # in case of real suspend we've already resumed
+ powerstate="on"
+ fi
+}
+