diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2018-10-03 08:21:50 +0900 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-10-04 07:54:01 +0200 |
commit | 366a20d7a75cff7f89dede6fdfd41bd491aaf8ac (patch) | |
tree | 76d2420ee45eff7139a3ede8cd020cf7df7ed98a /sound/firewire/digi00x | |
parent | 4a9a72e0db5e584267944f4d868f46419b2fab59 (diff) | |
download | linux-366a20d7a75cff7f89dede6fdfd41bd491aaf8ac.tar.bz2 |
ALSA: firewire: use managed-resource of fw unit device for private data
At present, private data of each driver in ALSA firewire stack is
allocated/freed by kernel slab allocator for corresponding unit on
IEEE 1394 bus. In this case, resource-managed slab allocator is
available to release memory object automatically just before releasing
device structure for the unit. This idea can prevent runtime from
memory leak due to programming mistakes.
This commit uses the allocator for the private data. These drivers
already use reference counter to maintain lifetime of device structure
for the unit by a pair of fw_unit_get()/fw_unit_put(). The private data
is safely released in a callback of 'struct snd_card.private_free().
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/digi00x')
-rw-r--r-- | sound/firewire/digi00x/digi00x.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/sound/firewire/digi00x/digi00x.c b/sound/firewire/digi00x/digi00x.c index ef689997d6a5..654420f1c9bd 100644 --- a/sound/firewire/digi00x/digi00x.c +++ b/sound/firewire/digi00x/digi00x.c @@ -46,10 +46,8 @@ static void dg00x_free(struct snd_dg00x *dg00x) snd_dg00x_stream_destroy_duplex(dg00x); snd_dg00x_transaction_unregister(dg00x); - fw_unit_put(dg00x->unit); - mutex_destroy(&dg00x->mutex); - kfree(dg00x); + fw_unit_put(dg00x->unit); } static void dg00x_card_free(struct snd_card *card) @@ -120,8 +118,9 @@ static int snd_dg00x_probe(struct fw_unit *unit, struct snd_dg00x *dg00x; /* Allocate this independent of sound card instance. */ - dg00x = kzalloc(sizeof(struct snd_dg00x), GFP_KERNEL); - if (dg00x == NULL) + dg00x = devm_kzalloc(&unit->device, sizeof(struct snd_dg00x), + GFP_KERNEL); + if (!dg00x) return -ENOMEM; dg00x->unit = fw_unit_get(unit); |