opened
ibm-genwqe
username_0
I did modify the code for N250SP. 
The code was restructured adding function so that the macros can be removed.
See Pull request
I also was working on one more patch to avoid a scenario where more than one card is installed  (e.g. Card 0 and 1) and card 0 was somehow removed after card reset. This did follow in a error since you do check a devive (/sys/class/cxl/card0/...) which is not there anymore. 

The patch i added but its not in the pull request was:
diff --git a/capi-flash-script.sh b/capi-flash-script.sh
index 489cbda..2deabe3 100755
--- a/capi-flash-script.sh
+++ b/capi-flash-script.sh
@@ -137,7 +137,18 @@ printf "${bold}%-7s %-30s %-29s %-20s %s${normal}\n" "#" "Card" "Flashed" "by" "
 # print card information and flash history
 i=0;
 while read d; do
-  p[$i]=$(cat /sys/class/cxl/card$i/device/subsystem_device)
+  # Go to list of Cards if Card is not given
+  if (($card == -1)); then
+    p[$i]=$(cat /sys/class/cxl/card$i/device/subsystem_device)
+  else
+    # Check only if given card is the index, skip all others
+    if (($card == $i)); then
+      p[$i]=$(cat /sys/class/cxl/card$i/device/subsystem_device)
+    else
+      printf "Search Card %s Skip %s Device: %s" "${card}" "${i}", "${d}"
+      continue
+    fi
+  fi
   # check for legacy device
   if [[ ${p[$i]:0:6} == "0x04af" ]]; then
     p[$i]=$(cat /sys/class/cxl/card$i/psl_revision | xargs printf "0x%.4X")
Pull Request
issue