MODULE_AUTHOR("Michal \"MadCatX\" Maly");
MODULE_DESCRIPTION("Pluginable framework of helper functions to handle gaming devices");
-#define TRYAGAIN_DELAY 5
+#define TRYAGAIN_DELAY msecs_to_jiffies(10)
struct klgd_main_private {
struct delayed_work work;
return -EAGAIN;
for (idx = 0; idx < priv->plugin_count; idx++) {
- struct klgd_plugin *plugin = priv->plugins[idx];
+ struct klgd_plugin *plugin = priv->plugins[idx];
struct klgd_command_stream *ss = plugin->get_commands(plugin, now);
if (klgd_append_stream(*s, ss)) {
klgd_free_stream(*s);
unsigned long now;
int ret;
+ printk(KERN_NOTICE "KLGD/WQ: --- WQ begins ---\n");
mutex_lock(&priv->send_lock);
printk(KERN_NOTICE "KLGD/WQ: Timer fired and send_lock acquired\n");
mutex_lock(&priv->plugins_lock);
- printk(KERN_NOTICE "KLGD/WQ: Plugins state locked\n");
+ printk(KERN_NOTICE "KLGD/WQ: Plugins state locked - building command stream\n");
ret = klgd_build_command_stream(priv, &s);
mutex_unlock(&priv->plugins_lock);
+ printk(KERN_NOTICE "KLGD/WQ: Plugins state unlocked - command stream built\n");
switch (ret) {
case -EAGAIN:
/* We're done submitting, check if there is some work for us in the future */
mutex_lock(&priv->plugins_lock);
+ printk(KERN_NOTICE "KLGD/WQ: Plugins state unlocked - checking if there is more to do in the future\n");
klgd_schedule_update(priv);
- printk(KERN_NOTICE "KLGD/WQ: Plugins state unlocked\n");
mutex_unlock(&priv->plugins_lock);
+ printk(KERN_NOTICE "KLGD/WQ: Plugins state unlocked - scheduling complete\n");
+ printk(KERN_NOTICE "KLGD/WQ: --- WQ complete ---\n");
}
static void klgd_free_command(const struct klgd_command *cmd)
}
if (!events) {
+ bool ret;
printk(KERN_NOTICE "No events, deactivating timer\n");
- cancel_delayed_work(&priv->work);
+ ret = cancel_delayed_work(&priv->work);
+ if (ret)
+ printk(KERN_NOTICE "KLGD: Work canceled\n");
+ else
+ printk(KERN_NOTICE "KLGD: There was to work to cancel\n");
} else {
printk(KERN_NOTICE "Events: %u, earliest: %lu, now: %lu\n", events, earliest, now);
- queue_delayed_work(priv->wq, &priv->work, earliest - now);
+ if (time_before(earliest, now))
+ printk(KERN_WARNING "KLGD: Time of earliest update is in the past. Is is probably caused by a buggy plugin. No update scheduled.\n");
+ else {
+ int ret = queue_delayed_work(priv->wq, &priv->work, earliest - now);
+ if (!ret) {
+ printk(KERN_WARNING "KLGD: Work was already on the queue!\n");
+ }
+ }
}
}