[alsa-devel] [PATCH] ASoC: fsl: Fix error handling if platform_device_add fails

Axel Lin axel.lin at gmail.com
Tue Sep 27 04:21:59 CEST 2011

2011/9/27 Tabi Timur-B04825 <B04825 at freescale.com>:
> Axel Lin wrote:
>> Call platform_device_put() instead of platform_device_unregister() if
>> platform_device_add() fails.
> What's wrong with calling platform_device_unregister()?

 * platform_device_unregister - unregister a platform-level device
 * @pdev: platform device we're unregistering
 * Unregistration is done in 2 steps. First we release all resources
 * and remove it from the subsystem, then we drop reference count by
 * calling platform_device_put().

platform_device_unregister() actually calls platform_device_del() and

If platform_device_add() call fails, we failed to add the platform
device to device hierarchy. Thus we can just call platform_device_put() instead.

> --
> Timur Tabi
> Linux kernel developer at Freescale

More information about the Alsa-devel mailing list