Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
remove disconnect debouncing as it is unneeded these days
Signed-off-by: Philippe De Swert <phdeswer@lumi.maa>
  • Loading branch information
Philippe De Swert committed Jun 27, 2011
1 parent 27ef7d1 commit a42afb2
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 27 deletions.
2 changes: 1 addition & 1 deletion configure.ac
@@ -1,4 +1,4 @@
AC_INIT([usb_moded], [0.41])
AC_INIT([usb_moded], [0.43])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])

AM_CONFIG_HEADER([config.h])
Expand Down
22 changes: 22 additions & 0 deletions debian/changelog
@@ -1,3 +1,25 @@
usb-moded (0.44) unstable; urgency=low

* Make disconnect debouncing timeout longer for USB cert Fixes: NB#266884

-- Philippe De Swert <philippe.de-swert@nokia.com> Thu, 23 Jun 2011 12:03:58 +0300

usb-moded (0.43) unstable; urgency=low

* Tweak disconnect debouncing and make sure we do not execute the disconnect
handler when we are connected. Fixes: NB#266157

-- Philippe De Swert <philippe.de-swert@nokia.com> Thu, 16 Jun 2011 14:43:37 +0300

usb-moded (0.42) unstable; urgency=low

* Debounce trigger events
* Only send disconnect signal when we were previously connected
* Make mass storage blocking more verbose
* Retry more before giving up the eMMC unmount. Fixes: NB#258488

-- Philippe De Swert <philippe.de-swert@nokia.com> Wed, 08 Jun 2011 14:23:01 +0300

usb-moded (0.41) unstable; urgency=low

* Fix forgotten case for devicelock/trigger. Fixes: NB#261558
Expand Down
11 changes: 7 additions & 4 deletions src/usb_moded-modesetting.c
Expand Up @@ -38,7 +38,7 @@
#include "usb_moded-config.h"
#include "usb_moded-modesetting.h"

static void report_mass_storage_blocker(const char *mountpoint);
static void report_mass_storage_blocker(const char *mountpoint, int try);

#ifdef MAYBE_NEEDED
int find_number_of_mounts(void)
Expand Down Expand Up @@ -147,17 +147,18 @@ umount: command = g_strconcat("mount | grep ", mounts[i], NULL);
g_free(command);
if(ret != 0)
{
if(try != 1)
if(try != 3)
{
try++;
sleep(1);
log_err("Umount failed. Retrying\n");
report_mass_storage_blocker(mount, 1);
goto umount;
}
else
{
log_err("Unmounting %s failed\n", mount);
report_mass_storage_blocker(mount);
report_mass_storage_blocker(mount, 2);
#ifdef NOKIA
usb_moded_send_error_signal("qtn_usb_filessystem_inuse");
#else
Expand Down Expand Up @@ -194,7 +195,7 @@ umount: command = g_strconcat("mount | grep ", mounts[i], NULL);

}

static void report_mass_storage_blocker(const char *mountpoint)
static void report_mass_storage_blocker(const char *mountpoint, int try)
{
FILE *stream = 0;
gchar *lsof_command = 0;
Expand Down Expand Up @@ -223,6 +224,8 @@ static void report_mass_storage_blocker(const char *mountpoint)
pclose(stream);
}
g_free(lsof_command);
if(try == 2)
log_err("Setting Mass storage blocked. Giving up.\n");

}

Expand Down
5 changes: 5 additions & 0 deletions src/usb_moded-modules.c
Expand Up @@ -103,6 +103,11 @@ const char * usb_moded_find_module(void)
result = MODULE_WINDOWS_NET;
break;
}
if( strstr(text, "g_ncm") )
{
result = "g_ncm";
break;
}
/* if switching without disconnect we might have some dynamic module loaded */
if(strstr(text, get_usb_module()))
{
Expand Down
6 changes: 4 additions & 2 deletions src/usb_moded-trigger.c
Expand Up @@ -179,7 +179,8 @@ static void udev_parse(struct udev_device *dev)
#ifdef NOKIA
if(!usb_moded_get_export_permission())
#endif /* NOKIA */
set_usb_mode(get_trigger_mode());
if(strcmp(get_trigger_mode(), get_usb_mode()) != 0)
set_usb_mode(get_trigger_mode());

}
else
Expand All @@ -190,7 +191,8 @@ static void udev_parse(struct udev_device *dev)
#ifdef NOKIA
if(!usb_moded_get_export_permission())
#endif /* NOKIA */
set_usb_mode(get_trigger_mode());
if(strcmp(get_trigger_mode(), get_usb_mode()) != 0)
set_usb_mode(get_trigger_mode());
}
return;
}
Expand Down
38 changes: 18 additions & 20 deletions src/usb_moded.c
Expand Up @@ -101,11 +101,6 @@ void set_usb_connected(gboolean connected)
if(current_mode.connected)
return;

if(debounce)
{
g_source_remove(debounce);
debounce = 0;
}
#ifdef NOKIA
if(timeout_source)
{
Expand All @@ -117,29 +112,32 @@ void set_usb_connected(gboolean connected)
set_usb_connected_state();
}
else
if(!debounce)
debounce = g_timeout_add_seconds(2, set_disconnected, NULL);

{
current_mode.connected = FALSE;
set_disconnected(NULL);
}

}

static gboolean set_disconnected(gpointer data)
{
current_mode.connected = FALSE;
/* signal usb disconnected */
log_debug("usb disconnected\n");
/* clean-up state */
usb_moded_mode_cleanup(get_usb_module());
usb_moded_send_signal(USB_DISCONNECTED);
/* only disconnect for real if we are actually still disconnected */
if(!get_usb_connection_state())
{
/* signal usb disconnected */
log_debug("usb disconnected\n");
usb_moded_send_signal(USB_DISCONNECTED);
#ifdef NOKIA
timeout_source = g_timeout_add_seconds(5, usb_module_timeout_cleanup, NULL);
/* delayed clean-up of state */
timeout_source = g_timeout_add_seconds(5, usb_module_timeout_cleanup, NULL);
#else
/* unload modules and general cleanup */
usb_moded_module_cleanup(get_usb_module());
/* unload modules and general cleanup */
usb_moded_module_cleanup(get_usb_module());
#endif /* NOKIA */

set_usb_mode(MODE_UNDEFINED);
return FALSE;
set_usb_mode(MODE_UNDEFINED);
}
return FALSE;
}

/** set the chosen usb state
Expand Down Expand Up @@ -348,7 +346,7 @@ gboolean get_usb_connection_state(void)

/** set connection status for some corner cases
*
* @param: connection status that needs to be set. Connected (TRUE)
* @param state The connection status that needs to be set. Connected (TRUE)
*
*/
void set_usb_connection_state(gboolean state)
Expand Down

0 comments on commit a42afb2

Please sign in to comment.