Skip to content

Commit

Permalink
Support mass_storage mode without forcing it to be named mass_storage
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 Sep 18, 2013
1 parent 08b4c3c commit d91d7de
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion docs/usb_moded-doc.txt
Expand Up @@ -212,7 +212,7 @@ for a certain mode. This also means that if you change the files or add/remove s
you need to restart usb_moded. Later when the mode is activated, usb_moded will start
each of them after the module has been loaded and keep track if they have been started.
It will warn you if that failed. This works together with an optional softconnect option
that will need kernel support. (Nokia only atm)
that will need kernel support.

Dynamic modes
-------------
Expand Down Expand Up @@ -242,6 +242,9 @@ Only the mode name and module are mandatory. In case you do not use modules, use
for module (as for the android gadget for example. See the android section for more info)

If appsync or network is not defined, or explicitly set to 0, it will not be used.
To use the mass_storage functions you need to define mass_storage = 1. The needed info for
mass_storage data need to be defined in the config file. (other approaches are possible so this is not
mandatory for all kinds of mass_storage support)

Trigger support
---------------
Expand Down
1 change: 1 addition & 0 deletions src/usb_moded-dyn-config.c
Expand Up @@ -85,6 +85,7 @@ static struct mode_list_elem *read_mode_file(const gchar *filename)
list_item->mode_module = g_key_file_get_string(settingsfile, MODE_ENTRY, MODE_MODULE_KEY, NULL);
log_debug("Dynamic mode module = %s\n", list_item->mode_module);
list_item->appsync = g_key_file_get_integer(settingsfile, MODE_ENTRY, MODE_NEEDS_APPSYNC_KEY, NULL);
list_item->mass_storage = g_key_file_get_integer(settingsfile, MODE_ENTRY, MODE_MASS_STORAGE, 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);
Expand Down
4 changes: 3 additions & 1 deletion src/usb_moded-dyn-config.h
Expand Up @@ -31,6 +31,7 @@
#define MODE_MODULE_KEY "module"
#define MODE_NEEDS_APPSYNC_KEY "appsync"
#define MODE_NETWORK_KEY "network"
#define MODE_MASS_STORAGE "mass_storage"
#define MODE_NETWORK_INTERFACE_KEY "network_interface"
#define MODE_OPTIONS_ENTRY "options"
#define MODE_SYSFS_PATH "sysfs_path"
Expand Down Expand Up @@ -59,6 +60,7 @@ typedef struct mode_list_elem
char *mode_module; /* needed module for given mode */
int appsync; /* requires appsync or not */
int network; /* bring up network or not */
int mass_storage; /* Use mass-storage functions */
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 */
Expand All @@ -74,7 +76,7 @@ typedef struct mode_list_elem
/*@} */
}mode_list_elem;


/* diag is used to select a secondary configuration location for diagnostic purposes */
GList *read_mode_list(int diag);

#endif /* USB_MODED_DYN_CONFIG_H_ */
2 changes: 1 addition & 1 deletion src/usb_moded-modesetting.c
Expand Up @@ -350,7 +350,7 @@ int set_dynamic_mode(void)
if(!data)
return 1;

if(!strcmp(data->mode_name, MODE_MASS_STORAGE))
if(data->mass_storage)
{
return set_mass_storage_mode();
}
Expand Down

0 comments on commit d91d7de

Please sign in to comment.