]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
powerpc/pseries/hotplug-memory.c: Replace nested ifs by switch-case
authorLeonardo Bras <leonardo@linux.ibm.com>
Thu, 1 Aug 2019 22:52:51 +0000 (19:52 -0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 5 Aug 2019 08:53:04 +0000 (18:53 +1000)
I noticed these nested ifs can be easily replaced by switch-cases,
which can improve readability.

Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190801225251.17864-1-leonardo@linux.ibm.com
arch/powerpc/platforms/pseries/hotplug-memory.c

index 46d0d35b9ca4495d05102d86fd728365036a668a..8e700390f3d6c842b45ff619362fe03ffd565c27 100644 (file)
@@ -880,34 +880,44 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
 
        switch (hp_elog->action) {
        case PSERIES_HP_ELOG_ACTION_ADD:
-               if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) {
+               switch (hp_elog->id_type) {
+               case PSERIES_HP_ELOG_ID_DRC_COUNT:
                        count = hp_elog->_drc_u.drc_count;
                        rc = dlpar_memory_add_by_count(count);
-               } else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) {
+                       break;
+               case PSERIES_HP_ELOG_ID_DRC_INDEX:
                        drc_index = hp_elog->_drc_u.drc_index;
                        rc = dlpar_memory_add_by_index(drc_index);
-               } else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_IC) {
+                       break;
+               case PSERIES_HP_ELOG_ID_DRC_IC:
                        count = hp_elog->_drc_u.ic.count;
                        drc_index = hp_elog->_drc_u.ic.index;
                        rc = dlpar_memory_add_by_ic(count, drc_index);
-               } else {
+                       break;
+               default:
                        rc = -EINVAL;
+                       break;
                }
 
                break;
        case PSERIES_HP_ELOG_ACTION_REMOVE:
-               if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) {
+               switch (hp_elog->id_type) {
+               case PSERIES_HP_ELOG_ID_DRC_COUNT:
                        count = hp_elog->_drc_u.drc_count;
                        rc = dlpar_memory_remove_by_count(count);
-               } else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) {
+                       break;
+               case PSERIES_HP_ELOG_ID_DRC_INDEX:
                        drc_index = hp_elog->_drc_u.drc_index;
                        rc = dlpar_memory_remove_by_index(drc_index);
-               } else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_IC) {
+                       break;
+               case PSERIES_HP_ELOG_ID_DRC_IC:
                        count = hp_elog->_drc_u.ic.count;
                        drc_index = hp_elog->_drc_u.ic.index;
                        rc = dlpar_memory_remove_by_ic(count, drc_index);
-               } else {
+                       break;
+               default:
                        rc = -EINVAL;
+                       break;
                }
 
                break;