From 1dd7c5b2f57c38973b174488bfe5eb1a98aab0b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Wed, 23 Sep 2015 18:01:04 +0200 Subject: [PATCH] Add a "spinning" alternative to plugin locking (might not be a good idea!) --- klgd.c | 7 +++++++ klgd.h | 1 + 2 files changed, 8 insertions(+) diff --git a/klgd.c b/klgd.c index 78b5aca..e2feee4 100644 --- a/klgd.c +++ b/klgd.c @@ -338,6 +338,13 @@ void klgd_lock_plugins(struct mutex *lock) } EXPORT_SYMBOL_GPL(klgd_lock_plugins); +void klgd_lock_plugins_spin(struct mutex *lock) +{ + while (!mutex_trylock(lock)); + printk(KERN_DEBUG "KLGD: Plugin state locked (spinning)\n"); +} +EXPORT_SYMBOL_GPL(klgd_lock_plugins_spin); + struct klgd_command * klgd_make_command(const char * const bytes, const size_t length) { struct klgd_command *cmd = kzalloc(sizeof(struct klgd_command), GFP_KERNEL); diff --git a/klgd.h b/klgd.h index b10e9c1..1bad9ae 100644 --- a/klgd.h +++ b/klgd.h @@ -47,6 +47,7 @@ void klgd_free_command(const struct klgd_command *cmd); void klgd_free_stream(struct klgd_command_stream *s); int klgd_init(struct klgd_main *ctx, void *dev_ctx, int (*callback)(void *, const struct klgd_command_stream *), const unsigned long plugin_count); void klgd_lock_plugins(struct mutex *lock); +void klgd_lock_plugins_spin(struct mutex *lock); struct klgd_command * klgd_make_cmd(const char * const bytes); int klgd_register_plugin(struct klgd_main *ctx, const size_t idx, struct klgd_plugin *plugin, bool dontfree); void klgd_unlock_plugins(struct mutex *lock); -- 2.43.5