Check for ir35221 link presence prior to bind/unbind
Check for /sys/bus/i2c/driversir35221/4-0070, 4-0071, 5-0070,
5-0071 on unbind.
Change-Id: I3c64682bcceffc6313625be1afadd38e090bcc63
Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com>
diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-unbind-bind.sh b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-unbind-bind.sh
index eea5070..5c100eb 100644
--- a/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-unbind-bind.sh
+++ b/meta-ibm/meta-witherspoon/recipes-phosphor/chassis/vrm-control/ir35221-unbind-bind.sh
@@ -3,7 +3,46 @@
# Script to run on witherspoon BMC to unbind/bind the ir35221
# driver's devices
-echo 4-0070 > /sys/bus/i2c/drivers/ir35221/$1
-echo 4-0071 > /sys/bus/i2c/drivers/ir35221/$1
-echo 5-0070 > /sys/bus/i2c/drivers/ir35221/$1
-echo 5-0071 > /sys/bus/i2c/drivers/ir35221/$1
+if [ "$1" = "unbind" ]
+then
+ if [ -e /sys/bus/i2c/drivers/ir35221/4-0070 ]
+ then
+ echo 4-0070 > /sys/bus/i2c/drivers/ir35221/$1
+ fi
+
+ if [ -e /sys/bus/i2c/drivers/ir35221/4-0071 ]
+ then
+ echo 4-0071 > /sys/bus/i2c/drivers/ir35221/$1
+ fi
+
+ if [ -e /sys/bus/i2c/drivers/ir35221/5-0070 ]
+ then
+ echo 5-0070 > /sys/bus/i2c/drivers/ir35221/$1
+ fi
+
+ if [ -e /sys/bus/i2c/drivers/ir35221/5-0071 ]
+ then
+ echo 5-0071 > /sys/bus/i2c/drivers/ir35221/$1
+ fi
+elif [ "$1" = "bind" ]
+then
+ if [ -e /sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/1e78a140.i2c-bus/i2c-4/4-0070 ]
+ then
+ echo 4-0070 > /sys/bus/i2c/drivers/ir35221/$1
+ fi
+
+ if [ -e /sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/1e78a140.i2c-bus/i2c-4/4-0071 ]
+ then
+ echo 4-0071 > /sys/bus/i2c/drivers/ir35221/$1
+ fi
+
+ if [ -e /sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/1e78a180.i2c-bus/i2c-5/5-0070 ]
+ then
+ echo 5-0070 > /sys/bus/i2c/drivers/ir35221/$1
+ fi
+
+ if [ -e /sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/1e78a180.i2c-bus/i2c-5/5-0071 ]
+ then
+ echo 5-0071 > /sys/bus/i2c/drivers/ir35221/$1
+ fi
+fi