lkml.org 
[lkml]   [2008]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Clarifying platform_device_unregister
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


\
 
 \ /
  Last update: 2008-04-01 07:23    [W:0.054 / U:0.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site