I have made the following changes intended for :
  CE:MW:Shared / usb-moded

Please review and accept or decline.
BOSS has already run some checks on this request.
See the "Messages from BOSS" section below.

https://build.pub.meego.com//request/show/7796

Thank You,
philippedeswert

[This message was auto-generated]

---

Request # 7796:

Messages from BOSS:

State: review at 2013-02-01T16:54:04 by bossbot

Reviews:
       accepted by bossbot : Prechecks succeeded.
       new for CE-maintainers : Please replace this text with a review and 
approve/reject the review (not the SR). BOSS will take care of the rest

Changes:
  submit: home:philippedeswert:branches:CE:MW:Shared / usb-moded -> 
CE:MW:Shared / usb-moded
  
changes files:
--------------
--- usb-moded.changes
+++ usb-moded.changes
@@ -0,0 +1,5 @@
+* Fri Feb 01 2013 Philippe De Swert <[email protected]> - 0.58
+- 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
+
@@ -8 +13 @@
-* Thu Jan 17 2013 Philippe De Swert <[email protected]> - 0.57
+* Thu Jan 17 2013 Philippe De Swert <[email protected]> - 0.57
@@ -12 +17 @@
-* Fri Jan 11 2013 Philippe De Swert <[email protected]> - 0.56
+* Fri Jan 11 2013 Philippe De Swert <[email protected]> - 0.56
@@ -17 +22 @@
-* Tue Dec 18 2012 Philippe De Swert <[email protected]> - 0.55
+* Tue Dec 18 2012 Philippe De Swert <[email protected]> - 0.55

old:
----
  usb-moded-0.57.1.tar.bz2

new:
----
  usb-moded-0.58.tar.bz2

spec files:
-----------
--- usb-moded.spec
+++ usb-moded.spec
@@ -1,5 +1,5 @@
 Name:     usb-moded
-Version:  0.57.1
+Version:  0.58
 Release:  0 
 Summary:  USB mode controller
 Group:    System/System Control

other changes:
--------------

++++++ usb-moded-0.57.1.tar.bz2 -> usb-moded-0.58.tar.bz2
--- configure.ac
+++ 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])
--- debian/changelog
+++ debian/changelog
@@ -1,8 +1,16 @@
+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 <[email protected]> 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 <[email protected]> Thu, 17 Jan 2013 
19:50:37 +0200
+ -- Philippe De Swert <[email protected]> Thu, 17 Jan 2013 
19:50:37 +0200
 
 usb-moded (0.56) unstable; urgency=low
 
@@ -10,7 +18,7 @@
   * 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 <[email protected]> Fri, 11 Jan 2013 
18:57:58 +0200
+ -- Philippe De Swert <[email protected]> Fri, 11 Jan 2013 
18:57:58 +0200
 
 usb-moded (0.55) unstable; urgency=low
 
@@ -19,7 +27,7 @@
   * Add rescue mode
   * Add softconnect support
 
- -- Philippe De Swert <[email protected]> Wed, 12 Dec 2012 
22:57:42 +0200
+ -- Philippe De Swert <[email protected]> Wed, 12 Dec 2012 
22:57:42 +0200
 
 usb-moded (0.54) unstable; urgency=low
 
--- src/usb_moded-modules.c
+++ src/usb_moded-modules.c
@@ -28,6 +28,7 @@
 #include <stdio.h>
 
 #include <glib.h>
+#include <glib/gprintf.h>
 
 #include <libkmod.h>
 
@@ -73,9 +74,31 @@
 #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);
+         
+       }
+       log_debug("module to load = %s\n", load);
+       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) && 
@@ -84,18 +107,17 @@
          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
+       {
+               log_debug("Loading with module args\n");
                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();
@@ -266,9 +288,15 @@
        if(failure && !strcmp(MODULE_MASS_STORAGE, module))
                failure = usb_moded_unload_module(MODULE_FILE_STORAGE);
 
+       /* if it still failed it might be the mode has not been cleaned-up 
correctly,
+          so we clean up the mode to be sure */
+       if(failure)
+       {
+               usb_moded_mode_cleanup(usb_moded_find_module());
+       }
+
        while(failure)
        {
-               // SP: up to 2 second sleep -> worth a warning log?
                /* module did not get unloaded. We will wait a bit and try 
again */
                sleep(1);
                /* send the REALLY  disconnect message */
--- src/usb_moded.c
+++ src/usb_moded.c
@@ -473,6 +473,7 @@
    * 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.



Reply via email to