From: Michal MalĂ˝ Date: Tue, 26 Aug 2014 18:40:05 +0000 (+0200) Subject: Add klgd_make_command() function to create commands from already X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=62a103915ed79ebe655bf94e648385183ff3e081;p=KLGD.git Add klgd_make_command() function to create commands from already allocated byte arrays --- diff --git a/klgd.c b/klgd.c index 4586ec2..0f4affa 100644 --- a/klgd.c +++ b/klgd.c @@ -284,6 +284,18 @@ void klgd_lock_plugins(struct mutex *lock) } EXPORT_SYMBOL_GPL(klgd_lock_plugins); +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); + if (!cmd) + return NULL; + + *(char **)(&cmd->bytes) = bytes; + cmd->length = length; + + return cmd; +} + int klgd_register_plugin(struct klgd_main *ctx, size_t idx, struct klgd_plugin *plugin) { struct klgd_main_private *priv = ctx->private; diff --git a/klgd.h b/klgd.h index c2cdb6d..b78cf8d 100644 --- a/klgd.h +++ b/klgd.h @@ -29,6 +29,7 @@ bool klgd_append_cmd(struct klgd_command_stream *target, const struct klgd_comma void klgd_deinit(struct klgd_main *ctx); 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); +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); void klgd_unlock_plugins(struct mutex *lock); void klgd_unlock_plugins_sched(struct mutex *lock);