All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Menon, Nishanth" <nm@ti.com>
To: Ameya Palande <ameya.palande@nokia.com>
Cc: "Ramirez Luna, Omar" <omar.ramirez@ti.com>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"Chitriki Rudramuni, Deepak" <deepak.chitriki@ti.com>
Subject: Re: [PATCH] DSPBRIDGE: MEM_VFree() cleanup
Date: Mon, 1 Feb 2010 22:00:56 +0200	[thread overview]
Message-ID: <4B6732F8.1010809@ti.com> (raw)
In-Reply-To: <48172f2f93a66f4d34c79aa6164236b01e706e3e.1265046944.git.ameya.palande@nokia.com>

Ameya Palande said the following on 02/01/2010 07:56 PM:
> Since vfree() checks for null pointer, there is no need to check is again in
> MEM_VFree(). This patch also reorganizes the function to make it more readable.
> 
> Signed-off-by: Ameya Palande <ameya.palande@nokia.com>
> ---
>  drivers/dsp/bridge/services/mem.c |   42 +++++++++++++++----------------------
>  1 files changed, 17 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/dsp/bridge/services/mem.c b/drivers/dsp/bridge/services/mem.c
> index dfe352d..c2887b3 100644
> --- a/drivers/dsp/bridge/services/mem.c
> +++ b/drivers/dsp/bridge/services/mem.c
> @@ -456,35 +456,27 @@ void MEM_FlushCache(void *pMemBuf, u32 cBytes, s32 FlushType)
>  void MEM_VFree(IN void *pMemBuf)
>  {
>  #ifdef MEM_CHECK
> -	struct memInfo *pMem = (void *)((u32)pMemBuf - sizeof(struct memInfo));
> +	struct memInfo *pMem;
>  #endif
> -
> -	DBC_Require(pMemBuf != NULL);
does'nt this remove a warning for us?
> -
>  	GT_1trace(MEM_debugMask, GT_ENTER, "MEM_VFree: pMemBufs 0x%x\n",
> -		  pMemBuf);
> -
> -	if (pMemBuf) {
> -#ifndef MEM_CHECK
> -		vfree(pMemBuf);
> +			pMemBuf);
probably an un-needed formattig change -> messed the diff a little bit 
here

> +#ifdef MEM_CHECK
> +	if (!pMemBuf) {
> +		GT_1trace(MEM_debugMask, GT_7CLASS,
> +			"Invalid allocation or Buffer underflow\n");
> +		return;
> +	}
> +	pMem = (void *)((u32)pMemBuf - sizeof(struct memInfo));
> +	if (pMem && pMem->dwSignature == memInfoSign) {
> +		spin_lock(&mMan.lock);
> +		MLST_RemoveElem(&mMan.lst, (struct list_head *)pMem);
> +		spin_unlock(&mMan.lock);
> +		pMem->dwSignature = 0;
^^^^^^^^^^^^^ Dumb question: signature should be locked? (yep the prev 
code was as such)..
> +		vfree(pMem);
> +	}
>  #else
> -		if (pMem) {
> -			if (pMem->dwSignature == memInfoSign) {
> -				spin_lock(&mMan.lock);
> -				MLST_RemoveElem(&mMan.lst,
> -						(struct list_head *)pMem);
> -				spin_unlock(&mMan.lock);
> -				pMem->dwSignature = 0;
> -				vfree(pMem);
> -			} else {
> -				GT_1trace(MEM_debugMask, GT_7CLASS,
> -					"Invalid allocation or "
> -					"Buffer underflow at %x\n",
> -					(u32) pMem + sizeof(struct memInfo));
> -			}
> -		}
> +	vfree(pMemBuf);
^^^^^^^^^^ it looks to me that if you put pMemBuf = pMem in the #ifdef 
case, you could probably move vfree out of the #ifdef altogether..
>  #endif
> -	}
>  }
>  
>  /*

Regards,
Nishanth Menon

  reply	other threads:[~2010-02-01 20:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-01 17:56 [PATCH] DSPBRIDGE: MEM_VFree() cleanup Ameya Palande
2010-02-01 20:00 ` Menon, Nishanth [this message]
2010-02-02 18:44   ` Ameya Palande

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=4B6732F8.1010809@ti.com \
    --to=nm@ti.com \
    --cc=ameya.palande@nokia.com \
    --cc=deepak.chitriki@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.