Delete functional BMC id if ACTIVE_BMC_MAX_ALLOWED is less than 2

The current logic in ItemUpdater::freeSpace() will try to find the
non-functional BMC ids and remove extra ones as long as the active BMC
images is greater than ACTIVE_BMC_MAX_ALLOWED.

For static layout systems with only one BMC flash chip, the above logic
will cause an issue that the "old" BMC id not deleted during code
update, because the "old" BMC id is the functional one.

This commit changes the above logic, that if ACTIVE_BMC_MAX_ALLOWED is
less than 2 (e.g. 1), delete the functional BMC id as well, because
there really is only one BMC after all.

Partly resolves openbmc/phosphor-bmc-code-mgmt#2

Tested: Verify that the "old" BMC id is deleted during code update, if
        ACTIVE_BMC_MAX_ALLOWED is configured to 1, on Romulus.

Change-Id: I6f21b4269dd78d71f7e9181bb913c49b575321d1
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index 014757d..6d90579 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -283,7 +283,7 @@
     auto it = versions.find(entryId);
     if (it != versions.end())
     {
-        if (it->second->isFunctional())
+        if (it->second->isFunctional() && ACTIVE_BMC_MAX_ALLOWED > 1)
         {
             log<level::ERR>("Error: Version is currently running on the BMC. "
                             "Unable to remove.",
@@ -599,7 +599,10 @@
             count++;
             // Don't put the functional version on the queue since we can't
             // remove the "running" BMC version.
-            if (versions.find(iter.second->versionId)->second->isFunctional())
+            // If ACTIVE_BMC_MAX_ALLOWED <= 1, there is only one active BMC,
+            // so remove functional version as well.
+            if (versions.find(iter.second->versionId)->second->isFunctional() &&
+                ACTIVE_BMC_MAX_ALLOWED > 1)
             {
                 continue;
             }