From 276cc746d58b73aa4e046745441b8cf56858f9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 7 Feb 2012 00:39:34 +0100 Subject: staging: tidspbridge: remove DBC_ENSURE and DBC_REQUIRED MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The kernel does not use a "Design by Contract" approach, and it is only activated in the module if CONFIG_TIDSPBRDIGE_DEBUG is enabled, so they are executed rarely. It is better to remove them: less code to maintain. Signed-off-by: Víctor Manuel Jáquez Leal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/tidspbridge/rmgr/dbdcd.c | 80 -------------------------------- 1 file changed, 80 deletions(-) (limited to 'drivers/staging/tidspbridge/rmgr/dbdcd.c') diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c index fda2402..792b443 100644 --- a/drivers/staging/tidspbridge/rmgr/dbdcd.c +++ b/drivers/staging/tidspbridge/rmgr/dbdcd.c @@ -85,8 +85,6 @@ int dcd_auto_register(struct dcd_manager *hdcd_mgr, { int status = 0; - DBC_REQUIRE(refs > 0); - if (hdcd_mgr) status = dcd_get_objects(hdcd_mgr, sz_coff_path, (dcd_registerfxn) dcd_register_object, @@ -107,8 +105,6 @@ int dcd_auto_unregister(struct dcd_manager *hdcd_mgr, { int status = 0; - DBC_REQUIRE(refs > 0); - if (hdcd_mgr) status = dcd_get_objects(hdcd_mgr, sz_coff_path, (dcd_registerfxn) dcd_register_object, @@ -131,9 +127,6 @@ int dcd_create_manager(char *sz_zl_dll_name, struct dcd_manager *dcd_mgr_obj = NULL; /* DCD Manager pointer */ int status = 0; - DBC_REQUIRE(refs >= 0); - DBC_REQUIRE(dcd_mgr); - status = cod_create(&cod_mgr, sz_zl_dll_name); if (status) goto func_end; @@ -156,9 +149,6 @@ int dcd_create_manager(char *sz_zl_dll_name, cod_delete(cod_mgr); } - DBC_ENSURE((!status) || - ((dcd_mgr_obj == NULL) && (status == -ENOMEM))); - func_end: return status; } @@ -173,8 +163,6 @@ int dcd_destroy_manager(struct dcd_manager *hdcd_mgr) struct dcd_manager *dcd_mgr_obj = hdcd_mgr; int status = -EFAULT; - DBC_REQUIRE(refs >= 0); - if (hdcd_mgr) { /* Delete the COD manager. */ cod_delete(dcd_mgr_obj->cod_mgr); @@ -205,10 +193,6 @@ int dcd_enumerate_object(s32 index, enum dsp_dcdobjtype obj_type, struct dcd_key_elem *dcd_key; int len; - DBC_REQUIRE(refs >= 0); - DBC_REQUIRE(index >= 0); - DBC_REQUIRE(uuid_obj != NULL); - if ((index != 0) && (enum_refs == 0)) { /* * If an enumeration is being performed on an index greater @@ -294,8 +278,6 @@ int dcd_enumerate_object(s32 index, enum dsp_dcdobjtype obj_type, } } - DBC_ENSURE(uuid_obj || (status == -EPERM)); - return status; } @@ -307,7 +289,6 @@ int dcd_enumerate_object(s32 index, enum dsp_dcdobjtype obj_type, void dcd_exit(void) { struct dcd_key_elem *rv, *rv_tmp; - DBC_REQUIRE(refs > 0); refs--; if (refs == 0) { @@ -319,7 +300,6 @@ void dcd_exit(void) } } - DBC_ENSURE(refs >= 0); } /* @@ -333,12 +313,6 @@ int dcd_get_dep_libs(struct dcd_manager *hdcd_mgr, { int status = 0; - DBC_REQUIRE(refs > 0); - DBC_REQUIRE(hdcd_mgr); - DBC_REQUIRE(uuid_obj != NULL); - DBC_REQUIRE(dep_lib_uuids != NULL); - DBC_REQUIRE(prstnt_dep_libs != NULL); - status = get_dep_lib_info(hdcd_mgr, uuid_obj, &num_libs, NULL, dep_lib_uuids, prstnt_dep_libs, phase); @@ -356,12 +330,6 @@ int dcd_get_num_dep_libs(struct dcd_manager *hdcd_mgr, { int status = 0; - DBC_REQUIRE(refs > 0); - DBC_REQUIRE(hdcd_mgr); - DBC_REQUIRE(num_libs != NULL); - DBC_REQUIRE(num_pers_libs != NULL); - DBC_REQUIRE(uuid_obj != NULL); - status = get_dep_lib_info(hdcd_mgr, uuid_obj, num_libs, num_pers_libs, NULL, NULL, phase); @@ -393,10 +361,6 @@ int dcd_get_object_def(struct dcd_manager *hdcd_mgr, u32 dw_key_len; /* Len of REG key. */ char sz_obj_type[MAX_INT2CHAR_LENGTH]; /* str. rep. of obj_type. */ - DBC_REQUIRE(refs > 0); - DBC_REQUIRE(obj_def != NULL); - DBC_REQUIRE(obj_uuid != NULL); - sz_uuid = kzalloc(MAXUUIDLEN, GFP_KERNEL); if (!sz_uuid) { status = -ENOMEM; @@ -553,7 +517,6 @@ int dcd_get_objects(struct dcd_manager *hdcd_mgr, struct dsp_uuid dsp_uuid_obj; s32 object_type; - DBC_REQUIRE(refs > 0); if (!hdcd_mgr) { status = -EFAULT; goto func_end; @@ -663,11 +626,6 @@ int dcd_get_library_name(struct dcd_manager *hdcd_mgr, int status = 0; struct dcd_key_elem *dcd_key = NULL; - DBC_REQUIRE(uuid_obj != NULL); - DBC_REQUIRE(str_lib_name != NULL); - DBC_REQUIRE(buff_size != NULL); - DBC_REQUIRE(hdcd_mgr); - dev_dbg(bridge, "%s: hdcd_mgr %p, uuid_obj %p, str_lib_name %p," " buff_size %p\n", __func__, hdcd_mgr, uuid_obj, str_lib_name, buff_size); @@ -790,8 +748,6 @@ bool dcd_init(void) bool init_cod; bool ret = true; - DBC_REQUIRE(refs >= 0); - if (refs == 0) { /* Initialize required modules. */ init_cod = cod_init(); @@ -809,8 +765,6 @@ bool dcd_init(void) if (ret) refs++; - DBC_ENSURE((ret && (refs > 0)) || (!ret && (refs == 0))); - return ret; } @@ -832,15 +786,6 @@ int dcd_register_object(struct dsp_uuid *uuid_obj, char sz_obj_type[MAX_INT2CHAR_LENGTH]; /* str. rep. of obj_type. */ struct dcd_key_elem *dcd_key = NULL; - DBC_REQUIRE(refs > 0); - DBC_REQUIRE(uuid_obj != NULL); - DBC_REQUIRE((obj_type == DSP_DCDNODETYPE) || - (obj_type == DSP_DCDPROCESSORTYPE) || - (obj_type == DSP_DCDLIBRARYTYPE) || - (obj_type == DSP_DCDCREATELIBTYPE) || - (obj_type == DSP_DCDEXECUTELIBTYPE) || - (obj_type == DSP_DCDDELETELIBTYPE)); - dev_dbg(bridge, "%s: object UUID %p, obj_type %d, szPathName %s\n", __func__, uuid_obj, obj_type, psz_path_name); @@ -987,15 +932,6 @@ int dcd_unregister_object(struct dsp_uuid *uuid_obj, { int status = 0; - DBC_REQUIRE(refs > 0); - DBC_REQUIRE(uuid_obj != NULL); - DBC_REQUIRE((obj_type == DSP_DCDNODETYPE) || - (obj_type == DSP_DCDPROCESSORTYPE) || - (obj_type == DSP_DCDLIBRARYTYPE) || - (obj_type == DSP_DCDCREATELIBTYPE) || - (obj_type == DSP_DCDEXECUTELIBTYPE) || - (obj_type == DSP_DCDDELETELIBTYPE)); - /* * When dcd_register_object is called with NULL as pathname, * it indicates an unregister object operation. @@ -1055,12 +991,6 @@ static int get_attrs_from_buf(char *psz_buf, u32 ul_buf_size, s32 entry_id; #endif - DBC_REQUIRE(psz_buf != NULL); - DBC_REQUIRE(ul_buf_size != 0); - DBC_REQUIRE((obj_type == DSP_DCDNODETYPE) - || (obj_type == DSP_DCDPROCESSORTYPE)); - DBC_REQUIRE(gen_obj != NULL); - switch (obj_type) { case DSP_DCDNODETYPE: /* @@ -1082,7 +1012,6 @@ static int get_attrs_from_buf(char *psz_buf, u32 ul_buf_size, token = strsep(&psz_cur, seps); /* ac_name */ - DBC_REQUIRE(token); token_len = strlen(token); if (token_len > DSP_MAXNAMELEN - 1) token_len = DSP_MAXNAMELEN - 1; @@ -1167,7 +1096,6 @@ static int get_attrs_from_buf(char *psz_buf, u32 ul_buf_size, token = strsep(&psz_cur, seps); /* char *str_create_phase_fxn */ - DBC_REQUIRE(token); token_len = strlen(token); gen_obj->obj_data.node_obj.str_create_phase_fxn = kzalloc(token_len + 1, GFP_KERNEL); @@ -1178,7 +1106,6 @@ static int get_attrs_from_buf(char *psz_buf, u32 ul_buf_size, token = strsep(&psz_cur, seps); /* char *str_execute_phase_fxn */ - DBC_REQUIRE(token); token_len = strlen(token); gen_obj->obj_data.node_obj.str_execute_phase_fxn = kzalloc(token_len + 1, GFP_KERNEL); @@ -1189,7 +1116,6 @@ static int get_attrs_from_buf(char *psz_buf, u32 ul_buf_size, token = strsep(&psz_cur, seps); /* char *str_delete_phase_fxn */ - DBC_REQUIRE(token); token_len = strlen(token); gen_obj->obj_data.node_obj.str_delete_phase_fxn = kzalloc(token_len + 1, GFP_KERNEL); @@ -1421,12 +1347,6 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr, u16 dep_libs = 0; int status = 0; - DBC_REQUIRE(refs > 0); - - DBC_REQUIRE(hdcd_mgr); - DBC_REQUIRE(num_libs != NULL); - DBC_REQUIRE(uuid_obj != NULL); - /* Initialize to 0 dependent libraries, if only counting number of * dependent libraries */ if (!get_uuids) { -- cgit v1.1 From 40e6336d1bdc10f072b6563dfb1255b5c4b039a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 7 Feb 2012 00:39:35 +0100 Subject: staging: tidspbridge: remove DBC_ASSERT macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This macro is only valid when CONFIG_TIDSPBRDIGE_DEBUG is enabled and it only prints a log message, it is not a real assertion mechanism like BUG_ON() or WARN_ON(). It is better to remove them: less code to maintain. Signed-off-by: Víctor Manuel Jáquez Leal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/tidspbridge/rmgr/dbdcd.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging/tidspbridge/rmgr/dbdcd.c') diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c index 792b443..18109fc 100644 --- a/drivers/staging/tidspbridge/rmgr/dbdcd.c +++ b/drivers/staging/tidspbridge/rmgr/dbdcd.c @@ -206,7 +206,6 @@ int dcd_enumerate_object(s32 index, enum dsp_dcdobjtype obj_type, * "_\0" + length of sz_obj_type string + terminating NULL. */ dw_key_len = strlen(DCD_REGKEY) + 1 + sizeof(sz_obj_type) + 1; - DBC_ASSERT(dw_key_len < DCD_MAXPATHLENGTH); /* Create proper REG key; concatenate DCD_REGKEY with * obj_type. */ @@ -375,7 +374,6 @@ int dcd_get_object_def(struct dcd_manager *hdcd_mgr, /* Pre-determine final key length. It's length of DCD_REGKEY + * "_\0" + length of sz_obj_type string + terminating NULL */ dw_key_len = strlen(DCD_REGKEY) + 1 + sizeof(sz_obj_type) + 1; - DBC_ASSERT(dw_key_len < DCD_MAXPATHLENGTH); /* Create proper REG key; concatenate DCD_REGKEY with obj_type. */ strncpy(sz_reg_key, DCD_REGKEY, strlen(DCD_REGKEY) + 1); @@ -434,7 +432,6 @@ int dcd_get_object_def(struct dcd_manager *hdcd_mgr, } /* Ensure sz_uuid + 1 is not greater than sizeof sz_sect_name. */ - DBC_ASSERT((strlen(sz_uuid) + 1) < sizeof(sz_sect_name)); /* Create section name based on node UUID. A period is * pre-pended to the UUID string to form the section name. @@ -635,7 +632,6 @@ int dcd_get_library_name(struct dcd_manager *hdcd_mgr, * "_\0" + length of sz_obj_type string + terminating NULL. */ dw_key_len = strlen(DCD_REGKEY) + 1 + sizeof(sz_obj_type) + 1; - DBC_ASSERT(dw_key_len < DCD_MAXPATHLENGTH); /* Create proper REG key; concatenate DCD_REGKEY with obj_type. */ strncpy(sz_reg_key, DCD_REGKEY, strlen(DCD_REGKEY) + 1); @@ -663,7 +659,6 @@ int dcd_get_library_name(struct dcd_manager *hdcd_mgr, break; default: status = -EINVAL; - DBC_ASSERT(false); } if (!status) { if ((strlen(sz_reg_key) + strlen(sz_obj_type)) < @@ -794,7 +789,6 @@ int dcd_register_object(struct dsp_uuid *uuid_obj, * "_\0" + length of sz_obj_type string + terminating NULL. */ dw_key_len = strlen(DCD_REGKEY) + 1 + sizeof(sz_obj_type) + 1; - DBC_ASSERT(dw_key_len < DCD_MAXPATHLENGTH); /* Create proper REG key; concatenate DCD_REGKEY with obj_type. */ strncpy(sz_reg_key, DCD_REGKEY, strlen(DCD_REGKEY) + 1); -- cgit v1.1 From f7c908ef871fcb319096caa7e839091b1feabd24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 7 Feb 2012 00:39:36 +0100 Subject: staging: tidspbridge: remove dbc.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All the macros in dbc.h are removed now so this patch removes it completely. Signed-off-by: Víctor Manuel Jáquez Leal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/tidspbridge/rmgr/dbdcd.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging/tidspbridge/rmgr/dbdcd.c') diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c index 18109fc..8378b7b 100644 --- a/drivers/staging/tidspbridge/rmgr/dbdcd.c +++ b/drivers/staging/tidspbridge/rmgr/dbdcd.c @@ -29,8 +29,6 @@ /* ----------------------------------- DSP/BIOS Bridge */ #include -/* ----------------------------------- Trace & Debug */ -#include /* ----------------------------------- Platform Manager */ #include -- cgit v1.1 From d4040fadc0b8bc109268cf278bab6f2132e7ab0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Fri, 9 Mar 2012 01:03:37 +0100 Subject: staging: tidspbridge: remove cod_init() and cod_exit() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cod module has a cod_init() and a cod_exit() whose only purpose is to keep a reference counting which is not used at all. This patch removes these functions and the reference count variable. There is no functional changes. Signed-off-by: Víctor Manuel Jáquez Leal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/tidspbridge/rmgr/dbdcd.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'drivers/staging/tidspbridge/rmgr/dbdcd.c') diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c index 8378b7b..12a1d34 100644 --- a/drivers/staging/tidspbridge/rmgr/dbdcd.c +++ b/drivers/staging/tidspbridge/rmgr/dbdcd.c @@ -289,7 +289,6 @@ void dcd_exit(void) refs--; if (refs == 0) { - cod_exit(); list_for_each_entry_safe(rv, rv_tmp, ®_key_list, link) { list_del(&rv->link); kfree(rv->path); @@ -738,22 +737,10 @@ int dcd_get_library_name(struct dcd_manager *hdcd_mgr, */ bool dcd_init(void) { - bool init_cod; bool ret = true; - if (refs == 0) { - /* Initialize required modules. */ - init_cod = cod_init(); - - if (!init_cod) { - ret = false; - /* Exit initialized modules. */ - if (init_cod) - cod_exit(); - } - + if (refs == 0) INIT_LIST_HEAD(®_key_list); - } if (ret) refs++; -- cgit v1.1