]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: dgap: Simplify dgap_find_config
authorMark Hounschell <markh@compro.net>
Wed, 28 May 2014 20:17:55 +0000 (16:17 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 May 2014 21:35:09 +0000 (14:35 -0700)
Simplify ugly dgap_find_config function

Signed-off-by: Mark Hounschell <markh@compro.net>
Tested-by: Mark Hounschell <markh@compro.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/dgap/dgap.c

index 7912d9865e22c8f5a9fa61da5265aa463273147b..09e247855c9107e194888ea9611c72b22b029eae 100644 (file)
@@ -7354,51 +7354,53 @@ static struct cnode *dgap_find_config(int type, int bus, int slot)
                prev = p;
                p = p->next;
 
-               if (p->type == BNODE) {
+               if (p->type != BNODE)
+                       continue;
 
-                       if (p->u.board.type == type) {
+               if (p->u.board.type != type)
+                       continue;
 
-                               if (p->u.board.v_pcibus &&
-                                   p->u.board.pcibus != bus)
-                                       continue;
-                               if (p->u.board.v_pcislot &&
-                                   p->u.board.pcislot != slot)
-                                       continue;
+               if (p->u.board.v_pcibus &&
+                   p->u.board.pcibus != bus)
+                       continue;
 
-                               found = p;
-                               /*
-                                * Keep walking thru the list till we
-                                * find the next board.
-                                */
-                               while (p->next) {
-                                       prev2 = p;
-                                       p = p->next;
-                                       if (p->type == BNODE) {
-
-                                               /*
-                                                * Mark the end of our 1 board
-                                                * chain of configs.
-                                                */
-                                               prev2->next = NULL;
-
-                                               /*
-                                                * Link the "next" board to the
-                                                * previous board, effectively
-                                                * "unlinking" our board from
-                                                * the main config.
-                                                */
-                                               prev->next = p;
-
-                                               return found;
-                                       }
-                               }
-                               /*
-                                * It must be the last board in the list.
-                                */
-                               prev->next = NULL;
-                               return found;
-                       }
+               if (p->u.board.v_pcislot &&
+                   p->u.board.pcislot != slot)
+                       continue;
+
+               found = p;
+               /*
+                * Keep walking thru the list till we
+                * find the next board.
+                */
+               while (p->next) {
+                       prev2 = p;
+                       p = p->next;
+
+                       if (p->type != BNODE)
+                               continue;
+
+                       /*
+                        * Mark the end of our 1 board
+                        * chain of configs.
+                        */
+                       prev2->next = NULL;
+
+                       /*
+                        * Link the "next" board to the
+                        * previous board, effectively
+                        * "unlinking" our board from
+                        * the main config.
+                        */
+                       prev->next = p;
+
+                       return found;
                }
+               /*
+                * It must be the last board in the list.
+                */
+               prev->next = NULL;
+               return found;
        }
        return NULL;
 }