PNOR: Check if the pnor mtd is already attached.

- In the pnor ubi attach function, check if the
  pnor is already attached to ubi, since a second
  attempt may fail.

Resolves openbmc/openbmc#2074

Change-Id: Ic07d56c5f656d4a236d85fd77acc9aef214a9c3b
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
index 19878d4..0cdf74e 100644
--- a/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
+++ b/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
@@ -28,6 +28,11 @@
   pnor="${pnormtd#mtd}"
   pnordev="/dev/mtd${pnor}"
 
+  if [ -d "/sys/class/ubi/ubi${pnor}" ]; then
+    # Already attached
+    return 0
+  fi
+
   ubiattach /dev/ubi_ctrl -m "${pnor}" -d "${pnor}"
   rc=$?
   if [ ${rc} -ne 0 ]; then