public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Jaya Kumar <jayakumar.lkml@gmail.com>
Cc: Linux Kernel Development <linux-kernel@vger.kernel.org>
Subject: Re: Clarifying platform_device_unregister
Date: Tue, 1 Apr 2008 01:19:47 -0400	[thread overview]
Message-ID: <20080401051947.GD18041@anvil.corenet.prv> (raw)
In-Reply-To: <45a44e480803311814q22bc85dbx9a7d128d84b7db08@mail.gmail.com>

Hi Jaya,

On Mon, Mar 31, 2008 at 09:14:35PM -0400, Jaya Kumar wrote:
> Hi,
> 
> I'm trying to figure out a problem I'm experiencing with
> platform_device_unregister. Here's what I'm seeing with a piece of
> test code based on corgi_pm.c:
> 
> static int mydata;
> static struct platform_device *mytest_device;
> static int __devinit mytest_init(void)
> {
>         int ret;
> 
>         mytest_device = platform_device_alloc("no_such_driver", -1);
> 
> // no_such_driver intentionally doesn't exist. i want to test this
> mytest module being insmod-ed/rmmod-ed without ever being bound to a
> platform driver.
> 
>         if (!mytest_device)
>                 return -ENOMEM;
> 
> 
>         mytest_device->dev.platform_data = &mydata;

Platform device code does kfree(pdev->dev.platform_data) unpon
unregistration, so it is not a good idea to assign address of
statically-allocated variable here. You should be using:

	platform_device_add_data(mytest_device, &mydata, sizeof(mydata));


>         ret = platform_device_add(mytest_device);
> 
>         if (ret)
>                 platform_device_put(mytest_device);
> 
>         return ret;
> }
> 
> static void mytest_exit(void)
> {
>         platform_device_unregister(mytest_device);
> }
> 
> 

Hope this helps.

-- 
Dmitry

  reply	other threads:[~2008-04-01  5:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-01  1:14 Clarifying platform_device_unregister Jaya Kumar
2008-04-01  5:19 ` Dmitry Torokhov [this message]
2008-04-01  7:47   ` Jaya Kumar
2008-04-01 14:54     ` Dmitry Torokhov
2008-04-02  1:57       ` Jaya Kumar
2008-04-05 12:07         ` Richard Purdie
2008-04-05 11:44       ` Richard Purdie

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=20080401051947.GD18041@anvil.corenet.prv \
    --to=dmitry.torokhov@gmail.com \
    --cc=jayakumar.lkml@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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