/** * get_dr_connectors * * NOTE:Callers of this function are expected to free drc_list themselves * * @param of_path * @param drc_list * @param n_drcs * @returns 0 on success, !0 otherwise */ struct dr_connector * get_drc_info(const char *of_path) { struct dr_connector *list = NULL; struct of_list_prop *drc_names; struct drc_prop_grp prop_grp; char *full_path = NULL; int rc, n_drcs; full_path = of_to_full_path(of_path); if (full_path == NULL) goto done; for (list = all_drc_lists; list; list = list->all_next) { if (! strcmp(list->ofdt_path, of_path)) return list; } rc = get_drc_prop_grp(full_path, &prop_grp); if (rc) { say(DEBUG, "Could not find DRC property group in path: %s.\n", full_path); goto done; } drc_names = &prop_grp.drc_names; n_drcs = drc_names->n_entries; list = zalloc(n_drcs * sizeof(struct dr_connector)); if (list == NULL) goto done; /* XXX Unchecked rc */ rc = build_connectors_list(&prop_grp, n_drcs, list); snprintf(list->ofdt_path, DR_PATH_MAX, "%s", of_path); list->all_next = all_drc_lists; all_drc_lists = list; done: free_drc_props(&prop_grp); if (full_path) free(full_path); return list; }
/** * get_my_drc_index * * @param of_path * @param index * @returns 0 on success, !0 otherwise */ int get_my_drc_index(char *of_path, uint32_t *index) { char *full_path = NULL; int rc; full_path = of_to_full_path(of_path); if (full_path == NULL) return -1; rc = get_property(full_path, "ibm,my-drc-index", index, sizeof(*index)); free(full_path); return rc; }
/** * correlate_devspec * * @param sysfs_path * @param ofdt_path */ static int correlate_devspec(char *sysfs_path, char *ofdt_path, struct dr_node *node_list) { struct dr_node *node; char *full_of_path; int found; int rc; full_of_path = of_to_full_path(ofdt_path); for (node = node_list; node != NULL; node = node->next) { rc = devspec_check_node(node, sysfs_path, full_of_path, &found); if (rc) return rc; if (found) break; } free(full_of_path); return 0; }