Re: [PATCH] ASoC: fsl: Fix error handling if platform_device_add fails

From: Axel Lin
Date: Mon Sep 26 2011 - 22:22:21 EST


2011/9/27 Tabi Timur-B04825 <B04825@xxxxxxxxxxxxx>:
> 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
platform_device_put().

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
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/