linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: "Ramos Falcon, Ernesto" <ernesto@ti.com>
Cc: "gregkh@suse.de" <gregkh@suse.de>,
	"Ramirez Luna, Omar" <omar.ramirez@ti.com>,
	"ohad@wizery.com" <ohad@wizery.com>,
	"ameya.palande@nokia.com" <ameya.palande@nokia.com>,
	"felipe.contreras@nokia.com" <felipe.contreras@nokia.com>,
	"Guzman Lugo, Fernando" <fernando.lugo@ti.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"andy.shevchenko@gmail.com" <andy.shevchenko@gmail.com>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [PATCH 2/5] staging:ti dspbridge: remove unnecessary check for NULL pointer in cmm.c
Date: Wed, 28 Jul 2010 10:31:50 -0500	[thread overview]
Message-ID: <4C504D66.8090302@ti.com> (raw)
In-Reply-To: <4C504719.3020007@ti.com>

Nishanth Menon had written, on 07/28/2010 10:04 AM, the following:
> Ramos Falcon, Ernesto had written, on 07/28/2010 09:40 AM, the following:
>> Remove unnecessary check for NULL pointer in cmm.c.
>>
>> Signed-off-by: Ernesto Ramos <ernesto@ti.com>
>> ---
>>  drivers/staging/tidspbridge/pmgr/cmm.c |    8 ++------
>>  1 files changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/tidspbridge/pmgr/cmm.c b/drivers/staging/tidspbridge/pmgr/cmm.c
>> index 8e808d9..874ed64 100644
>> --- a/drivers/staging/tidspbridge/pmgr/cmm.c
>> +++ b/drivers/staging/tidspbridge/pmgr/cmm.c
>> @@ -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;
>>  }
>>  
>>  /*
> 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
diff --git a/drivers/staging/tidspbridge/pmgr/cmm.c 
b/drivers/staging/tidspbridge/pmgr/cmm.c
index 8e808d9..1a4ebca 100644
--- a/drivers/staging/tidspbridge/pmgr/cmm.c
+++ b/drivers/staging/tidspbridge/pmgr/cmm.c
@@ -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,
diff --git a/drivers/staging/tidspbridge/rmgr/node.c 
b/drivers/staging/tidspbridge/rmgr/node.c
index 9f07c81..0c39288 100644
--- a/drivers/staging/tidspbridge/rmgr/node.c
+++ b/drivers/staging/tidspbridge/rmgr/node.c
@@ -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;
diff --git a/drivers/staging/tidspbridge/rmgr/strm.c 
b/drivers/staging/tidspbridge/rmgr/strm.c
index 73888e3..05a8d13 100644
--- a/drivers/staging/tidspbridge/rmgr/strm.c
+++ b/drivers/staging/tidspbridge/rmgr/strm.c
@@ -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 {
-- 
Regards,
Nishanth Menon

  reply	other threads:[~2010-07-28 15:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-28 14:40 [PATCH 0/5] staging:ti dspbridge: Checkpatch errors cleanup series Ernesto Ramos
2010-07-28 14:40 ` [PATCH 1/5] staging:ti dspbridge: remove unused typedef REG16 Ernesto Ramos
2010-07-28 14:40   ` [PATCH 2/5] staging:ti dspbridge: remove unnecessary check for NULL pointer in cmm.c Ernesto Ramos
2010-07-28 14:40     ` [PATCH 3/5] staging:ti dspbridge: remove function delete_strm_mgr Ernesto Ramos
2010-07-28 14:40       ` [PATCH 4/5] staging:ti dspbridge: remove unnecessary volatile variables Ernesto Ramos
2010-07-28 14:40         ` [PATCH 5/5] staging:ti dspbridge: replace simple_strtoul by strict_strtoul Ernesto Ramos
2010-07-28 15:09           ` Greg KH
2010-07-28 18:40             ` Andy Shevchenko
2010-07-28 18:56               ` Greg KH
2010-07-28 18:43           ` Andy Shevchenko
2010-08-03 17:33             ` Ramos Falcon, Ernesto
2010-07-28 15:03         ` [PATCH 4/5] staging:ti dspbridge: remove unnecessary volatile variables Nishanth Menon
2010-08-02 19:46           ` Ramos Falcon, Ernesto
2010-07-28 15:04     ` [PATCH 2/5] staging:ti dspbridge: remove unnecessary check for NULL pointer in cmm.c Nishanth Menon
2010-07-28 15:31       ` Nishanth Menon [this message]
2010-07-28 16:53         ` Ramos Falcon, Ernesto
2010-07-28 17:11           ` Felipe Contreras
2010-07-28 17:29             ` Ramos Falcon, Ernesto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C504D66.8090302@ti.com \
    --to=nm@ti.com \
    --cc=ameya.palande@nokia.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=ernesto@ti.com \
    --cc=felipe.contreras@nokia.com \
    --cc=fernando.lugo@ti.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=ohad@wizery.com \
    --cc=omar.ramirez@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).