From 4f07db9e92ba13294cd9c163d8a5071551449be0 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Wed, 21 Jul 2010 15:56:17 +0000 Subject: xpp_fxloader: replace a sleep with a sleep loop For newer kernels there's no need to sleep at all. For Centos5 systems there seems to be a need for a large sleep for firmware load at boot time. So let's make it a loop. Merged revisions 8951 via svnmerge from http://svn.digium.com/svn/dahdi/tools/trunk git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/branches/2.3@8963 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- xpp/xpp_fxloader | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/xpp/xpp_fxloader b/xpp/xpp_fxloader index 943adcd..0287032 100644 --- a/xpp/xpp_fxloader +++ b/xpp/xpp_fxloader @@ -67,7 +67,7 @@ USB_PREFIX= FIRMWARE_DIR="${FIRMWARE_DIR:-/usr/share/dahdi}" ASTRIBANK_HEXLOAD=${ASTRIBANK_HEXLOAD:-/usr/sbin/astribank_hexload} ASTRIBANK_TOOL=${ASTRIBANK_TOOL:-/usr/sbin/astribank_tool} -XPP_UDEV_SLEEP_TIME="${XPP_UDEV_SLEEP_TIME:-1}" +XPP_UDEV_SLEEP_TIME="${XPP_UDEV_SLEEP_TIME:-5}" USB_FW="${USB_FW:-USB_FW.hex}" @@ -325,9 +325,18 @@ fi # On some systems (e.g. CentOS 5) we get the relevant udev event before the device # file is ready. Which is why we want the background process to wait a bit first. udev_delayed_load() { + sleep 0.2 # Make sure the new device is writable: - sleep "$XPP_UDEV_SLEEP_TIME" - if [ ! -w "$DEVICE" ]; then + usb_dev_writable=0 + for i in `seq $XPP_UDEV_SLEEP_TIME`; do + if [ -w "$DEVICE" ]; then + usb_dev_writable=1; + break; + fi + sleep 1 + done + if [ $usb_dev_writable != 1 ]; then + $LOGGER "Device $DEVICE not writable. Can't load firmware." return; fi -- cgit v1.2.3