Skip to contentSkip to conversation

staging:ti dspbridge: Checkpatch errors cleanup series

PATCH In review Ernesto Ramos 5 participants 18 messages Jul 28, 2010 – Aug 3, 2010 Staging

lore
Share & tools
lore
#0 lore raw

cover staging:ti dspbridge: Checkpatch errors cleanup series

These patches are targetted to remove checkpatch errors within dspbridge driver.

Ernesto Ramos (5):
staging:ti dspbridge: remove unused typedef REG16 staging:ti dspbridge: remove unnecessary check for NULL pointer in
cmm.c
staging:ti dspbridge: remove function delete_strm_mgr staging:ti dspbridge: remove unnecessary volatile variables staging:ti dspbridge: replace simple_strtoul by strict_strtoul

 drivers/staging/tidspbridge/core/_tiomap.h    |    2 --
 drivers/staging/tidspbridge/core/tiomap3430.c |    8 ++++----
 drivers/staging/tidspbridge/dynload/tramp.c   |    4 ++--
 drivers/staging/tidspbridge/pmgr/cmm.c        |   15 ++++++---------
 drivers/staging/tidspbridge/rmgr/dbdcd.c      |    6 +++++-
 drivers/staging/tidspbridge/rmgr/strm.c       |   16 ++--------------
 6 files changed, 19 insertions(+), 32 deletions(-)
#1 lore raw

PATCH 1/5 staging:ti dspbridge: remove unused typedef REG16

Remove unused typedef REG16 in dspbridge.

---
 drivers/staging/tidspbridge/core/_tiomap.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/tidspbridge/core/_tiomap.h +0 -2
index b754e49..1c1f157 100644
@@ -295,8 +295,6 @@ static const struct bpwr_clk_t bpwr_clks[] = {
 #define LOW_LEVEL                       false
 
 /* Macro's */
-#define REG16(A)    (*(reg_uword16 *)(A))
-
 #define CLEAR_BIT(reg, mask)             (reg &= ~mask)
 #define SET_BIT(reg, mask)               (reg |= mask)
 
Signature · 1 line
1.5.4.5
#4 lore raw

PATCH 4/5 staging:ti dspbridge: remove unnecessary volatile variables

In reply to Ernesto Ramos

Remove unnecessary volatile variables; use accessor functions __raw_readl/__raw_writel instead when applicable.

---
 drivers/staging/tidspbridge/core/tiomap3430.c |    8 ++++----
 drivers/staging/tidspbridge/dynload/tramp.c   |    4 ++--
 drivers/staging/tidspbridge/pmgr/cmm.c        |    7 ++++---
 3 files changed, 10 insertions(+), 9 deletions(-)
drivers/staging/tidspbridge/core/tiomap3430.c +4 -4
index 08a2f5f..ae1f394 100644
@@ -404,7 +404,7 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
 		pr_err("%s: Illegal SM base\n", __func__);
 		status = -EPERM;
 	} else
-		*((volatile u32 *)dw_sync_addr) = 0xffffffff;
+		__raw_writel(0xffffffff, dw_sync_addr);
 
 	if (DSP_SUCCEEDED(status)) {
 		resources = dev_context->resources;
@@ -584,7 +584,7 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
 		dev_dbg(bridge, "Waiting for Sync @ 0x%x\n", dw_sync_addr);
 		dev_dbg(bridge, "DSP c_int00 Address =  0x%x\n", dsp_addr);
 		if (dsp_debug)
-			while (*((volatile u16 *)dw_sync_addr))
+			while (__raw_readw(dw_sync_addr))
 				;;
 
 		/* Wait for DSP to clear word in shared memory */
@@ -602,7 +602,7 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
 			/* Write the synchronization bit to indicate the
 			 * completion of OPP table update to DSP
 			 */
-			*((volatile u32 *)dw_sync_addr) = 0XCAFECAFE;
+			__raw_writel(0XCAFECAFE, dw_sync_addr);
 
 			/* update board state */
 			dev_context->dw_brd_state = BRD_RUNNING;
@@ -1852,7 +1852,7 @@ bool wait_for_start(struct bridge_dev_context *dev_context, u32 dw_sync_addr)
 	u16 timeout = TIHELEN_ACKTIMEOUT;
 
 	/*  Wait for response from board */
-	while (*((volatile u16 *)dw_sync_addr) && --timeout)
+	while (__raw_readw(dw_sync_addr) && --timeout)
 		udelay(10);
 
 	/*  If timed out: return false */
drivers/staging/tidspbridge/dynload/tramp.c +2 -2
index 81314d2..60d22ea 100644
@@ -86,8 +86,8 @@ static u8 priv_h2a(u8 value)
 static void priv_tramp_sym_gen_name(u32 value, char *dst)
 {
 	u32 i;
-	volatile char *prefix = TRAMP_SYM_PREFIX;
-	volatile char *dst_local = dst;
+	char *prefix = TRAMP_SYM_PREFIX;
+	char *dst_local = dst;
 	u8 tmp;
 
 	/*  Clear out the destination, including the ending NULL */
drivers/staging/tidspbridge/pmgr/cmm.c +4 -3
index 874ed64..b7cba1b 100644
@@ -1008,6 +1008,7 @@ void *cmm_xlator_alloc_buf(struct cmm_xlatorobject *xlator, void *va_buf,
 {
 	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
 	void *pbuf = NULL;
+	void *tmp_va_buff;
 	struct cmm_attrs attrs;
 
 	DBC_REQUIRE(refs > 0);
@@ -1019,16 +1020,16 @@ void *cmm_xlator_alloc_buf(struct cmm_xlatorobject *xlator, void *va_buf,
 
 	if (xlator_obj) {
 		attrs.ul_seg_id = xlator_obj->ul_seg_id;
-		*(volatile u32 *)va_buf = 0;
+		__raw_writel(0, va_buf);
 		/* Alloc SM */
 		pbuf =
 		    cmm_calloc_buf(xlator_obj->hcmm_mgr, pa_size, &attrs, NULL);
 		if (pbuf) {
 			/* convert to translator(node/strm) process Virtual
 			 * address */
-			*(volatile u32 **)va_buf =
-			    (u32 *) cmm_xlator_translate(xlator,
+			 tmp_va_buff = cmm_xlator_translate(xlator,
 							 pbuf, CMM_PA2VA);
+			__raw_writel((u32)tmp_va_buff, va_buf);
 		}
 	}
 	return pbuf;
Signature · 1 line
1.5.4.5
#2 lore raw

PATCH 2/5 staging:ti dspbridge: remove unnecessary check for NULL pointer in cmm.c

In reply to Ernesto Ramos

Remove unnecessary check for NULL pointer in cmm.c.

---
 drivers/staging/tidspbridge/pmgr/cmm.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/staging/tidspbridge/pmgr/cmm.c +2 -6
index 8e808d9..874ed64 100644
@@ -992,16 +992,12 @@ int cmm_xlator_create(struct cmm_xlatorobject **xlator,
 int cmm_xlator_delete(struct cmm_xlatorobject *xlator, bool force)
 {
 	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
-	int status = 0;
 
 	DBC_REQUIRE(refs > 0);
 
-	if (xlator_obj)
-		kfree(xlator_obj);
-	else
-		status = -EFAULT;
+	kfree(xlator_obj);
 
-	return status;
+	return 0;
 }
 
 /*
Signature · 1 line
1.5.4.5
#3 lore raw

PATCH 3/5 staging:ti dspbridge: remove function delete_strm_mgr

Remove function delete_strm_mgr in strm.c and
use kfree instead.

---
 drivers/staging/tidspbridge/rmgr/strm.c |   16 ++--------------
 1 files changed, 2 insertions(+), 14 deletions(-)
drivers/staging/tidspbridge/rmgr/strm.c +2 -14
index 73888e3..6c184c6 100644
@@ -90,7 +90,6 @@ static u32 refs;		/* module reference count */
 
 /*  ----------------------------------- Function Prototypes */
 static int delete_strm(struct strm_object *stream_obj);
-static void delete_strm_mgr(struct strm_mgr *strm_mgr_obj);
 
 /*
  *  ======== strm_allocate_buffer ========
@@ -232,7 +231,7 @@ int strm_create(struct strm_mgr **strm_man,
 	if (DSP_SUCCEEDED(status))
 		*strm_man = strm_mgr_obj;
 	else
-		delete_strm_mgr(strm_mgr_obj);
+		kfree(strm_mgr_obj);
 
 	DBC_ENSURE((DSP_SUCCEEDED(status) && *strm_man) ||
 				(DSP_FAILED(status) && *strm_man == NULL));
@@ -250,7 +249,7 @@ void strm_delete(struct strm_mgr *strm_mgr_obj)
 	DBC_REQUIRE(refs > 0);
 	DBC_REQUIRE(strm_mgr_obj);
 
-	delete_strm_mgr(strm_mgr_obj);
+	kfree(strm_mgr_obj);
 }
 
 /*
@@ -859,14 +858,3 @@ static int delete_strm(struct strm_object *stream_obj)
 	}
 	return status;
 }
-
-/*
- *  ======== delete_strm_mgr ========
- *  Purpose:
- *      Frees stream manager.
- */
-static void delete_strm_mgr(struct strm_mgr *strm_mgr_obj)
-{
-	if (strm_mgr_obj)
-		kfree(strm_mgr_obj);
-}
Signature · 1 line
1.5.4.5
#5 lore raw

PATCH 5/5 staging:ti dspbridge: replace simple_strtoul by strict_strtoul

In reply to Ernesto Ramos

Replace simple_strtoul by strict_strtoul in atoi function.

---
 drivers/staging/tidspbridge/rmgr/dbdcd.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/staging/tidspbridge/rmgr/dbdcd.c +5 -1
index cceceb9..b96aea7 100644
@@ -1012,6 +1012,8 @@ static s32 atoi(char *psz_buf)
 {
 	char *pch = psz_buf;
 	s32 base = 0;
+	unsigned long res;
+	int ret_val;
 
 	while (isspace(*pch))
 		pch++;
@@ -1023,7 +1025,9 @@ static s32 atoi(char *psz_buf)
 		base = 16;
 	}
 
-	return simple_strtoul(pch, NULL, base);
+	ret_val = strict_strtoul(pch, base, &res);
+
+	return ret_val ? : res;
 }
 
 /*
Signature · 1 line
1.5.4.5
#11 lore raw

Re: [PATCH 4/5] staging:ti dspbridge: remove unnecessary volatile variables

In reply to Ernesto Ramos

Ramos Falcon, Ernesto had written, on 07/28/2010 09:40 AM, the following:

Quoted 15 lines

Remove unnecessary volatile variables; use accessor functions __raw_readl/__raw_writel instead when applicable.

---
 drivers/staging/tidspbridge/core/tiomap3430.c |    8 ++++----
 drivers/staging/tidspbridge/dynload/tramp.c   |    4 ++--
 drivers/staging/tidspbridge/pmgr/cmm.c        |    7 ++++---
 3 files changed, 10 insertions(+), 9 deletions(-)
drivers/staging/tidspbridge/core/tiomap3430.c +0 -0
index 08a2f5f..ae1f394 100644

drivers/staging/tidspbridge/core/tiomap3430.c static int bridge_brd_start(struct bridge_dev_context *dev_ctxt, · line 407

Quoted 5 lines
drivers/staging/tidspbridge/core/tiomap3430.c +1 -1
@@ -404,7 +404,7 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
 		pr_err("%s: Illegal SM base\n", __func__);
 		status = -EPERM;
 	} else
-		*((volatile u32 *)dw_sync_addr) = 0xffffffff;
+		__raw_writel(0xffffffff, dw_sync_addr);

curious question: any reason not to use writel instead of __raw_writel?

drivers/staging/tidspbridge/core/tiomap3430.c static int bridge_brd_start(struct bridge_dev_context *dev_ctxt, · line 588

Quoted 10 lines
drivers/staging/tidspbridge/core/tiomap3430.c +1 -1
 	if (DSP_SUCCEEDED(status)) {
 		resources = dev_context->resources;
@@ -584,7 +584,7 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
 		dev_dbg(bridge, "Waiting for Sync @ 0x%x\n", dw_sync_addr);
 		dev_dbg(bridge, "DSP c_int00 Address =  0x%x\n", dsp_addr);
 		if (dsp_debug)
-			while (*((volatile u16 *)dw_sync_addr))
+			while (__raw_readw(dw_sync_addr))
 				;;

may be for a later on patch -> we seem to have a potential infinite loop here..

Quoted 54 lines
drivers/staging/tidspbridge/core/tiomap3430.c +2 -2
 		/* Wait for DSP to clear word in shared memory */
@@ -602,7 +602,7 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
 			/* Write the synchronization bit to indicate the
 			 * completion of OPP table update to DSP
 			 */
-			*((volatile u32 *)dw_sync_addr) = 0XCAFECAFE;
+			__raw_writel(0XCAFECAFE, dw_sync_addr);
 
 			/* update board state */
 			dev_context->dw_brd_state = BRD_RUNNING;
@@ -1852,7 +1852,7 @@ bool wait_for_start(struct bridge_dev_context *dev_context, u32 dw_sync_addr)
 	u16 timeout = TIHELEN_ACKTIMEOUT;
 
 	/*  Wait for response from board */
-	while (*((volatile u16 *)dw_sync_addr) && --timeout)
+	while (__raw_readw(dw_sync_addr) && --timeout)
 		udelay(10);
 
 	/*  If timed out: return false */
drivers/staging/tidspbridge/dynload/tramp.c +2 -2
index 81314d2..60d22ea 100644
@@ -86,8 +86,8 @@ static u8 priv_h2a(u8 value)
 static void priv_tramp_sym_gen_name(u32 value, char *dst)
 {
 	u32 i;
-	volatile char *prefix = TRAMP_SYM_PREFIX;
-	volatile char *dst_local = dst;
+	char *prefix = TRAMP_SYM_PREFIX;
+	char *dst_local = dst;
 	u8 tmp;
 
 	/*  Clear out the destination, including the ending NULL */
drivers/staging/tidspbridge/pmgr/cmm.c +2 -1
index 874ed64..b7cba1b 100644
@@ -1008,6 +1008,7 @@ void *cmm_xlator_alloc_buf(struct cmm_xlatorobject *xlator, void *va_buf,
 {
 	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
 	void *pbuf = NULL;
+	void *tmp_va_buff;
 	struct cmm_attrs attrs;
 
 	DBC_REQUIRE(refs > 0);
@@ -1019,16 +1020,16 @@ void *cmm_xlator_alloc_buf(struct cmm_xlatorobject *xlator, void *va_buf,
 
 	if (xlator_obj) {
 		attrs.ul_seg_id = xlator_obj->ul_seg_id;
-		*(volatile u32 *)va_buf = 0;
+		__raw_writel(0, va_buf);
 		/* Alloc SM */

drivers/staging/tidspbridge/pmgr/cmm.c void *cmm_xlator_alloc_buf(struct cmm_xlatorobject *xlator, void *va_buf, · line 1032

Quoted 10 lines
drivers/staging/tidspbridge/pmgr/cmm.c +2 -2
 		pbuf =
 		    cmm_calloc_buf(xlator_obj->hcmm_mgr, pa_size, &attrs, NULL);
 		if (pbuf) {
 			/* convert to translator(node/strm) process Virtual
 			 * address */
-			*(volatile u32 **)va_buf =
-			    (u32 *) cmm_xlator_translate(xlator,
+			 tmp_va_buff = cmm_xlator_translate(xlator,
 							 pbuf, CMM_PA2VA);
+			__raw_writel((u32)tmp_va_buff, va_buf);

a) is the u32 cast of tmp_va_buff really necessary?
b) tmp_va_buff is used only in this branch, why not reduce the scope of the variable to just to this if branch or an optional way could be:

drivers/staging/tidspbridge/pmgr/cmm.c +3 -4
@@ -1022,18 +1022,17 @@ void *cmm_xlator_alloc_buf(struct cmm_xlatorobject *xlator, void *va_buf,
 	DBC_REQUIRE(xlator_obj->ul_seg_id > 0);
 
 	if (xlator_obj) {
+		void *t_buf = 0;
 		attrs.ul_seg_id = xlator_obj->ul_seg_id;
-		*(volatile u32 *)va_buf = 0;
 		/* Alloc SM */
 		pbuf =
 		    cmm_calloc_buf(xlator_obj->hcmm_mgr, pa_size, &attrs, NULL);
 		if (pbuf) {
 			/* convert to translator(node/strm) process Virtual
 			 * address */
-			*(volatile u32 **)va_buf =
-			    (u32 *) cmm_xlator_translate(xlator,
-							 pbuf, CMM_PA2VA);
+			t_buf = cmm_xlator_translate(xlator, pbuf, CMM_PA2VA);
 		}
+		writel(t_buf, va_buf);
 	}
 	return pbuf;
 }
Quoted 3 lines
drivers/staging/tidspbridge/pmgr/cmm.c +0 -0
 		}
 	}
 	return pbuf;
Signature · 2 lines
Regards,
Nishanth Menon
#13 lore raw

Re: [PATCH 2/5] staging:ti dspbridge: remove unnecessary check for NULL pointer in cmm.c

In reply to Ernesto Ramos

Ramos Falcon, Ernesto had written, on 07/28/2010 09:40 AM, the following:

Quoted 20 lines

Remove unnecessary check for NULL pointer in cmm.c.

---
 drivers/staging/tidspbridge/pmgr/cmm.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/staging/tidspbridge/pmgr/cmm.c +0 -2
index 8e808d9..874ed64 100644
@@ -992,16 +992,12 @@ int cmm_xlator_create(struct cmm_xlatorobject **xlator,
 int cmm_xlator_delete(struct cmm_xlatorobject *xlator, bool force)
 {
 	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
-	int status = 0;
 
 	DBC_REQUIRE(refs > 0);
 
-	if (xlator_obj)

drivers/staging/tidspbridge/pmgr/cmm.c int cmm_xlator_create(struct cmm_xlatorobject **xlator, · line 1003

Quoted 10 lines
drivers/staging/tidspbridge/pmgr/cmm.c +2 -4
-		kfree(xlator_obj);
-	else
-		status = -EFAULT;
+	kfree(xlator_obj);
 
-	return status;
+	return 0;
 }
 
 /*

which kind of begs the question - does this function need to any longer return int?

Signature · 2 lines
Regards,
Nishanth Menon
#6 lore raw

Re: [PATCH 5/5] staging:ti dspbridge: replace simple_strtoul by strict_strtoul

In reply to Ernesto Ramos
Quoted 1 line · Ernesto Ramos

Replace simple_strtoul by strict_strtoul in atoi function.

Why not use the built-in kernel function instead of having your own atoi function?

thanks,

greg k-h

#14 lore raw

Re: [PATCH 2/5] staging:ti dspbridge: remove unnecessary check for NULL pointer in cmm.c

In reply to Nishanth Menon

Nishanth Menon had written, on 07/28/2010 10:04 AM, the following:

Quoted 26 lines

Ramos Falcon, Ernesto had written, on 07/28/2010 09:40 AM, the following:

Quoted 25 lines

Remove unnecessary check for NULL pointer in cmm.c.

---
 drivers/staging/tidspbridge/pmgr/cmm.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/staging/tidspbridge/pmgr/cmm.c +1 -5
index 8e808d9..874ed64 100644
@@ -992,16 +992,12 @@ int cmm_xlator_create(struct cmm_xlatorobject **xlator,
 int cmm_xlator_delete(struct cmm_xlatorobject *xlator, bool force)
 {
 	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
-	int status = 0;
 
 	DBC_REQUIRE(refs > 0);
 
-	if (xlator_obj)
-		kfree(xlator_obj);
-	else
-		status = -EFAULT;
+	kfree(xlator_obj);
 
Quoted 7 lines

drivers/staging/tidspbridge/pmgr/cmm.c int cmm_xlator_create(struct cmm_xlatorobject **xlator, · line 1003

Quoted 5 lines
drivers/staging/tidspbridge/pmgr/cmm.c +1 -1
-	return status;
+	return 0;
 }
 
 /*

which kind of begs the question - does this function need to any longer return int?

here is a better approach:
remove cmm_xlator_delete altogether

drivers/staging/tidspbridge/pmgr/cmm.c +0 -21
index 8e808d9..1a4ebca 100644
@@ -984,27 +984,6 @@ int cmm_xlator_create(struct cmm_xlatorobject **xlator,
 }
 
 /*
- *  ======== cmm_xlator_delete ========
- *  Purpose:
- *      Free the Xlator resources.
- *      VM gets freed later.
- */
-int cmm_xlator_delete(struct cmm_xlatorobject *xlator, bool force)
-{
-	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
-	int status = 0;
-
-	DBC_REQUIRE(refs > 0);
-
-	if (xlator_obj)
-		kfree(xlator_obj);
-	else
-		status = -EFAULT;
-
-	return status;
-}
-
-/*
  *  ======== cmm_xlator_alloc_buf ========
  */
 void *cmm_xlator_alloc_buf(struct cmm_xlatorobject *xlator, void *va_buf,
drivers/staging/tidspbridge/rmgr/node.c +1 -6
index 9f07c81..0c39288 100644
@@ -2503,7 +2503,6 @@ static void delete_node(struct node_object *hnode,
 			struct process_context *pr_ctxt)
 {
 	struct node_mgr *hnode_mgr;
-	struct cmm_xlatorobject *xlator;
 	struct bridge_drv_interface *intf_fxns;
 	u32 i;
 	enum node_type node_type;
@@ -2521,7 +2520,6 @@ static void delete_node(struct node_object *hnode,
 	hnode_mgr = hnode->hnode_mgr;
 	if (!hnode_mgr)
 		goto func_end;
-	xlator = hnode->xlator;
 	node_type = node_get_type(hnode);
 	if (node_type != NODE_DEVICE) {
 		node_msg_args = hnode->create_args.asa.node_msg_args;
@@ -2617,10 +2615,7 @@ static void delete_node(struct node_object *hnode,
 	hnode->dcd_props.obj_data.node_obj.pstr_i_alg_name = NULL;
 
 	/* Free all SM address translator resources */
-	if (xlator) {
-		(void)cmm_xlator_delete(xlator, true);	/* force free */
-		xlator = NULL;
-	}
+	kfree(hnode->xlator);
 
 	kfree(hnode->nldr_node_obj);
 	hnode->nldr_node_obj = NULL;
drivers/staging/tidspbridge/rmgr/strm.c +2 -8
index 73888e3..05a8d13 100644
@@ -844,14 +844,8 @@ static int delete_strm(struct strm_object *stream_obj)
 			status = (*intf_fxns->pfn_chnl_close)
 					(stream_obj->chnl_obj);
 			/* Free all SM address translator resources */
-			if (DSP_SUCCEEDED(status)) {
-				if (stream_obj->xlator) {
-					/* force free */
-					(void)cmm_xlator_delete(stream_obj->
-								xlator,
-								true);
-				}
-			}
+			if (DSP_SUCCEEDED(status))
+				kfree(stream_obj->xlator);
 		}
 		kfree(stream_obj);
 	} else {
Signature · 2 lines
Regards,
Nishanth Menon
#15 lore raw

RE: [PATCH 2/5] staging:ti dspbridge: remove unnecessary check for NULL pointer in cmm.c

Quoted 142 lines

-----Original Message-----
From: Menon, Nishanth
Sent: Wednesday, July 28, 2010 10:32 AM
To: Ramos Falcon, Ernesto
Cc: [email protected]; Ramirez Luna, Omar; [email protected]; [email protected]; [email protected]; Guzman Lugo, Fernando; [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH 2/5] staging:ti dspbridge: remove unnecessary check for NULL pointer in cmm.c

Nishanth Menon had written, on 07/28/2010 10:04 AM, the following:

Quoted 9 lines

Ramos Falcon, Ernesto had written, on 07/28/2010 09:40 AM, the following:

Review

Quoted 8 lines

Remove unnecessary check for NULL pointer in cmm.c.

---
 drivers/staging/tidspbridge/pmgr/cmm.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/tidspbridge/pmgr/cmm.c

Quoted 4 lines

drivers/staging/tidspbridge/pmgr/cmm.c int cmm_xlator_create(struct cmm_xlatorobject

Quoted 4 lines

index 8e808d9..874ed64 100644

drivers/staging/tidspbridge/pmgr/cmm.c +0 -0
@@ -992,16 +992,12 @@ int cmm_xlator_create(struct cmm_xlatorobject

**xlator,

Quoted 13 lines
Quoted 13 lines
drivers/staging/tidspbridge/pmgr/cmm.c +1 -5
 int cmm_xlator_delete(struct cmm_xlatorobject *xlator, bool force)
 {
 	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
-	int status = 0;
 
 	DBC_REQUIRE(refs > 0);
 
-	if (xlator_obj)
-		kfree(xlator_obj);
-	else
-		status = -EFAULT;
+	kfree(xlator_obj);
 
Quoted 8 lines

drivers/staging/tidspbridge/pmgr/cmm.c int cmm_xlator_create(struct cmm_xlatorobject · line 1003

Quoted 5 lines
drivers/staging/tidspbridge/pmgr/cmm.c +1 -1
-	return status;
+	return 0;
 }
 
 /*

which kind of begs the question - does this function need to any longer return int?

here is a better approach:
remove cmm_xlator_delete altogether

drivers/staging/tidspbridge/pmgr/cmm.c +0 -21
index 8e808d9..1a4ebca 100644
@@ -984,27 +984,6 @@ int cmm_xlator_create(struct cmm_xlatorobject
 **xlator,
 }
 
 /*
- *  ======== cmm_xlator_delete ========
- *  Purpose:
- *      Free the Xlator resources.
- *      VM gets freed later.
- */
-int cmm_xlator_delete(struct cmm_xlatorobject *xlator, bool force)
-{
-	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
-	int status = 0;
-
-	DBC_REQUIRE(refs > 0);
-
-	if (xlator_obj)
-		kfree(xlator_obj);
-	else
-		status = -EFAULT;
-
-	return status;
-}
-
-/*
  *  ======== cmm_xlator_alloc_buf ========
  */

void *cmm_xlator_alloc_buf(struct cmm_xlatorobject *xlator, void *va_buf,

drivers/staging/tidspbridge/rmgr/node.c +1 -6
index 9f07c81..0c39288 100644
@@ -2503,7 +2503,6 @@ static void delete_node(struct node_object *hnode,
 			struct process_context *pr_ctxt)
 {
 	struct node_mgr *hnode_mgr;
-	struct cmm_xlatorobject *xlator;
 	struct bridge_drv_interface *intf_fxns;
 	u32 i;
 	enum node_type node_type;
@@ -2521,7 +2520,6 @@ static void delete_node(struct node_object *hnode,
 	hnode_mgr = hnode->hnode_mgr;
 	if (!hnode_mgr)
 		goto func_end;
-	xlator = hnode->xlator;
 	node_type = node_get_type(hnode);
 	if (node_type != NODE_DEVICE) {
 		node_msg_args = hnode->create_args.asa.node_msg_args;
@@ -2617,10 +2615,7 @@ static void delete_node(struct node_object *hnode,
 	hnode->dcd_props.obj_data.node_obj.pstr_i_alg_name = NULL;
 
 	/* Free all SM address translator resources */
-	if (xlator) {
-		(void)cmm_xlator_delete(xlator, true);	/* force free */
-		xlator = NULL;
-	}
+	kfree(hnode->xlator);
 
 	kfree(hnode->nldr_node_obj);
 	hnode->nldr_node_obj = NULL;
drivers/staging/tidspbridge/rmgr/strm.c +2 -9
index 73888e3..05a8d13 100644
@@ -844,14 +844,8 @@ static int delete_strm(struct strm_object *stream_obj)
 			status = (*intf_fxns->pfn_chnl_close)
 					(stream_obj->chnl_obj);
 			/* Free all SM address translator resources */
-			if (DSP_SUCCEEDED(status)) {
-				if (stream_obj->xlator) {
-					/* force free */
-					(void)cmm_xlator_delete(stream_obj->
-								xlator,
-								true);
-				}
-			}
+			if (DSP_SUCCEEDED(status))
+				kfree(stream_obj->xlator);
 		}
 		kfree(stream_obj);
 	} else {
--
Quoted 2 lines

Regards,
Nishanth Menon

Thanks Nishanth,

I considered this approach before but in terms of maintainability I thought it was easier to locate where translator tables are destroy if we keep cmm_xlator_delete function.

/Ernesto

#16 lore raw

Re: [PATCH 2/5] staging:ti dspbridge: remove unnecessary check for NULL pointer in cmm.c

Hi Ernesto,

Quoted 2 lines · Ernesto
Quoted 2 lines

here is a better approach:
remove cmm_xlator_delete altogether

[...]

Quoted 1 line

I considered this approach before but in terms of maintainability I thought it was easier to locate where translator tables are destroy if we keep cmm_xlator_delete function.

That's not maintainability, that's debugging convenience. AFAIU linux is all about maintenance, because that provides real, tangible, and proven gains. Debugging convenience gains are hypothetical; you don't really know how useful it will be to have a separate free function.

And please avoid bottom-posting, instead use interleaved style, otherwise people see a comment, and then have to scroll down to see the answer.
http://en.wikipedia.org/wiki/Posting_style#Interleaved_style

Signature · 1 line
Felipe Contreras
#17 lore raw

RE: [PATCH 2/5] staging:ti dspbridge: remove unnecessary check for NULL pointer in cmm.c

Agree! I'll send new version of this patch.

Quoted 36 lines

-----Original Message-----
From: Felipe Contreras [mailto:[email protected]]
Sent: Wednesday, July 28, 2010 12:12 PM
To: Ramos Falcon, Ernesto
Cc: Menon, Nishanth; [email protected]; Ramirez Luna, Omar; [email protected]; [email protected]; [email protected]; Guzman Lugo, Fernando; [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH 2/5] staging:ti dspbridge: remove unnecessary check for NULL pointer in cmm.c

Hi Ernesto,

Quoted 2 lines · Ernesto
Quoted 2 lines

here is a better approach:
remove cmm_xlator_delete altogether

[...]

Quoted 1 line

I considered this approach before but in terms of maintainability I

thought it was easier to locate where translator tables are destroy if we keep cmm_xlator_delete function.

That's not maintainability, that's debugging convenience. AFAIU linux is all about maintenance, because that provides real, tangible, and proven gains. Debugging convenience gains are hypothetical; you don't really know how useful it will be to have a separate free function.

And please avoid bottom-posting, instead use interleaved style, otherwise people see a comment, and then have to scroll down to see the answer.
http://en.wikipedia.org/wiki/Posting_style#Interleaved_style

--
Felipe Contreras

#7 lore raw

Re: [PATCH 5/5] staging:ti dspbridge: replace simple_strtoul by strict_strtoul

In reply to Greg KH
Quoted 5 lines · Greg KH
Quoted 1 line · Ernesto Ramos

Replace simple_strtoul by strict_strtoul in atoi function.

Why not use the built-in kernel function instead of having your own atoi function?

The commit message left opened questions about
http://dev.omapzoom.org/?p=tidspbridge/kernel-dspbridge.git;a=commit;h=b8af1123b47741086ef5a307ad1ec8fec6fc7f0d

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

Re: [PATCH 5/5] staging:ti dspbridge: replace simple_strtoul by strict_strtoul

In reply to Ernesto Ramos
Quoted 1 line · Ernesto Ramos

Replace simple_strtoul by strict_strtoul in atoi function.

In general the question what is the purpose here to do the change?

drivers/staging/tidspbridge/rmgr/dbdcd.c static s32 atoi(char *psz_buf) · line 1030

Quoted 8 lines
drivers/staging/tidspbridge/rmgr/dbdcd.c +3 -1
@@ -1023,7 +1025,9 @@ static s32 atoi(char *psz_buf)
                base = 16;
        }
 
-       return simple_strtoul(pch, NULL, base);
+       ret_val = strict_strtoul(pch, base, &res);
+
+       return ret_val ? : res;

May be better to use explicit values in condition?

Signature · 6 lines
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

Re: [PATCH 5/5] staging:ti dspbridge: replace simple_strtoul by strict_strtoul

In reply to Andy Shevchenko
Quoted 8 lines · Andy Shevchenko
Quoted 5 lines · Greg KH
Quoted 1 line · Ernesto Ramos

Replace simple_strtoul by strict_strtoul in atoi function.

Why not use the built-in kernel function instead of having your own atoi function?

The commit message left opened questions about
http://dev.omapzoom.org/?p=tidspbridge/kernel-dspbridge.git;a=commit;h=b8af1123b47741086ef5a307ad1ec8fec6fc7f0d

Ok, but you will have to fix this up eventually, you need to use the in-kernel library functions, or fix the in-kernel ones to add the support you need.

thanks,

greg k-h

#12 lore raw

RE: [PATCH 4/5] staging:ti dspbridge: remove unnecessary volatile variables

In reply to Nishanth Menon

Hi,

Quoted 10 lines

-----Original Message-----
From: Menon, Nishanth
Sent: Wednesday, July 28, 2010 10:04 AM
To: Ramos Falcon, Ernesto
Cc: [email protected]; Ramirez Luna, Omar; [email protected]; [email protected]; [email protected]; Guzman Lugo, Fernando; [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH 4/5] staging:ti dspbridge: remove unnecessary volatile variables

<snip>

Quoted 5 lines

drivers/staging/tidspbridge/core/tiomap3430.c static int bridge_brd_start(struct bridge_dev_context

Quoted 4 lines

index 08a2f5f..ae1f394 100644

drivers/staging/tidspbridge/core/tiomap3430.c +0 -0
@@ -404,7 +404,7 @@ static int bridge_brd_start(struct bridge_dev_context

*dev_ctxt,

Quoted 7 lines

drivers/staging/tidspbridge/core/tiomap3430.c static int bridge_brd_start(struct bridge_dev_context · line 407

Quoted 5 lines
drivers/staging/tidspbridge/core/tiomap3430.c +1 -1
 		pr_err("%s: Illegal SM base\n", __func__);
 		status = -EPERM;
 	} else
-		*((volatile u32 *)dw_sync_addr) = 0xffffffff;
+		__raw_writel(0xffffffff, dw_sync_addr);

curious question: any reason not to use writel instead of __raw_writel?

I was not aware of the existence of writel, but I think I should use writel instead.

Quoted 5 lines

drivers/staging/tidspbridge/core/tiomap3430.c static int bridge_brd_start(struct bridge_dev_context

Quoted 4 lines
drivers/staging/tidspbridge/core/tiomap3430.c +0 -0
 	if (DSP_SUCCEEDED(status)) {
 		resources = dev_context->resources;
@@ -584,7 +584,7 @@ static int bridge_brd_start(struct bridge_dev_context

*dev_ctxt,

Quoted 10 lines

drivers/staging/tidspbridge/core/tiomap3430.c static int bridge_brd_start(struct bridge_dev_context · line 588

Quoted 6 lines
drivers/staging/tidspbridge/core/tiomap3430.c +1 -1
 		dev_dbg(bridge, "Waiting for Sync @ 0x%x\n", dw_sync_addr);
 		dev_dbg(bridge, "DSP c_int00 Address =  0x%x\n", dsp_addr);
 		if (dsp_debug)
-			while (*((volatile u16 *)dw_sync_addr))
+			while (__raw_readw(dw_sync_addr))
 				;;

may be for a later on patch -> we seem to have a potential infinite loop here..

This is done intentionally and it is used to debug the dsp. The system will hang here, and then Lautherback or jtag can be connected to take control of the program execution from this point.

Quoted 25 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/staging/tidspbridge/pmgr/cmm.c

drivers/staging/tidspbridge/pmgr/cmm.c void *cmm_xlator_alloc_buf(struct cmm_xlatorobject

Quoted 4 lines

index 874ed64..b7cba1b 100644

drivers/staging/tidspbridge/pmgr/cmm.c +0 -0
@@ -1008,6 +1008,7 @@ void *cmm_xlator_alloc_buf(struct cmm_xlatorobject

*xlator, void *va_buf,

drivers/staging/tidspbridge/pmgr/cmm.c void *cmm_xlator_alloc_buf(struct

Quoted 8 lines
drivers/staging/tidspbridge/pmgr/cmm.c +1 -0
 {
 	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
 	void *pbuf = NULL;
+	void *tmp_va_buff;
 	struct cmm_attrs attrs;
 
 	DBC_REQUIRE(refs > 0);
@@ -1019,16 +1020,16 @@ void *cmm_xlator_alloc_buf(struct

cmm_xlatorobject *xlator, void *va_buf,

drivers/staging/tidspbridge/pmgr/cmm.c void *cmm_xlator_alloc_buf(struct cmm_xlatorobject *xlator, void *va_buf,

Quoted 8 lines
drivers/staging/tidspbridge/pmgr/cmm.c +1 -1
 	if (xlator_obj) {
 		attrs.ul_seg_id = xlator_obj->ul_seg_id;
-		*(volatile u32 *)va_buf = 0;
+		__raw_writel(0, va_buf);
 		/* Alloc SM */
 		pbuf =
 		    cmm_calloc_buf(xlator_obj->hcmm_mgr, pa_size, &attrs,

NULL);

Quoted 12 lines

drivers/staging/tidspbridge/pmgr/cmm.c void *cmm_xlator_alloc_buf(struct cmm_xlatorobject *xlator, void *va_buf,

Quoted 8 lines
drivers/staging/tidspbridge/pmgr/cmm.c +2 -2
 		if (pbuf) {
 			/* convert to translator(node/strm) process Virtual
 			 * address */
-			*(volatile u32 **)va_buf =
-			    (u32 *) cmm_xlator_translate(xlator,
+			 tmp_va_buff = cmm_xlator_translate(xlator,
 							 pbuf, CMM_PA2VA);
+			__raw_writel((u32)tmp_va_buff, va_buf);

a) is the u32 cast of tmp_va_buff really necessary?
b) tmp_va_buff is used only in this branch, why not reduce the scope of the variable to just to this if branch

Agree!

#10 lore raw

RE: [PATCH 5/5] staging:ti dspbridge: replace simple_strtoul by strict_strtoul

In reply to Andy Shevchenko

Hi,

Quoted 10 lines

-----Original Message-----
From: Andy Shevchenko [mailto:[email protected]]
Sent: Wednesday, July 28, 2010 1:44 PM
To: Ramos Falcon, Ernesto
Cc: [email protected]; Ramirez Luna, Omar; [email protected]; [email protected]; [email protected]; Guzman Lugo, Fernando; [email protected]; Menon, Nishanth; [email protected]
Subject: Re: [PATCH 5/5] staging:ti dspbridge: replace simple_strtoul by strict_strtoul

Quoted 4 lines
Quoted 1 line · Ernesto Ramos

Replace simple_strtoul by strict_strtoul in atoi function.

In general the question what is the purpose here to do the change?

It is recommended to use strict_strtoul instead of simple_strtoul since ensures the string is really a valid unsigned long. This also removes checkpatch warning message.

Quoted 10 lines

drivers/staging/tidspbridge/rmgr/dbdcd.c static s32 atoi(char *psz_buf) · line 1030

Quoted 8 lines
drivers/staging/tidspbridge/rmgr/dbdcd.c +3 -1
@@ -1023,7 +1025,9 @@ static s32 atoi(char *psz_buf)
                base = 16;
        }
 
-       return simple_strtoul(pch, NULL, base);
+       ret_val = strict_strtoul(pch, base, &res);
+
+       return ret_val ? : res;

May be better to use explicit values in condition?

I think this is ok as it is, I'm not sure but I think it maybe defined in any C ansi book, in this case if ret_val is unequal to 0 ret_val is returned.

Quoted 3 lines

--
With Best Regards,
Andy Shevchenko