[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080401051947.GD18041@anvil.corenet.prv>
Date: Tue, 1 Apr 2008 01:19:47 -0400
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: Jaya Kumar <jayakumar.lkml@...il.com>
Cc: Linux Kernel Development <linux-kernel@...r.kernel.org>
Subject: Re: 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists