[alsa-devel] [PATCH] ASoC: wm8962: Convert to devm_input_allocate_device()

Leon Romanovsky leon at leon.nu
Mon Apr 29 19:47:37 CEST 2013

On Mon, Apr 29, 2013 at 1:19 PM, Mark Brown <broonie at kernel.org> wrote:
> On Sun, Apr 28, 2013 at 09:32:18PM +0300, Leon Romanovsky wrote:
>> I think the reason of our misunderstanding is due to the name of
>> input_free_device call. From the code, it is device destroy function,
>> and the freeing itself done as an error handling of
>> input_register_device
>> (http://lxr.free-electrons.com/source/drivers/input/input.c#L2114).
>> How do you think we need to proceed? Do I need to send patches with
>> explicit call to input_free_device function?
> I really think the input API needs to be looked at here, this is all way
> too error prone.  Calling input_free_device() on something allocated
> using devm_ looks like an error itself...
In general, I agree with you, but I think we both agree that the
current patch is not working as expected.
The problem is that you allocated device with devm_ and later at the
code you tried to register it, but failed. In this case no one will
call to devres_destroy, because it is done at unregister stage only.

I see two possible solutions:
1. short one - fix your patches
2. long one - add input_free_device code into input_register_device
call (http://lxr.free-electrons.com/source/drivers/input/input.c#L2114).

Leon Romanovsky | Independent Linux Consultant
        www.leon.nu | leon at leon.nu

More information about the Alsa-devel mailing list