Skip to content

Commit

Permalink
Include the new mode data in the mode setting chain
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 fae2d26 commit 3f720ca
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/usb_moded-modesetting.c
Expand Up @@ -296,6 +296,14 @@ int set_dynamic_mode(struct mode_list_elem *data)
usb_network_up();
#endif /* DEBIAN */
}
if(data->sysfs_path)
{
write_to_file(data->sysfs_path, data->sysfs_value);
}
if(data->softconnect)
{
write_to_file(data->softconnect_path, data->softconnect);
}

return(0);
}
Expand Down
1 change: 0 additions & 1 deletion src/usb_moded-modules.h
Expand Up @@ -32,7 +32,6 @@
#define MODULE_NONE "none"
#define MODULE_DEVELOPER "g_ether"
#define MODULE_MTP "g_ffs"
#define MODULE_NONE "none"

/* load module */
int usb_moded_load_module(const char *module);
Expand Down
26 changes: 25 additions & 1 deletion src/usb_moded.c
Expand Up @@ -279,16 +279,20 @@ void set_usb_mode(const char *mode)
set_usb_module(data->mode_module);
ret = usb_moded_load_module(data->mode_module);
ret = set_dynamic_mode(data);
set_usb_mode_data(data);
}
}
}

end:
/* if ret != 0 then usb_module loading failed */
/* if ret != 0 then usb_module loading failed
no mode matched or MODE_UNDEFINED was requested */
if(ret)
{
set_usb_module(MODULE_NONE);
mode = MODE_UNDEFINED;
/*TODO: unset_dynamic_mode */
set_usb_mode_data(NULL);
}
if(net)
log_debug("Network setting failed!\n");
Expand Down Expand Up @@ -412,6 +416,26 @@ inline void set_usb_connection_state(gboolean state)
current_mode.connected = state;
}

/** set the mode_list_elem data
*
* @param data mode_list_element pointer
*
*/
void set_usb_mode_data(struct mode_list_elem *data)
{
current_mode.data = data;
}

/** get the usb mode data
*
* @return a pointer to the usb mode data
*
*/
inline struct mode_list_elem * get_usb_mode_data(void)
{
return(current_mode.data);
}

/*================ Static functions ===================================== */

/* set default values for usb_moded */
Expand Down
5 changes: 5 additions & 0 deletions src/usb_moded.h
Expand Up @@ -35,6 +35,8 @@
#include <glib-2.0/glib.h>
#include <glib-object.h>

#include "usb_moded-dyn-config.h"

#define USB_MODED_LOCKFILE "/var/run/usb_moded.pid"
#define MAX_READ_BUF 512

Expand All @@ -48,6 +50,7 @@ typedef struct usb_mode
gboolean mounted; /* mount status, 1 for mounted -UNUSED atm- */
char *mode; /* the mode name */
char *module; /* the module name for the specific mode */
struct mode_list_elem *data; /* contains the mode data */
/*@}*/
}usb_mode;

Expand All @@ -57,6 +60,8 @@ void set_usb_mode(const char *mode);
const char * get_usb_mode(void);
void set_usb_module(const char *module);
const char * get_usb_module(void);
void set_usb_mode_data(struct mode_list_elem *data);
struct mode_list_elem * get_usb_mode_data(void);
gboolean get_usb_connection_state(void);
void set_usb_connection_state(gboolean state);
void set_charger_connected(gboolean state);
Expand Down

0 comments on commit 3f720ca

Please sign in to comment.