login
Header Space

 
 

Re: Clarifying platform_device_unregister

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jaya Kumar <jayakumar.lkml@...>, Richard Purdie <rpurdie@...>
Cc: Linux Kernel Development <linux-kernel@...>
Date: Tuesday, April 1, 2008 - 10:54 am

On Tue, Apr 01, 2008 at 12:47:54AM -0700, Jaya Kumar wrote:

Hmm, are you sure they can't be removed? Why do they all have
module_exit methods?

Even if they can't be unloaded the whole thing will blow to pieces
if registration fails. Consider this:

static int __devinit spitzpm_init(void)
{
        int ret;

        spitzpm_device = platform_device_alloc("sharpsl-pm", -1);
        if (!spitzpm_device)
                return -ENOMEM;

        spitzpm_device->dev.platform_data = &spitz_pm_machinfo;
        ret = platform_device_add(spitzpm_device);

        if (ret)
                platform_device_put(spitzpm_device);
		^^^^^^^^^^^
This will try to kfree(spitzpm_device->dev.platform_data) and it gonna
blow. We need to do spitzpm_device->dev.platform_data = NULL before doing
put.

Also  spitzpm_init() shoudl be marked __init, not __devinit and
spitzpm_exit() should be __exit() if it is event needed at all.

Richard, I think you work with spitz and corgi, any comments?

-- 
Dmitry
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Clarifying platform_device_unregister, Jaya Kumar, (Mon Mar 31, 9:14 pm)
Re: Clarifying platform_device_unregister, Dmitry Torokhov, (Tue Apr 1, 1:19 am)
Re: Clarifying platform_device_unregister, Jaya Kumar, (Tue Apr 1, 3:47 am)
Re: Clarifying platform_device_unregister, Dmitry Torokhov, (Tue Apr 1, 10:54 am)
Re: Clarifying platform_device_unregister, Richard Purdie, (Sat Apr 5, 7:44 am)
Re: Clarifying platform_device_unregister, Jaya Kumar, (Tue Apr 1, 9:57 pm)
Re: Clarifying platform_device_unregister, Richard Purdie, (Sat Apr 5, 8:07 am)
speck-geostationary