xpp: waitfor_xpds: handle missing serial numbers

Fixes a regression since 949ea4ca9f
(2.7.0) - allows using an Astribank with no serial.

* Some of the olderst Astribanks don't have a serial number burned in
  them. Thus there is no serial attribute for the sysfs USB device node.

* waitfor_xpds identifies the Astribanks by their serial numbers.

* An lone Astribank without serial number would thus block waitfor_xpds
  (until timeout).

* Now we warn about them.

* We also try to handle it gracefully. As long as there's only one
  of thease, it would be counted as "NO-SERIAL".

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
This commit is contained in:
Oron Peled 2014-03-31 13:35:34 +03:00 committed by Tzafrir Cohen
parent ffe36c63e0
commit 794c8eb048
1 changed files with 24 additions and 9 deletions

View File

@ -41,18 +41,25 @@ ab_list() {
} }
ab_serial_nums() { ab_serial_nums() {
ab_list | \ for i in `ab_list`; do
sed 's,$,/serial,' | \ s=`cat "$i/serial" 2>/dev/null` || :
xargs grep -H '' 2>/dev/null | \ if [ "$s" = '' ]; then
sed 's,.*/serial:,,' | \ echo "NO-SERIAL"
sed 's/^$/NO-SERIAL/' | \ else
sort -u echo "$s"
fi
done | sort -u || :
} }
detected_serial_nums() { detected_serial_nums() {
cat /sys/bus/astribanks/devices/*/transport/serial 2> /dev/null | \ for i in /sys/bus/astribanks/devices/*/transport; do
sed 's/^$/NO-SERIAL/' | \ s=`cat "$i/serial" 2>/dev/null` || :
sort -u || : if [ "$s" = '' ]; then
echo "NO-SERIAL"
else
echo "$s"
fi
done | sort -u || :
} }
calc_union() { calc_union() {
@ -98,6 +105,14 @@ if ! astribank_is_starting; then
exit 0 exit 0
fi fi
# Sanity check
for i in `ab_list`; do
s=`cat "$i/serial" 2>/dev/null` || :
if [ "$s" = '' ]; then
echo >&2 "WARNING! Astribank without serial number: $i"
fi
done
serial_nums=`ab_serial_nums` serial_nums=`ab_serial_nums`
# Loop until detected (hopefully) all astribanks and they are initialized # Loop until detected (hopefully) all astribanks and they are initialized