struct klgd_command_stream *last_stream;
size_t plugin_count;
struct klgd_plugin **plugins;
+ bool *dontfree;
struct mutex plugins_lock;
struct mutex send_lock;
struct workqueue_struct *wq;
if (!plugin)
continue;
+ if (priv->dontfree[idx])
+ continue;
if (plugin->deinit)
plugin->deinit(plugin);
kfree(plugin);
}
kfree(priv->plugins);
+ kfree(priv->dontfree);
kfree(priv);
}
ret = -ENOMEM;
goto err_out;
}
+ priv->dontfree = kzalloc(sizeof(bool) * plugin_count, GFP_KERNEL);
+ if (!priv->dontfree) {
+ printk(KERN_ERR "No memory for plugin quirks\n");
+ ret = -ENOMEM;
+ goto err_out2;
+ }
priv->plugin_count = plugin_count;
priv->device_context = dev_ctx;
ctx->private = priv;
return 0;
+err_out2:
+ kfree(priv->plugins);
err_out:
destroy_workqueue(priv->wq);
kfree(ctx->private);
}
EXPORT_SYMBOL_GPL(klgd_make_command);
-int klgd_register_plugin(struct klgd_main *ctx, size_t idx, struct klgd_plugin *plugin)
+int klgd_register_plugin(struct klgd_main *ctx, size_t idx, struct klgd_plugin *plugin, bool dontfree)
{
struct klgd_main_private *priv = ctx->private;
plugin->plugins_lock = &priv->plugins_lock;
priv->plugins[idx] = plugin;
+ priv->dontfree[idx] = dontfree;
if (plugin->init)
return plugin->init(plugin);
struct klgd_command {
- char * const bytes;
+ __u8 * const bytes;
size_t length;
};
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);
+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);
void klgd_unlock_plugins_sched(struct mutex *lock);