blob: d41901968a2d71caa7dd9f52be8f8e3e7ac0d038 [file] [log] [blame]
Thang Q. Nguyen267615d2022-11-24 14:48:51 +07001#!/bin/bash
2
3DELAY_BEFORE_BIND=5000000
4# Each driver include driver name and driver path
5declare -a DRIVER_NAMEs=("2-004f"
6 "2-004e"
7 )
8# Driver path should include / at the end
9declare -a DRIVER_PATHs=("/sys/bus/i2c/drivers/smpro-core/"
10 "/sys/bus/i2c/drivers/smpro-core/"
11 )
12
13# get length of an array
14arraylength=${#DRIVER_NAMEs[@]}
15
16usleep $DELAY_BEFORE_BIND
17# use for loop to read all values and indexes
18for (( i=0; i<"${arraylength}"; i++ ));
19do
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"
27done
28
29exit 0