Skip to content

Commit

Permalink
clean up mode also before switching modes after trigger
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe De Swert <phdeswer@lumi.maa>
  • Loading branch information
Philippe De Swert committed Aug 17, 2011
1 parent 57cf9b4 commit 43f67f1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion configure.ac
@@ -1,4 +1,4 @@
AC_INIT([usb_moded], [0.45])
AC_INIT([usb_moded], [0.46])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])

AM_CONFIG_HEADER([config.h])
Expand Down
3 changes: 2 additions & 1 deletion debian/changelog
@@ -1,6 +1,7 @@
usb-moded (0.46) unstable; urgency=low

* Restart usb trigger if the socket gets destroyed.
* Restart usb trigger if the socket gets destroyed. Fixes: NB#277395
* On usb trigger mode switch, clean up mode first.

-- Philippe De Swert <philippe.de-swert@nokia.com> Mon, 15 Aug 2011 15:28:16 +0300

Expand Down
8 changes: 6 additions & 2 deletions src/usb_moded-trigger.c
Expand Up @@ -36,6 +36,7 @@
#include "usb_moded-log.h"
#include "usb_moded-config.h"
#include "usb_moded-hw-ab.h"
#include "usb_moded-modesetting.h"
#include "usb_moded-trigger.h"
#ifdef NOKIA
#include "usb_moded-devicelock.h"
Expand All @@ -56,7 +57,8 @@ static void udev_parse(struct udev_device *dev);
static void notify_issue (gpointer data)
{
log_debug("trigger watch destroyed\n!");
/* restart trigger */
/* clean up & restart trigger */
trigger_stop();
trigger_init();
}

Expand Down Expand Up @@ -188,8 +190,10 @@ static void udev_parse(struct udev_device *dev)
if(!usb_moded_get_export_permission())
#endif /* NOKIA */
if(strcmp(get_trigger_mode(), get_usb_mode()) != 0)
{
usb_moded_mode_cleanup(get_usb_module());
set_usb_mode(get_trigger_mode());

}
}
else
return;
Expand Down
10 changes: 9 additions & 1 deletion src/usb_moded-udev.c
Expand Up @@ -49,6 +49,14 @@ static gboolean monitor_udev(GIOChannel *iochannel G_GNUC_UNUSED, GIOCondition c
gpointer data G_GNUC_UNUSED);
static void udev_parse(struct udev_device *dev);

static void notify_issue (gpointer data)
{
log_debug("USB connection watch destroyed, restarting it\n!");
/* restart trigger */
hwal_cleanup();
hwal_init();
}

gboolean hwal_init(void)
{
const gchar *udev_path = NULL;
Expand Down Expand Up @@ -103,7 +111,7 @@ gboolean hwal_init(void)
udev_parse(dev);

iochannel = g_io_channel_unix_new(udev_monitor_get_fd(mon));
watch_id = g_io_add_watch(iochannel, G_IO_IN, monitor_udev, NULL);
watch_id = g_io_add_watch_full(iochannel, 0, G_IO_IN, monitor_udev, NULL,notify_issue);

/* everything went well */
return TRUE;
Expand Down

0 comments on commit 43f67f1

Please sign in to comment.