Commit 535e6ec5 authored by Philippe De Swert's avatar Philippe De Swert

Handle all the kmod init where all the modules are handled

We had the reference to the kmod ctx in usb-moded.c, now instead all is in the module
handling code. Which enables us to plug in libusbg / USB gadget fs later in a
cleaner way.
Signed-off-by: default avatarPhilippe De Swert <philippe.deswert@jollamobile.com>
parent 098b51e1
......@@ -42,9 +42,23 @@
#include "usb_moded-modesetting.h"
#include "usb_moded-modes.h"
/* kmod context - initialized at start in usb_moded_init */
/* kmod context - initialized at start in usb_moded_init by ctx_init()
and cleaned up by ctx_cleanup() functions */
struct kmod_ctx *ctx;
/* kmod module init */
void usb_moded_module_ctx_init(void)
{
ctx = kmod_new(NULL, NULL);
kmod_load_resources(ctx);
}
/* kmod module cleanup */
void usb_moded_module_ctx_cleanup(void)
{
kmod_unref(ctx);
}
/** load module
*
* @param module Name of the module to load
......
......@@ -33,6 +33,12 @@
#define MODULE_DEVELOPER "g_ether"
#define MODULE_MTP "g_ffs"
/* module loading init */
void usb_moded_module_ctx_init(void);
/* module loading context cleanup */
void usb_moded_module_ctx_cleanup(void);
/* load module */
int usb_moded_load_module(const char *module);
......
......@@ -535,8 +535,6 @@ inline struct mode_list_elem * get_usb_mode_data(void)
/* set default values for usb_moded */
static void usb_moded_init(void)
{
extern struct kmod_ctx *ctx;
current_mode.connected = FALSE;
current_mode.mounted = FALSE;
current_mode.mode = strdup(MODE_UNDEFINED);
......@@ -571,8 +569,7 @@ static void usb_moded_init(void)
}
/* kmod init */
ctx = kmod_new(NULL, NULL);
kmod_load_resources(ctx);
usb_moded_module_ctx_init();
/* Android specific stuff */
if(android_settings())
......@@ -607,8 +604,6 @@ static gboolean charging_fallback(gpointer data)
static void handle_exit(void)
{
extern struct kmod_ctx *ctx;
/* exiting and clean-up when mainloop ended */
appsync_stop();
hwal_cleanup();
......@@ -618,7 +613,7 @@ static void handle_exit(void)
#endif /* MEEGOLOCK */
free_mode_list(modelist);
kmod_unref(ctx);
usb_moded_module_ctx_cleanup();
#ifdef APP_SYNC
free_appsync_list();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment