Commit 276cc746 authored by Víctor Manuel Jáquez Leal's avatar Víctor Manuel Jáquez Leal Committed by Greg Kroah-Hartman
Browse files

staging: tidspbridge: remove DBC_ENSURE and DBC_REQUIRED



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: default avatarVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8900f00b
Loading
Loading
Loading
Loading
+1 −18
Original line number Diff line number Diff line
@@ -358,13 +358,6 @@ int bridge_chnl_create(struct chnl_mgr **channel_mgr,
	struct chnl_mgr *chnl_mgr_obj = NULL;
	u8 max_channels;

	/* Check DBC requirements: */
	DBC_REQUIRE(channel_mgr != NULL);
	DBC_REQUIRE(mgr_attrts != NULL);
	DBC_REQUIRE(mgr_attrts->max_channels > 0);
	DBC_REQUIRE(mgr_attrts->max_channels <= CHNL_MAXCHANNELS);
	DBC_REQUIRE(mgr_attrts->word_size != 0);

	/* Allocate channel manager object */
	chnl_mgr_obj = kzalloc(sizeof(struct chnl_mgr), GFP_KERNEL);
	if (chnl_mgr_obj) {
@@ -491,7 +484,6 @@ int bridge_chnl_flush_io(struct chnl_object *chnl_obj, u32 timeout)
			pchnl->state &= ~CHNL_STATECANCEL;
		}
	}
	DBC_ENSURE(status || list_empty(&pchnl->io_requests));
	return status;
}

@@ -705,8 +697,6 @@ int bridge_chnl_idle(struct chnl_object *chnl_obj, u32 timeout,
	struct chnl_mgr *chnl_mgr_obj;
	int status = 0;

	DBC_REQUIRE(chnl_obj);

	chnl_mode = chnl_obj->chnl_mode;
	chnl_mgr_obj = chnl_obj->chnl_mgr_obj;

@@ -736,10 +726,7 @@ int bridge_chnl_open(struct chnl_object **chnl,
	struct chnl_mgr *chnl_mgr_obj = hchnl_mgr;
	struct chnl_object *pchnl = NULL;
	struct sync_object *sync_event = NULL;
	/* Ensure DBC requirements: */
	DBC_REQUIRE(chnl != NULL);
	DBC_REQUIRE(pattrs != NULL);
	DBC_REQUIRE(hchnl_mgr != NULL);

	*chnl = NULL;

	/* Validate Args: */
@@ -906,8 +893,6 @@ static void free_chirp_list(struct list_head *chirp_list)
{
	struct chnl_irp *chirp, *tmp;

	DBC_REQUIRE(chirp_list != NULL);

	list_for_each_entry_safe(chirp, tmp, chirp_list, link) {
		list_del(&chirp->link);
		kfree(chirp);
@@ -924,8 +909,6 @@ static int search_free_channel(struct chnl_mgr *chnl_mgr_obj,
	int status = -ENOSR;
	u32 i;

	DBC_REQUIRE(chnl_mgr_obj);

	for (i = 0; i < chnl_mgr_obj->max_channels; i++) {
		if (chnl_mgr_obj->channels[i] == NULL) {
			status = 0;
+0 −3
Original line number Diff line number Diff line
@@ -256,9 +256,6 @@ static void bad_page_dump(u32 pa, struct page *pg)
void bridge_drv_entry(struct bridge_drv_interface **drv_intf,
		   const char *driver_file_name)
{

	DBC_REQUIRE(driver_file_name != NULL);

	if (strcmp(driver_file_name, "UMA") == 0)
		*drv_intf = &drv_interface_fxns;
	else
+0 −4
Original line number Diff line number Diff line
@@ -41,8 +41,6 @@ void uuid_uuid_to_string(struct dsp_uuid *uuid_obj, char *sz_uuid,
{
	s32 i;			/* return result from snprintf. */

	DBC_REQUIRE(uuid_obj && sz_uuid);

	i = snprintf(sz_uuid, size,
		     "%.8X_%.4X_%.4X_%.2X%.2X_%.2X%.2X%.2X%.2X%.2X%.2X",
		     uuid_obj->data1, uuid_obj->data2, uuid_obj->data3,
@@ -50,8 +48,6 @@ void uuid_uuid_to_string(struct dsp_uuid *uuid_obj, char *sz_uuid,
		     uuid_obj->data6[0], uuid_obj->data6[1],
		     uuid_obj->data6[2], uuid_obj->data6[3],
		     uuid_obj->data6[4], uuid_obj->data6[5]);

	DBC_ENSURE(i != -1);
}

static s32 uuid_hex_to_bin(char *buf, s32 len)
+0 −7
Original line number Diff line number Diff line
@@ -32,15 +32,8 @@
    if (!(exp)) \
	pr_err("%s, line %d: Assertion (" #exp ") failed.\n", \
	__FILE__, __LINE__)
#define DBC_REQUIRE DBC_ASSERT	/* Function Precondition. */
#define DBC_ENSURE  DBC_ASSERT	/* Function Postcondition. */

#else

#define DBC_ASSERT(exp) {}
#define DBC_REQUIRE(exp) {}
#define DBC_ENSURE(exp) {}

#endif /* DEBUG */

#endif /* DBC_ */
+0 −16
Original line number Diff line number Diff line
@@ -58,10 +58,6 @@ int chnl_create(struct chnl_mgr **channel_mgr,
	struct chnl_mgr *hchnl_mgr;
	struct chnl_mgr_ *chnl_mgr_obj = NULL;

	DBC_REQUIRE(refs > 0);
	DBC_REQUIRE(channel_mgr != NULL);
	DBC_REQUIRE(mgr_attrts != NULL);

	*channel_mgr = NULL;

	/* Validate args: */
@@ -99,8 +95,6 @@ int chnl_create(struct chnl_mgr **channel_mgr,
		}
	}

	DBC_ENSURE(status || chnl_mgr_obj);

	return status;
}

@@ -115,8 +109,6 @@ int chnl_destroy(struct chnl_mgr *hchnl_mgr)
	struct bridge_drv_interface *intf_fxns;
	int status;

	DBC_REQUIRE(refs > 0);

	if (chnl_mgr_obj) {
		intf_fxns = chnl_mgr_obj->intf_fxns;
		/* Let Bridge channel module destroy the chnl_mgr: */
@@ -135,11 +127,7 @@ int chnl_destroy(struct chnl_mgr *hchnl_mgr)
 */
void chnl_exit(void)
{
	DBC_REQUIRE(refs > 0);

	refs--;

	DBC_ENSURE(refs >= 0);
}

/*
@@ -151,12 +139,8 @@ bool chnl_init(void)
{
	bool ret = true;

	DBC_REQUIRE(refs >= 0);

	if (ret)
		refs++;

	DBC_ENSURE((ret && (refs > 0)) || (!ret && (refs >= 0)));

	return ret;
}
Loading