[maemo-commits] [maemo-commits] r19160 - in projects/haf/trunk/ke-recv: debian src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Aug 19 19:48:29 EEST 2009
- Previous message: [maemo-commits] r19159 - in projects/haf/trunk/ke-recv: debian src
- Next message: [maemo-commits] r19161 - in projects/haf/trunk/sapwood: . engine
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kihamala
Date: 2009-08-19 19:48:14 +0300 (Wed, 19 Aug 2009)
New Revision: 19160
Modified:
projects/haf/trunk/ke-recv/debian/changelog
projects/haf/trunk/ke-recv/debian/init.d
projects/haf/trunk/ke-recv/debian/ke-recv.upstart
projects/haf/trunk/ke-recv/src/ke-recv.c
projects/haf/trunk/ke-recv/src/pcsuite-disable.sh
Log:
fixes: hal connection improvement, modprobe g_nokia on disconnection
Modified: projects/haf/trunk/ke-recv/debian/changelog
===================================================================
--- projects/haf/trunk/ke-recv/debian/changelog 2009-08-19 14:26:27 UTC (rev 19159)
+++ projects/haf/trunk/ke-recv/debian/changelog 2009-08-19 16:48:14 UTC (rev 19160)
@@ -8,6 +8,8 @@
- Insert g_nokia in startup, unless we're in ACTDEAD mode
- NOTE: requires infonote and infobanner interfaces to be provided on
the system bus also
+ - Assume S_PCSUITE if restarted when the cable is connected
+ - Be more persisting when connecting to hald.
-- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> Wed, 15 Jul 2009 13:02:48 +0300
Modified: projects/haf/trunk/ke-recv/debian/init.d
===================================================================
--- projects/haf/trunk/ke-recv/debian/init.d 2009-08-19 14:26:27 UTC (rev 19159)
+++ projects/haf/trunk/ke-recv/debian/init.d 2009-08-19 16:48:14 UTC (rev 19160)
@@ -54,19 +54,25 @@
case "$1" in
start)
- modprobe omap_hsmmc
- modprobe sd_mod
+ STATE="x$(cat /tmp/STATE)x"
+ if [ $STATE != "xACT_DEADx" -a $STATE != "xTESTx" ]; then
+ modprobe omap_hsmmc
+ modprobe sd_mod
- # Start daemons
- echo -n "Starting $DESC: "
+ # Start daemons
+ echo -n "Starting $DESC: "
- if [ -x $DTOOL ]; then
- $DTOOL -U $USER -n -1 -t $DAEMON
- else
- start-stop-daemon -b --start --quiet --user $USER \
- --exec $DAEMON -- $PARAMS
- fi
- echo "$NAME."
+ # modprobe g_nokia by default, unless in ACT_DEAD
+ modprobe g_nokia
+
+ if [ -x $DTOOL ]; then
+ $DTOOL -U $USER -n -1 -t $DAEMON
+ else
+ start-stop-daemon -b --start --quiet --user $USER \
+ --exec $DAEMON -- $PARAMS
+ fi
+ echo "$NAME."
+ fi
;;
stop)
echo -n "Stopping $DESC: "
Modified: projects/haf/trunk/ke-recv/debian/ke-recv.upstart
===================================================================
--- projects/haf/trunk/ke-recv/debian/ke-recv.upstart 2009-08-19 14:26:27 UTC (rev 19159)
+++ projects/haf/trunk/ke-recv/debian/ke-recv.upstart 2009-08-19 16:48:14 UTC (rev 19160)
@@ -1,9 +1,10 @@
description "starting ke-recv"
author "Philippe De Swert"
+stop on ACT_DEAD
+stop on TEST
+stop on stopping hal
start on started hal
-stop on stopping hal
-stop on ACT_DEAD
console none
script
Modified: projects/haf/trunk/ke-recv/src/ke-recv.c
===================================================================
--- projects/haf/trunk/ke-recv/src/ke-recv.c 2009-08-19 14:26:27 UTC (rev 19159)
+++ projects/haf/trunk/ke-recv/src/ke-recv.c 2009-08-19 16:48:14 UTC (rev 19160)
@@ -224,6 +224,12 @@
handle_event(E_INIT_CARD, &ext_mmc, NULL);
mmc_initialised = TRUE;
}
+
+ if (usb_state == S_INVALID_USB_STATE) {
+ /* try USB init again now that syncd and obexd
+ * should be running */
+ init_usb_cable_status ((void*)1);
+ }
#if 0
if (delayed_auto_install_check) {
possibly_start_am();
@@ -1825,8 +1831,11 @@
if (state == S_HOST) {
handle_usb_event(E_ENTER_HOST_MODE);
} else if (state == S_PERIPHERAL_WAIT) {
- /* go directly to PC Suite mode whenever cable is plugged */
- handle_usb_event(E_ENTER_PCSUITE_MODE);
+ if (usb_state == S_CABLE_DETACHED) {
+ /* go directly to PC Suite mode whenever cable is
+ * plugged */
+ handle_usb_event(E_ENTER_PCSUITE_MODE);
+ }
} else if (state == S_CABLE_DETACHED) {
handle_usb_event(E_CABLE_DETACHED);
}
@@ -1878,8 +1887,12 @@
/* should reset gconf keys here */
} else {
ULOG_DEBUG_F("peripheral but cards not "
- "USB-shared, assuming charging mode");
- usb_state = S_CHARGING;
+ "USB-shared, assuming PC Suite mode");
+ usb_state = S_PCSUITE;
+ if (!enable_pcsuite()) {
+ ULOG_ERR_F("Couldn't enable PC Suite");
+ usb_state = S_INVALID_USB_STATE;
+ }
/*
if (do_e_plugged) {
handle_usb_event(
@@ -1892,7 +1905,8 @@
set_usb_mode_key("idle");
}
- if (desktop_started && !mmc_initialised) {
+ if (usb_state != S_INVALID_USB_STATE &&
+ desktop_started && !mmc_initialised) {
/* initialise GConf keys and possibly mount or
* USB-share */
if (int_mmc_enabled) {
@@ -2903,6 +2917,17 @@
return retval;
}
+static gboolean modprobe_g_nokia()
+{
+ int ret;
+ const char *args[] = {"/sbin/modprobe", "g_nokia", NULL};
+ ret = exec_prog(args[0], args);
+ if (ret)
+ return FALSE;
+ else
+ return TRUE;
+}
+
static void handle_usb_event(usb_event_t e)
{
switch (e) {
@@ -2926,6 +2951,7 @@
show_infobanner(
MSG_USB_DISCONNECTED);
}
+ modprobe_g_nokia();
} else if (usb_state == S_EJECTED) {
ULOG_DEBUG_F("E_CABLE_DETACHED in S_EJECTED");
} else if (usb_state == S_EJECTING) {
@@ -2940,9 +2966,11 @@
"S_CHARGING");
} else if (usb_state == S_PCSUITE) {
ULOG_INFO_F("E_CABLE_DETACHED in S_PCSUITE");
+ /*
if (!disable_pcsuite()) {
ULOG_ERR_F("disable_pcsuite() failed");
}
+ */
} else {
ULOG_WARN_F("E_CABLE_DETACHED in %d!",
usb_state);
@@ -3028,6 +3056,9 @@
usb_state == S_CHARGING ||
usb_state == S_PCSUITE) {
usb_state_t orig = usb_state;
+ if (!disable_pcsuite()) {
+ ULOG_ERR_F("disable_pcsuite() failed");
+ }
usb_state = S_MASS_STORAGE;
if (!e_plugged_helper()) {
ULOG_DEBUG_F("no card was USB shared");
@@ -3108,6 +3139,7 @@
.unregister_function = NULL
};
int ret;
+ int hal_retries = 10;
if (signal(SIGTERM, sigterm) == SIG_ERR) {
ULOG_CRIT_L("signal() failed");
@@ -3191,6 +3223,8 @@
ULOG_CRIT_L("libhal_ctx_set_dbus_connection() failed");
exit(1);
}
+
+try_hal_again:
if (!libhal_ctx_init(hal_ctx, &error)) {
if (dbus_error_is_set(&error)) {
ULOG_CRIT_L("libhal_ctx_init: %s: %s", error.name,
@@ -3198,7 +3232,11 @@
dbus_error_free(&error);
}
ULOG_CRIT_L("Could not initialise connection to hald");
- exit(1);
+ if (--hal_retries > 0) {
+ sleep(1);
+ goto try_hal_again;
+ } else
+ exit(1);
}
do_global_init();
Modified: projects/haf/trunk/ke-recv/src/pcsuite-disable.sh
===================================================================
--- projects/haf/trunk/ke-recv/src/pcsuite-disable.sh 2009-08-19 14:26:27 UTC (rev 19159)
+++ projects/haf/trunk/ke-recv/src/pcsuite-disable.sh 2009-08-19 16:48:14 UTC (rev 19160)
@@ -19,4 +19,37 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
+/sbin/lsmod | grep g_nokia > /dev/null
+if [ $? = 0 ]; then
+ logger "$0: removing g_nokia"
+
+ initctl emit G_NOKIA_REMOVE
+
+ PNATD_PID=`pidof pnatd`
+ if [ $? = 0 ]; then
+ kill $PNATD_PID
+ else
+ logger "$0: pnatd is not running"
+ fi
+ OBEXD_PID=`pidof obexd`
+ if [ $? = 0 ]; then
+ kill -HUP $OBEXD_PID
+ else
+ logger "$0: obexd is not running"
+ fi
+ SYNCD_PID=`pidof syncd`
+ if [ $? = 0 ]; then
+ kill $SYNCD_PID
+ else
+ logger "$0: syncd is not running"
+ fi
+
+ sleep 2
+ /sbin/rmmod g_nokia
+ if [ $? != 0 ]; then
+ logger "$0: failed to rmmod g_nokia!"
+ exit 1
+ fi
+fi
+
exit 0
- Previous message: [maemo-commits] r19159 - in projects/haf/trunk/ke-recv: debian src
- Next message: [maemo-commits] r19161 - in projects/haf/trunk/sapwood: . engine
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
