Thang Q. Nguyen | 267615d | 2022-11-24 14:48:51 +0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | DELAY_BEFORE_BIND=5000000 |
| 4 | # Each driver include driver name and driver path |
| 5 | declare -a DRIVER_NAMEs=("2-004f" |
| 6 | "2-004e" |
| 7 | ) |
| 8 | # Driver path should include / at the end |
| 9 | declare -a DRIVER_PATHs=("/sys/bus/i2c/drivers/smpro-core/" |
| 10 | "/sys/bus/i2c/drivers/smpro-core/" |
| 11 | ) |
| 12 | |
| 13 | # get length of an array |
| 14 | arraylength=${#DRIVER_NAMEs[@]} |
| 15 | |
| 16 | usleep $DELAY_BEFORE_BIND |
| 17 | # use for loop to read all values and indexes |
| 18 | for (( i=0; i<"${arraylength}"; i++ )); |
| 19 | do |
| 20 | bindFile="${DRIVER_PATHs[$i]}bind" |
| 21 | driverDir="${DRIVER_PATHs[$i]}${DRIVER_NAMEs[$i]}" |
| 22 | if [ -d "$driverDir" ]; then |
| 23 | echo "Driver ${DRIVER_NAMEs[$i]} is already bound." |
| 24 | continue; |
| 25 | fi |
| 26 | echo "${DRIVER_NAMEs[$i]}" > "$bindFile" |
| 27 | done |
| 28 | |
| 29 | exit 0 |