Messages in this thread | | | Date | Tue, 1 Apr 2008 01:19:47 -0400 | From | Dmitry Torokhov <> | 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
| |