• Takashi Iwai's avatar
    ALSA: intel8x0: Allocate resources with device-managed APIs · 7835e090
    Takashi Iwai authored
    This patch refactors the intel8x0 and intel8x0m driver codes using
    devres and gets rid of the driver remove callback.
    
    The conversion is fairly straightforward: each API call is replaced
    with the device-managed API function, e.g. pci_enable_device() ->
    pcim_enable_device(), and so on.  The buffer descriptor list is
    allocated with a new API, snd_devm_alloc_pages().
    
    A slight code structure change is that the intel8x0 object is
    allocated as a card's private_data instead of the own lowlevel
    snd_device object.  This simplifies the resource management.
    And, the take-down procedure is triggered via card->private_free, and
    it's registered at the end of the whole initialization, i.e. after the
    all resources get properly managed.
    
    The only not-devres-managed resource is the irq handler.  Since we
    need to release at suspend and re-acquire at resume (otherwise
    something weird happens on some machines), this is still managed
    manually.  But the rest are all freed automatically.
    
    The end result is a good amount of code reduction.
    
    Link: https://lore.kernel.org/r/20210715075941.23332-6-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
    7835e090
intel8x0.c 87.4 KB