Re: [PATCH] Minor change to platform_device_register_simple prototype

Russell King
2005-12-08T23:23:04Z

On Thu, Dec 08, 2005 at 09:52:57PM +0100, Jean Delvare wrote:
> BTW, doesn't this suggest that the error path in
> platform_device_register_simple() is currently broken as well? If
> platform_device_add() fails therein, I take it that the resources
> previously allocated by platform_device_add_resources() will never be
> freed.

No. If platform_device_add() fails then you platform_device_put()
it with no other action. If it's been added, with the current
available interfaces, your only option is to
platform_device_unregister() it.

So:

- error during platform_device_alloc, no additional action necessary
- error returned by platform_device_add, you have a structure allocated
and initialised, you platform_device_put it.
- subsequently you want to get rid of it, platform_device_unregister it,
or alternatively platform_device_del + platform_device_put it (where
provided.)

This is actually a generic driver model rule which can be applied to
all driver model interfaces which have the alloc/init, add, del, put,
register, unregister methods.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core