ALSA: intel8x0: Allocate resources with device-managed APIs
authorTakashi Iwai <tiwai@suse.de>
Thu, 15 Jul 2021 07:58:27 +0000 (09:58 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 19 Jul 2021 14:16:36 +0000 (16:16 +0200)
commit7835e0901e245aa8b83d7e2964f17088cb2e1f1e
tree419851236e88ba39c089447059d61ddae3ced3dd
parentac327f1b10bca6cee8f1a427e5ba451e2d69c710
ALSA: intel8x0: Allocate resources with device-managed APIs

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.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/intel8x0.c
sound/pci/intel8x0m.c