summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-08-03 10:09:17 +0300
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-08-03 10:09:17 +0300
commit1504e9c9d305e2ad24f0bba57e37eb18a18ddc4e (patch)
treeafd04eb8978e3db42808be7cb62998b3eabeb16c
parent98c73936ffe9ad7d308b619f9ec985555493d095 (diff)
load_nandsim.sh: use less bashisms + cleanups
Use posix shell constructs in the "if" statements. Additionally, use quotes everywhere for variables. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
-rwxr-xr-xload_nandsim.sh50
1 files changed, 25 insertions, 25 deletions
diff --git a/load_nandsim.sh b/load_nandsim.sh
index 18f788e..de1ac74 100755
--- a/load_nandsim.sh
+++ b/load_nandsim.sh
@@ -12,7 +12,7 @@ if grep -q "NAND simulator" /proc/mtd; then
exit 1
fi
-if (( $# < 1 )); then
+if [ "$#" -lt "1" ]; then
echo "Load NAND simulator to simulate flash of a specified size."
echo ""
echo "Usage: ./load_nandsim.sh <size in MiB> <eraseblock size in KiB>"
@@ -54,23 +54,23 @@ if (( $# < 1 )); then
exit 1
fi
-SZ=$1
-EBSZ=$2
-PGSZ=$3
-if [[ $# == '1' ]]; then
- EBSZ=16
- PGSZ=512
-elif [[ $# == '2' ]]; then
- PGSZ=512
+SZ="$1"
+EBSZ="$2"
+PGSZ="$3"
+if [ "$#" = "1" ]; then
+ EBSZ="16"
+ PGSZ="512"
+elif [ "$#" = "2" ]; then
+ PGSZ="512"
fi
-if (( $PGSZ == 512 && $EBSZ != 16 )); then
+if [ "$PGSZ" -eq 512 ] && [ "$EBSZ" -ne "16" ]; then
echo "Error: only 16KiB eraseblocks are possible in case of 512 bytes page"
exit 1
fi
-if (( $PGSZ == 512 )); then
- case $SZ in
+if [ "$PGSZ" -eq "512" ]; then
+ case "$SZ" in
16) modprobe nandsim first_id_byte=0x20 second_id_byte=0x33 ;;
32) modprobe nandsim first_id_byte=0x20 second_id_byte=0x35 ;;
64) modprobe nandsim first_id_byte=0x20 second_id_byte=0x36 ;;
@@ -79,22 +79,22 @@ if (( $PGSZ == 512 )); then
*) echo "Flash size ${SZ}MiB is not supported, try 16, 32, 64 or 256"
exit 1 ;;
esac
-elif (( $PGSZ == 2048 )); then
- case $EBSZ in
- 64) FOURTH=0x05 ;;
- 128) FOURTH=0x15 ;;
- 256) FOURTH=0x25 ;;
- 512) FOURTH=0x35 ;;
+elif [ "$PGSZ" -eq "2048" ]; then
+ case "$EBSZ" in
+ 64) FOURTH="0x05" ;;
+ 128) FOURTH="0x15" ;;
+ 256) FOURTH="0x25" ;;
+ 512) FOURTH="0x35" ;;
*) echo "Eraseblock ${EBSZ}KiB is not supported"
exit 1
esac
- case $SZ in
- 64) modprobe nandsim first_id_byte=0x20 second_id_byte=0xa2 third_id_byte=0x00 fourth_id_byte=$FOURTH ;;
- 128) modprobe nandsim first_id_byte=0xec second_id_byte=0xa1 third_id_byte=0x00 fourth_id_byte=$FOURTH ;;
- 256) modprobe nandsim first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte=$FOURTH ;;
- 512) modprobe nandsim first_id_byte=0x20 second_id_byte=0xac third_id_byte=0x00 fourth_id_byte=$FOURTH ;;
- 1024) modprobe nandsim first_id_byte=0xec second_id_byte=0xd3 third_id_byte=0x51 fourth_id_byte=$FOURTH ;;
+ case "$SZ" in
+ 64) modprobe nandsim first_id_byte=0x20 second_id_byte=0xa2 third_id_byte=0x00 fourth_id_byte="$FOURTH" ;;
+ 128) modprobe nandsim first_id_byte=0xec second_id_byte=0xa1 third_id_byte=0x00 fourth_id_byte="$FOURTH" ;;
+ 256) modprobe nandsim first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte="$FOURTH" ;;
+ 512) modprobe nandsim first_id_byte=0x20 second_id_byte=0xac third_id_byte=0x00 fourth_id_byte="$FOURTH" ;;
+ 1024) modprobe nandsim first_id_byte=0xec second_id_byte=0xd3 third_id_byte=0x51 fourth_id_byte="$FOURTH" ;;
*) echo "Unable to emulate ${SZ}MiB flash with ${EBSZ}KiB eraseblock"
exit 1
esac
@@ -103,7 +103,7 @@ else
exit 1
fi
-if (( $? != 0 )); then
+if [ "$?" != "0" ]; then
echo "Error: cannot load nandsim"
exit 1
fi