From: Michael Gernoth Date: Mon, 29 Oct 2012 11:42:49 +0000 (+0100) Subject: wait for module to be loaded before trying to set parameters X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-fixes/commitdiff_plain/2b26b706ee901d201d424c5e6386649f5fb16636?ds=sidebyside wait for module to be loaded before trying to set parameters --- diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java index fbcc837..b01b2b5 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java @@ -93,6 +93,16 @@ public class DebounceModuleHelper runAsRoot(insmod + " " + debounce_ko); + int cnt = 10; + while ((!isLoaded()) && (cnt > 0)) { + try { + Thread.sleep(100); + } catch (Exception e) { + return false; + } + cnt--; + } + if (!isLoaded()) { return false; } @@ -123,6 +133,7 @@ public class DebounceModuleHelper public synchronized boolean isLoaded() { boolean loaded = false; + try { String read; @@ -131,10 +142,13 @@ public class DebounceModuleHelper while((read = modules_buf.readLine()) != null) { if (read.regionMatches(0, "debounce", 0, 8)) { - loaded = true; + File sysdir = new File("/sys/devices/debounce"); + if (sysdir.exists() && sysdir.isDirectory()) { + loaded = true; + break; + } } } - } catch (Exception e) { loaded = false; }