public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Geoff Levand <geoffrey.levand@am.sony.com>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: Geert.Uytterhoeven@sonycom.com, linuxppc-dev@ozlabs.org,
	cbe-oss-dev@ozlabs.org, lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ps3: remove driver_data direct access of struct device
Date: Mon, 11 May 2009 14:07:41 -0700	[thread overview]
Message-ID: <4A08939D.5050203@am.sony.com> (raw)
In-Reply-To: <4A087DB9.50305@gmail.com>

Hi Roel,

On 05/11/2009 12:34 PM, Roel Kluin wrote:
> To avoid direct access to the driver_data pointer in struct device, the
> functions dev_get_drvdata() and dev_set_drvdata() should be used.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> Please review. especially note that I removed a
> kfree(dev->sbd.core.driver_data);
> Is that correct?

Comment below.

>  arch/powerpc/include/asm/ps3.h |    4 ++--
>  drivers/char/ps3flash.c        |   11 +++++------
>  drivers/scsi/ps3rom.c          |   10 +++++-----
>  drivers/video/ps3fb.c          |    6 +++---
>  4 files changed, 15 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h
> index cdb6fd8..a55717e 100644
> --- a/arch/powerpc/include/asm/ps3.h
> +++ b/arch/powerpc/include/asm/ps3.h
> @@ -421,12 +421,12 @@ static inline struct ps3_system_bus_driver *
>  static inline void ps3_system_bus_set_driver_data(
>  	struct ps3_system_bus_device *dev, void *data)
>  {
> -	dev->core.driver_data = data;
> +	dev_set_drvdata(&dev->core, data);
>  }
>  static inline void *ps3_system_bus_get_driver_data(
>  	struct ps3_system_bus_device *dev)
>  {
> -	return dev->core.driver_data;
> +	return dev_get_drvdata(&dev->core);
>  }
>  
>  /* These two need global scope for get_dma_ops(). */
> diff --git a/drivers/char/ps3flash.c b/drivers/char/ps3flash.c
> index afbe456..6083032 100644
> --- a/drivers/char/ps3flash.c
> +++ b/drivers/char/ps3flash.c
> @@ -108,7 +108,7 @@ static ssize_t ps3flash_read(struct file *file, char __user *buf, size_t count,
>  			     loff_t *pos)
>  {
>  	struct ps3_storage_device *dev = ps3flash_dev;
> -	struct ps3flash_private *priv = dev->sbd.core.driver_data;
> +	struct ps3flash_private *priv = dev_get_drvdata(&dev->sbd.core);

These should all be using ps3_system_bus_get_driver_data() and
ps3_system_bus_set_driver_data():

  struct ps3flash_private *priv = ps3_system_bus_get_driver_data(&dev->sbd)

> @@ -404,8 +404,7 @@ static int ps3flash_remove(struct ps3_system_bus_device *_dev)
>  
>  	misc_deregister(&ps3flash_misc);
>  	ps3stor_teardown(dev);
> -	kfree(dev->sbd.core.driver_data);
> -	dev->sbd.core.driver_data = NULL;
> +	dev_set_drvdata(&dev->sbd.core, NULL);

It seems that will result in a memory leak.  Why did you
think the kfree() should be removed?

Won't this work?

	kfree(ps3_system_bus_get_driver_data(&dev->sbd));
	ps3_system_bus_set_driver_data(&dev->sbd, NULL);

>  	ps3flash_dev = NULL;
>  	return 0;
>  }

-Geoff


      reply	other threads:[~2009-05-11 21:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-11 19:34 [PATCH] ps3: remove driver_data direct access of struct device Roel Kluin
2009-05-11 21:07 ` Geoff Levand [this message]

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=4A08939D.5050203@am.sony.com \
    --to=geoffrey.levand@am.sony.com \
    --cc=Geert.Uytterhoeven@sonycom.com \
    --cc=cbe-oss-dev@ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=roel.kluin@gmail.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