[maemo-commits] [maemo-commits] r18689 - in projects/haf/trunk/ke-recv: debian src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Jun 10 14:13:37 EEST 2009
- Previous message: [maemo-commits] r18688 - in projects/haf/trunk/hildon-thumbnail: . daemon
- Next message: [maemo-commits] r18690 - projects/haf/trunk/libosso/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kihamala Date: 2009-06-10 14:13:32 +0300 (Wed, 10 Jun 2009) New Revision: 18689 Modified: projects/haf/trunk/ke-recv/debian/changelog projects/haf/trunk/ke-recv/debian/init.d projects/haf/trunk/ke-recv/src/ke-recv.c projects/haf/trunk/ke-recv/src/osso-usb-mass-storage-disable.sh projects/haf/trunk/ke-recv/src/osso-usb-mass-storage-enable.sh projects/haf/trunk/ke-recv/src/pcsuite-disable.sh projects/haf/trunk/ke-recv/src/pcsuite-enable.sh Log: changes for the new USB architecture Modified: projects/haf/trunk/ke-recv/debian/changelog =================================================================== --- projects/haf/trunk/ke-recv/debian/changelog 2009-06-10 10:33:01 UTC (rev 18688) +++ projects/haf/trunk/ke-recv/debian/changelog 2009-06-10 11:13:32 UTC (rev 18689) @@ -3,6 +3,7 @@ * Fixes: NB#121472 - mmc-pre-unmount crashes on mass storage mode when memory is full * Changes for the new USB handling architecture. + * Reduce some syslog spam. -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> Wed, 10 Jun 2009 09:47:20 +0300 Modified: projects/haf/trunk/ke-recv/debian/init.d =================================================================== --- projects/haf/trunk/ke-recv/debian/init.d 2009-06-10 10:33:01 UTC (rev 18688) +++ projects/haf/trunk/ke-recv/debian/init.d 2009-06-10 11:13:32 UTC (rev 18689) @@ -60,14 +60,22 @@ # Start daemons echo -n "Starting $DESC: " - # g_nokia is loaded as the default - modprobe g_nokia + # g_nada is loaded as the default + modprobe g_nada # check if this is the first boot if [ -e /home/user/first-boot-flag ]; then export FIRST_BOOT=1 fi + # check if this is TA image + if [ -x /usr/bin/sysinfo-tool ]; then + sysinfo-tool -g /device/sw-release-ver | grep -q _TA_ + if [ $? = 0 ]; then + export TA_IMAGE=1 + fi + fi + if [ -x $DTOOL ]; then $DTOOL -U $USER -n -1 -t $DAEMON else Modified: projects/haf/trunk/ke-recv/src/ke-recv.c =================================================================== --- projects/haf/trunk/ke-recv/src/ke-recv.c 2009-06-10 10:33:01 UTC (rev 18688) +++ projects/haf/trunk/ke-recv/src/ke-recv.c 2009-06-10 11:13:32 UTC (rev 18689) @@ -1629,15 +1629,31 @@ return 1; } +#define USB_PROP "usb_device.vbus" + usb_state_t get_usb_state(void) { usb_state_t ret; - char *prop = NULL; + int prop = -1; if (usb_cable_udi != NULL) { - prop = get_prop_string(usb_cable_udi, "usb_device.mode"); + prop = get_prop_int(usb_cable_udi, USB_PROP); } + if (prop == -1) { + ULOG_ERR_F("couldn't read '" USB_PROP "' from %s", + usb_cable_udi); + ret = S_INVALID_USB_STATE; + } else if (prop == 0) { + ret = S_CABLE_DETACHED; + } else if (prop == 1) { + ret = S_PERIPHERAL_WAIT; + } else { + ULOG_ERR_F("unknown " USB_PROP " value %d", prop); + ret = S_CABLE_DETACHED; + } + +#if 0 /* old architecture */ if (prop == NULL) { ULOG_ERR_F("couldn't read 'usb_device.mode' from %s", usb_cable_udi); @@ -1660,6 +1676,7 @@ ret = S_CABLE_DETACHED; } if (prop != NULL) libhal_free_string(prop); +#endif return ret; } @@ -1677,6 +1694,7 @@ "button.type", "usb.cable", &num_devices, &error); if (list != NULL && num_devices >= 1) { usb_cable_udi = strdup(list[0]); + ULOG_DEBUG_F("using USB cable udi '%s'", usb_cable_udi); } else { ULOG_ERR_F("coudn't find USB cable indicator"); } @@ -1786,7 +1804,11 @@ if (state == S_HOST) { handle_usb_event(E_ENTER_HOST_MODE); } else if (state == S_PERIPHERAL_WAIT) { - handle_usb_event(E_ENTER_PERIPHERAL_WAIT_MODE); + if (getenv("TA_IMAGE")) + /* in TA image, we don't wait for user's decision */ + handle_usb_event(E_ENTER_PCSUITE_MODE); + else + handle_usb_event(E_ENTER_PERIPHERAL_WAIT_MODE); } else if (state == S_CABLE_DETACHED) { handle_usb_event(E_CABLE_DETACHED); } @@ -1872,9 +1894,13 @@ dbus_bool_t is_added) { if (is_added) { + /* ULOG_DEBUG_F("udi %s added %s", udi, key); + */ } else if (is_removed) { + /* ULOG_DEBUG_F("udi %s removed %s", udi, key); + */ } else { int val; @@ -1884,7 +1910,7 @@ return; } - if (strcmp("usb_device.mode", key) == 0) { + if (strcmp(USB_PROP, key) == 0) { check_usb_cable(); return; } @@ -2995,7 +3021,8 @@ break; case E_ENTER_PCSUITE_MODE: if (usb_state == S_PERIPHERAL_WAIT || - usb_state == S_CHARGING) { + usb_state == S_CHARGING || + usb_state == S_CABLE_DETACHED) { usb_state = S_PCSUITE; if (!enable_pcsuite()) { ULOG_ERR_F("Couldn't enable PC Suite"); Modified: projects/haf/trunk/ke-recv/src/osso-usb-mass-storage-disable.sh =================================================================== --- projects/haf/trunk/ke-recv/src/osso-usb-mass-storage-disable.sh 2009-06-10 10:33:01 UTC (rev 18688) +++ projects/haf/trunk/ke-recv/src/osso-usb-mass-storage-disable.sh 2009-06-10 11:13:32 UTC (rev 18689) @@ -26,7 +26,11 @@ /sbin/lsmod | grep g_file_storage > /dev/null if [ $? != 0 ]; then - # the module is not loaded + # the module is not loaded, ensure g_nada + /sbin/modprobe g_nada + if [ $? != 0 ]; then + logger "$0: failed to install g_nada" + fi exit 0 fi @@ -35,27 +39,46 @@ LUN1='gadget-lun1' if [ $# = 0 ]; then - # unload all + # unload both echo "" > $GADGETPATH/$LUN0/file echo "" > $GADGETPATH/$LUN1/file - exit 0 +else + # NOTE: works only for 1 or 2 device arguments + for lun in $LUN0 $LUN1; do + grep $1 $GADGETPATH/$lun/file > /dev/null + RC=$? + + if [ $# = 2 ]; then + grep $2 $GADGETPATH/$lun/file > /dev/null + RC2=$? + else + RC2=1 + fi + + if [ $RC = 0 -o $RC2 = 0 ]; then + echo "" > $GADGETPATH/$lun/file + fi + done fi -# NOTE: works only for 1 or 2 device arguments -for lun in $LUN0 $LUN1; do - grep $1 $GADGETPATH/$lun/file > /dev/null - RC=$? +# unload g_file_storage only if it is "empty" +TMP1=$(cat $GADGETPATH/$LUN0/file) +TMP2=$(cat $GADGETPATH/$LUN1/file) - if [ $# = 2 ]; then - grep $2 $GADGETPATH/$lun/file > /dev/null - RC2=$? - else - RC2=1 +if [ x${TMP1}${TMP2}x = xx ]; then + /sbin/lsmod | grep g_file_storage > /dev/null + if [ $? = 0 ]; then + logger "$0: removing g_file_storage" + /sbin/rmmod g_file_storage + if [ $? != 0 ]; then + logger "$0: failed to rmmod g_file_storage!" + fi fi - if [ $RC = 0 -o $RC2 = 0 ]; then - echo "" > $GADGETPATH/$lun/file + /sbin/modprobe g_nada + if [ $? != 0 ]; then + logger "$0: failed to install g_nada" fi -done +fi exit 0 Modified: projects/haf/trunk/ke-recv/src/osso-usb-mass-storage-enable.sh =================================================================== --- projects/haf/trunk/ke-recv/src/osso-usb-mass-storage-enable.sh 2009-06-10 10:33:01 UTC (rev 18688) +++ projects/haf/trunk/ke-recv/src/osso-usb-mass-storage-enable.sh 2009-06-10 11:13:32 UTC (rev 18689) @@ -3,7 +3,7 @@ # # Copyright (C) 2004-2009 Nokia Corporation. All rights reserved. # -# Contact: Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> +# Author: Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -19,41 +19,13 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA -RC=0 - -/sbin/lsmod | grep g_nokia > /dev/null +/sbin/lsmod | grep g_nada > /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 + logger "$0: removing g_nada" + /sbin/rmmod g_nada fi +RC=0 /sbin/lsmod | grep g_file_storage > /dev/null if [ $? != 0 ]; then /sbin/modprobe g_file_storage stall=0 luns=2 removable @@ -62,6 +34,11 @@ if [ $RC != 0 ]; then logger "$0: failed to install g_file_storage" + # put g_nada back + /sbin/modprobe g_nada + if [ $? != 0 ]; then + logger "$0: failed to install g_nada back" + fi exit 1 fi Modified: projects/haf/trunk/ke-recv/src/pcsuite-disable.sh =================================================================== --- projects/haf/trunk/ke-recv/src/pcsuite-disable.sh 2009-06-10 10:33:01 UTC (rev 18688) +++ projects/haf/trunk/ke-recv/src/pcsuite-disable.sh 2009-06-10 11:13:32 UTC (rev 18689) @@ -1,9 +1,9 @@ #!/bin/sh # This file is part of ke-recv # -# Copyright (C) 2008 Nokia Corporation. All rights reserved. +# Copyright (C) 2008-2009 Nokia Corporation. All rights reserved. # -# Contact: Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> +# Author: Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -19,5 +19,49 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA -echo "$0: I ain't no doing nothing" +/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 + +RC=0 +/sbin/lsmod | grep g_nada > /dev/null +if [ $? != 0 ]; then + /sbin/modprobe g_nada + RC=$? +fi + +if [ $RC != 0 ]; then + logger "$0: failed to install g_nada" + exit 1 +fi + exit 0 Modified: projects/haf/trunk/ke-recv/src/pcsuite-enable.sh =================================================================== --- projects/haf/trunk/ke-recv/src/pcsuite-enable.sh 2009-06-10 10:33:01 UTC (rev 18688) +++ projects/haf/trunk/ke-recv/src/pcsuite-enable.sh 2009-06-10 11:13:32 UTC (rev 18689) @@ -19,13 +19,13 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA -/sbin/lsmod | grep g_file_storage > /dev/null +/sbin/lsmod | grep g_nada > /dev/null if [ $? = 0 ]; then - logger "$0: removing g_file_storage" - initctl emit G_FILE_STORAGE_REMOVE - /sbin/rmmod g_file_storage + logger "$0: removing g_nada" + /sbin/rmmod g_nada fi +RC=0 /sbin/lsmod | grep g_nokia > /dev/null if [ $? != 0 ]; then /sbin/modprobe g_nokia @@ -34,15 +34,21 @@ if [ $RC != 0 ]; then logger "$0: failed to install g_nokia" + # put g_nada back + /sbin/modprobe g_nada + if [ $? != 0 ]; then + logger "$0: failed to install g_nada back" + fi exit 1 -else - # TODO: remove the sleep when the wait is in place - sleep 2 fi +# TODO: wait for device files +sleep 1 + initctl emit --no-wait G_NOKIA_READY -# TODO: wait for the devices +# TODO: wait for daemons +sleep 1 OBEXD_PID=`pidof obexd` if [ $? != 0 ]; then
- Previous message: [maemo-commits] r18688 - in projects/haf/trunk/hildon-thumbnail: . daemon
- Next message: [maemo-commits] r18690 - projects/haf/trunk/libosso/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]