Extract the "does the target of this TIC already exist?" check from
ccwchain_handle_tic(), so that it's easier to refactor that function
into one that cp_init() is able to use.
Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <
20190606202831.44135-3-farman@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
 
        struct ccwchain *chain;
        int len, ret;
 
-       /* May transfer to an existing chain. */
-       if (tic_target_chain_exists(tic, cp))
-               return 0;
-
        /* Get chain length. */
        len = ccwchain_calc_length(tic->cda, cp);
        if (len < 0)
                if (!ccw_is_tic(tic))
                        continue;
 
+               /* May transfer to an existing chain. */
+               if (tic_target_chain_exists(tic, cp))
+                       continue;
+
                ret = ccwchain_handle_tic(tic, cp);
                if (ret)
                        return ret;