static int dpbp_exit(void) { int err; err = dpbp_open(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_attr.id, &dflt_dpbp->dpbp_handle); if (err < 0) { printf("dpbp_open() failed: %d\n", err); goto err; } err = dpbp_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); if (err < 0) { printf("dpbp_destroy() failed: %d\n", err); goto err; } #ifdef DEBUG printf("Exit: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id); #endif if (dflt_dpbp) free(dflt_dpbp); return 0; err: return err; }
static int dpbp_init(void) { int err; struct dpbp_attr dpbp_attr; struct dpbp_cfg dpbp_cfg; dflt_dpbp = (struct fsl_dpbp_obj *)malloc(sizeof(struct fsl_dpbp_obj)); if (!dflt_dpbp) { printf("No memory: malloc() failed\n"); err = -ENOMEM; goto err_malloc; } dpbp_cfg.options = 512; err = dpbp_create(dflt_mc_io, MC_CMD_NO_FLAGS, &dpbp_cfg, &dflt_dpbp->dpbp_handle); if (err < 0) { err = -ENODEV; printf("dpbp_create() failed: %d\n", err); goto err_create; } memset(&dpbp_attr, 0, sizeof(struct dpbp_attr)); err = dpbp_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle, &dpbp_attr); if (err < 0) { printf("dpbp_get_attributes() failed: %d\n", err); goto err_get_attr; } dflt_dpbp->dpbp_attr.id = dpbp_attr.id; #ifdef DEBUG printf("Init: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id); #endif err = dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); if (err < 0) { printf("dpbp_close() failed: %d\n", err); goto err_close; } return 0; err_close: free(dflt_dpbp); err_get_attr: dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); dpbp_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); err_create: err_malloc: return err; }
static int dpbp_init(void) { int err; struct dpbp_attr dpbp_attr; struct dpbp_cfg dpbp_cfg; uint16_t major_ver, minor_ver; dflt_dpbp = (struct fsl_dpbp_obj *)calloc( sizeof(struct fsl_dpbp_obj), 1); if (!dflt_dpbp) { printf("No memory: calloc() failed\n"); err = -ENOMEM; goto err_calloc; } dpbp_cfg.options = 512; err = dpbp_create(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS, &dpbp_cfg, &dflt_dpbp->dpbp_id); if (err < 0) { err = -ENODEV; printf("dpbp_create() failed: %d\n", err); goto err_create; } err = dpbp_get_api_version(dflt_mc_io, 0, &major_ver, &minor_ver); if (err < 0) { printf("dpbp_get_api_version() failed: %d\n", err); goto err_get_api_ver; } if (major_ver < DPBP_VER_MAJOR || (major_ver == DPBP_VER_MAJOR && minor_ver < DPBP_VER_MINOR)) { printf("DPBP version mismatch found %u.%u,", major_ver, minor_ver); printf("supported version is %u.%u\n", DPBP_VER_MAJOR, DPBP_VER_MINOR); } err = dpbp_open(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_id, &dflt_dpbp->dpbp_handle); if (err) { printf("dpbp_open() failed\n"); goto err_open; } memset(&dpbp_attr, 0, sizeof(struct dpbp_attr)); err = dpbp_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle, &dpbp_attr); if (err < 0) { printf("dpbp_get_attributes() failed: %d\n", err); goto err_get_attr; } if (dflt_dpbp->dpbp_id != dpbp_attr.id) { printf("dpbp object id and attribute id are not same\n"); goto err_attr_not_same; } #ifdef DEBUG printf("Init: DPBP id=0x%x\n", dflt_dpbp->dpbp_attr.id); #endif err = dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); if (err < 0) { printf("dpbp_close() failed: %d\n", err); goto err_close; } return 0; err_get_attr: err_attr_not_same: dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); dpbp_destroy(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_id); err_get_api_ver: err_close: err_open: err_create: free(dflt_dpbp); err_calloc: return err; }
static int dpbp_init(void) { int err; struct dpbp_attr dpbp_attr; struct dpbp_cfg dpbp_cfg; dflt_dpbp = (struct fsl_dpbp_obj *)malloc(sizeof(struct fsl_dpbp_obj)); if (!dflt_dpbp) { printf("No memory: malloc() failed\n"); err = -ENOMEM; goto err_malloc; } dpbp_cfg.options = 512; err = dpbp_create(dflt_mc_io, MC_CMD_NO_FLAGS, &dpbp_cfg, &dflt_dpbp->dpbp_handle); if (err < 0) { err = -ENODEV; printf("dpbp_create() failed: %d\n", err); goto err_create; } memset(&dpbp_attr, 0, sizeof(struct dpbp_attr)); err = dpbp_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle, &dpbp_attr); if (err < 0) { printf("dpbp_get_attributes() failed: %d\n", err); goto err_get_attr; } if ((dpbp_attr.version.major != DPBP_VER_MAJOR) || (dpbp_attr.version.minor != DPBP_VER_MINOR)) { printf("DPBP version mismatch found %u.%u,", dpbp_attr.version.major, dpbp_attr.version.minor); printf("supported version is %u.%u\n", DPBP_VER_MAJOR, DPBP_VER_MINOR); } dflt_dpbp->dpbp_attr.id = dpbp_attr.id; #ifdef DEBUG printf("Init: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id); #endif err = dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); if (err < 0) { printf("dpbp_close() failed: %d\n", err); goto err_close; } return 0; err_close: free(dflt_dpbp); err_get_attr: dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); dpbp_destroy(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); err_create: err_malloc: return err; }