Skip to content

Commit

Permalink
Fix charging fall-back and release 0.58
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 Feb 1, 2013
1 parent 3e2d439 commit e1f614f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 13 deletions.
2 changes: 1 addition & 1 deletion configure.ac
@@ -1,4 +1,4 @@
AC_INIT([usb_moded], [0.57])
AC_INIT([usb_moded], [0.58])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])

AM_CONFIG_HEADER([config.h])
Expand Down
14 changes: 11 additions & 3 deletions debian/changelog
@@ -1,16 +1,24 @@
usb-moded (0.58) unstable; urgency=low

* Fix bug with ask mode since module loading failed
* Make sure mac is generated before kmod is initialized to be sure the random mac is used
* Always call clean-up first when modules get switched

-- Philippe De Swert <philippe.deswert@jollamobile.com> Fri, 01 Feb 2013 13:36:47 +0200

usb-moded (0.57) unstable; urgency=low

* Add random mac generator so host based network tools always get the same mac

-- Philippe De Swert <philippedeswert@jollamobile.com> Thu, 17 Jan 2013 19:50:37 +0200
-- Philippe De Swert <philippe.deswert@jollamobile.com> Thu, 17 Jan 2013 19:50:37 +0200

usb-moded (0.56) unstable; urgency=low

* Fix possible compiltation issue with N900 support and android which are mutually exclusive
* Fix g_file_storage fallback which did not work anymore with kmod
* Warn when using dbus methods to change mode when not connected

-- Philippe De Swert <philippedeswert@jollamobile.com> Fri, 11 Jan 2013 18:57:58 +0200
-- Philippe De Swert <philippe.deswert@jollamobile.com> Fri, 11 Jan 2013 18:57:58 +0200

usb-moded (0.55) unstable; urgency=low

Expand All @@ -19,7 +27,7 @@ usb-moded (0.55) unstable; urgency=low
* Add rescue mode
* Add softconnect support

-- Philippe De Swert <philippedeswert@jollamobile.com> Wed, 12 Dec 2012 22:57:42 +0200
-- Philippe De Swert <philippe.deswert@jollamobile.com> Wed, 12 Dec 2012 22:57:42 +0200

usb-moded (0.54) unstable; urgency=low

Expand Down
38 changes: 29 additions & 9 deletions src/usb_moded-modules.c
Expand Up @@ -28,6 +28,7 @@
#include <stdio.h>

#include <glib.h>
#include <glib/gprintf.h>

#include <libkmod.h>

Expand Down Expand Up @@ -73,9 +74,30 @@ int usb_moded_load_module(const char *module)
#else
const int probe_flags = KMOD_PROBE_APPLY_BLACKLIST;
struct kmod_module *mod;
const char *charging_args = NULL;

ret = kmod_module_new_from_name(ctx, module, &mod);
char *charging_args = NULL;
char *load = NULL;

/* 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))
{
/* split the string in module name and argument, they are the same for MODULE_CHARGE_FALLBACK
so no need to handle them separately */
gchar **strings;

/* since the mass_storage module is the newer one and we check against it to avoid
loading failures we use it here, as we fall back to g_file_storage if g_mass_storage
fails to load */
strings = g_strsplit(MODULE_CHARGE_FALLBACK, " ", 2);
log_debug("module args = %s, module = %s\n", strings[1], strings[0]);
charging_args = strdup(strings[1]);
/* load was already assigned. Free it to re-assign */
free(load);
load = strdup(strings[0]);
g_strfreev(strings);

}
ret = kmod_module_new_from_name(ctx, load, &mod);
/* since kmod_module_new_from_name does not check if the module
exists we test it's path in case we deal with the mass-storage one */
if(!strcmp(module, MODULE_MASS_STORAGE) &&
Expand All @@ -84,18 +106,16 @@ int usb_moded_load_module(const char *module)
log_debug("Fallback on older g_file_storage\n");
ret = kmod_module_new_from_name(ctx, MODULE_FILE_STORAGE, &mod);
}
if(!strcmp(module, MODULE_CHARGING) && (ret != 0))
{
/* split the string in module name and arguments, if it still fails do the same
for MODULE_CHARGE_FALLBACK */
}

if(!charging_args)
ret = kmod_module_probe_insert_module(mod, probe_flags, NULL, NULL, NULL, NULL);
else
{
ret = kmod_module_probe_insert_module(mod, probe_flags, charging_args, NULL, NULL, NULL);

free(charging_args);
}
kmod_module_unref(mod);
free(load);
#endif /* NO_KMOD */

softconnect = get_soft_connect_path();
Expand Down
1 change: 1 addition & 0 deletions src/usb_moded.c
Expand Up @@ -473,6 +473,7 @@ static gboolean charging_fallback(gpointer data)
* means a mode has been set */
if(strcmp(get_usb_mode(), MODE_ASK) != 0)
return FALSE;

set_usb_mode(MODE_CHARGING);
/* since this is the fallback, we keep an indication
for the UI, as we are not really in charging mode.
Expand Down

0 comments on commit e1f614f

Please sign in to comment.