staging: tidspbridge: mgr_enum_node_info cleanup
authorIonut Nicu <ionut.nicu@gmail.com>
Fri, 5 Nov 2010 17:01:49 +0000 (17:01 +0000)
committerOmar Ramirez Luna <omar.ramirez@ti.com>
Sat, 5 Feb 2011 02:11:22 +0000 (20:11 -0600)
Reorganized mgr_enum_node_info code to increase its
readability.

Signed-off-by: Ionut Nicu <ionut.nicu@mindbit.ro>
Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
drivers/staging/tidspbridge/rmgr/mgr.c

index 2eab6a56ab223ef9b0831d931355fd9c6b46fb7e..16410a5a9b6f3306c8db46ce85ce94bed50d0cf8 100644 (file)
@@ -134,8 +134,7 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops *pndb_props,
                              u32 undb_props_size, u32 *pu_num_nodes)
 {
        int status = 0;
-       struct dsp_uuid node_uuid, temp_uuid;
-       u32 temp_index = 0;
+       struct dsp_uuid node_uuid;
        u32 node_index = 0;
        struct dcd_genericobj gen_obj;
        struct mgr_object *pmgr_obj = NULL;
@@ -149,24 +148,27 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops *pndb_props,
        *pu_num_nodes = 0;
        /* Get the Manager Object from the driver data */
        if (!drv_datap || !drv_datap->mgr_object) {
-               status = -ENODATA;
                pr_err("%s: Failed to retrieve the object handle\n", __func__);
-               goto func_cont;
-       } else {
-               pmgr_obj = drv_datap->mgr_object;
+               return -ENODATA;
        }
+       pmgr_obj = drv_datap->mgr_object;
 
        DBC_ASSERT(pmgr_obj);
        /* Forever loop till we hit failed or no more items in the
         * Enumeration. We will exit the loop other than 0; */
-       while (status == 0) {
-               status = dcd_enumerate_object(temp_index++, DSP_DCDNODETYPE,
-                                             &temp_uuid);
-               if (status == 0) {
-                       node_index++;
-                       if (node_id == (node_index - 1))
-                               node_uuid = temp_uuid;
-
+       while (!status) {
+               status = dcd_enumerate_object(node_index++, DSP_DCDNODETYPE,
+                               &node_uuid);
+               if (status)
+                       break;
+               *pu_num_nodes = node_index;
+               if (node_id == (node_index - 1)) {
+                       status = dcd_get_object_def(pmgr_obj->hdcd_mgr,
+                                       &node_uuid, DSP_DCDNODETYPE, &gen_obj);
+                       if (status)
+                               break;
+                       /* Get the Obj def */
+                       *pndb_props = gen_obj.obj_data.node_obj.ndb_props;
                }
        }
 
@@ -174,27 +176,6 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops *pndb_props,
        if (status > 0)
                status = 0;
 
-       if (!status) {
-               if (node_id > (node_index - 1)) {
-                       status = -EINVAL;
-               } else {
-                       status = dcd_get_object_def(pmgr_obj->hdcd_mgr,
-                                                   (struct dsp_uuid *)
-                                                   &node_uuid, DSP_DCDNODETYPE,
-                                                   &gen_obj);
-                       if (!status) {
-                               /* Get the Obj def */
-                               *pndb_props =
-                                   gen_obj.obj_data.node_obj.ndb_props;
-                               *pu_num_nodes = node_index;
-                       }
-               }
-       }
-
-func_cont:
-       DBC_ENSURE((!status && *pu_num_nodes > 0) ||
-                  (status && *pu_num_nodes == 0));
-
        return status;
 }