Skip to content

Commit

Permalink
Fill in new list-item type
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed May 27, 2013
1 parent 95cc997 commit fae2d26
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/usb_moded-dyn-config.c
Expand Up @@ -53,7 +53,7 @@ GList *read_mode_list(void)
g_dir_close(confdir);
}
else
log_debug("Dynamic mode confdir open failed.\n");
log_debug("Mode confdir open failed or file is incomplete/invalid.\n");
return(modelist);
}

Expand Down Expand Up @@ -82,6 +82,10 @@ static struct mode_list_elem *read_mode_file(const gchar *filename)
list_item->appsync = g_key_file_get_integer(settingsfile, MODE_ENTRY, MODE_NEEDS_APPSYNC_KEY, NULL);
list_item->network = g_key_file_get_integer(settingsfile, MODE_ENTRY, MODE_NETWORK_KEY, NULL);
list_item->network_interface = g_key_file_get_string(settingsfile, MODE_ENTRY, MODE_NETWORK_INTERFACE_KEY, NULL);
list_item->sysfs_path = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_SYSFS_PATH, NULL);
list_item->sysfs_value = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_SYSFS_VALUE, NULL);
list_item->softconnect = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_SOFTCONNECT, NULL);
list_item->softconnect_path = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_SOFTCONNECT_PATH, NULL);
g_key_file_free(settingsfile);
if(list_item->mode_name == NULL || list_item->mode_module == NULL)
{
Expand All @@ -95,6 +99,18 @@ static struct mode_list_elem *read_mode_file(const gchar *filename)
free(list_item);
return NULL;
}
if(list_item->sysfs_path && list_item->sysfs_value == NULL)
{
/* free list_item as it will not be used */
free(list_item);
return NULL;
}
if(list_item->softconnect && list_item->softconnect_path == NULL)
{
/* free list_item as it will not be used */
free(list_item);
return NULL;
}
else
return(list_item);
}
Expand Down
5 changes: 5 additions & 0 deletions src/usb_moded-dyn-config.h
Expand Up @@ -31,6 +31,7 @@
#define MODE_NEEDS_APPSYNC_KEY "appsync"
#define MODE_NETWORK_KEY "network"
#define MODE_NETWORK_INTERFACE_KEY "network_interface"
#define MODE_OPTIONS_ENTRY "options"
#define MODE_SYSFS_PATH "sysfs_path"
#define MODE_SYSFS_VALUE "sysfs_value"
#define MODE_SOFTCONNECT "softconnect"
Expand All @@ -47,6 +48,10 @@ typedef struct mode_list_elem
int appsync; /* requires appsync or not */
int network; /* bring up network or not */
char *network_interface; /* Which network interface to bring up if network needs to be enabled */
char *sysfs_path; /* path to set sysfs options */
char *sysfs_value; /* option name/value to write to sysfs */
char *softconnect; /* value to be written to softconnect interface */
char *softconnect_path; /* path for the softconnect */
/*@} */
}mode_list_elem;

Expand Down
16 changes: 15 additions & 1 deletion src/usb_moded-modules.c
Expand Up @@ -55,9 +55,13 @@ int usb_moded_load_module(const char *module)
{
int ret = 0;
const char * softconnect;

#ifdef NO_KMOD
gchar *command;

if(!strcmp(module, MODULE_NONE))
return 0;

command = g_strconcat("modprobe ", module, NULL);
ret = system(command);
if(!strcmp(module, MODULE_MASS_STORAGE) && (ret != 0))
Expand All @@ -76,7 +80,10 @@ int usb_moded_load_module(const char *module)
struct kmod_module *mod;
char *charging_args = NULL;
char *load = NULL;


if(!strcmp(module, MODULE_NONE))
return 0;

/* copy module to load as it might be modified if we're trying charging mode */
load = strdup(module);
if(!strcmp(module, MODULE_CHARGING) || !strcmp(module, MODULE_CHARGE_FALLBACK))
Expand Down Expand Up @@ -140,15 +147,22 @@ int usb_moded_unload_module(const char *module)
int ret = 0;
const char * softconnect;


#ifdef NO_KMOD
gchar *command;

if(!strcmp(module, MODULE_NONE))
return 0;

command = g_strconcat("rmmod ", module, NULL);
ret = system(command);
g_free(command);
#else
struct kmod_module *mod;

if(!strcmp(module, MODULE_NONE))
return 0;

kmod_module_new_from_name(ctx, module, &mod);
ret = kmod_module_remove_module(mod, KMOD_REMOVE_NOWAIT);
kmod_module_unref(mod);
Expand Down

0 comments on commit fae2d26

Please sign in to comment.