summaryrefslogtreecommitdiffstats
path: root/sound/firewire/oxfw
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2018-10-03 01:21:54 +0200
committerTakashi Iwai <tiwai@suse.de>2018-10-04 07:54:09 +0200
commitcd3b7116b57527f659b96ff6988d2de3d448c5b3 (patch)
treed3c0f0d82eb3b528f343b2ddfbcfdc1a437a5cea /sound/firewire/oxfw
parentALSA: oxfw: use managed-resource to maintain model-specific data (diff)
downloadlinux-cd3b7116b57527f659b96ff6988d2de3d448c5b3.tar.xz
linux-cd3b7116b57527f659b96ff6988d2de3d448c5b3.zip
ALSA: oxfw: use managed-resource to maintain cache of stream formats
ALSA oxfw driver allocates memory objects for cache of stream formats. The objects are used to maintain packet streaming by components for ALSA rawMIDI/PCM interface. They can be released as managed-resource of 'struct snd_card.card_dev'. This commit uses managed-resource of the sound card device for this purpose. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/oxfw')
-rw-r--r--sound/firewire/oxfw/oxfw-stream.c13
-rw-r--r--sound/firewire/oxfw/oxfw.c14
2 files changed, 8 insertions, 19 deletions
diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c
index d9361f352133..f230a9e44c3c 100644
--- a/sound/firewire/oxfw/oxfw-stream.c
+++ b/sound/firewire/oxfw/oxfw-stream.c
@@ -517,8 +517,9 @@ assume_stream_formats(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir,
if (err < 0)
goto end;
- formats[eid] = kmemdup(buf, *len, GFP_KERNEL);
- if (formats[eid] == NULL) {
+ formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len,
+ GFP_KERNEL);
+ if (!formats[eid]) {
err = -ENOMEM;
goto end;
}
@@ -535,7 +536,8 @@ assume_stream_formats(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir,
continue;
eid++;
- formats[eid] = kmemdup(buf, *len, GFP_KERNEL);
+ formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, *len,
+ GFP_KERNEL);
if (formats[eid] == NULL) {
err = -ENOMEM;
goto end;
@@ -597,8 +599,9 @@ static int fill_stream_formats(struct snd_oxfw *oxfw,
if (err < 0)
break;
- formats[eid] = kmemdup(buf, len, GFP_KERNEL);
- if (formats[eid] == NULL) {
+ formats[eid] = devm_kmemdup(&oxfw->card->card_dev, buf, len,
+ GFP_KERNEL);
+ if (!formats[eid]) {
err = -ENOMEM;
break;
}
diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c
index 06d791acfdc5..6ac551786b93 100644
--- a/sound/firewire/oxfw/oxfw.c
+++ b/sound/firewire/oxfw/oxfw.c
@@ -115,17 +115,10 @@ end:
static void oxfw_free(struct snd_oxfw *oxfw)
{
- unsigned int i;
-
snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
if (oxfw->has_output)
snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
- for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
- kfree(oxfw->tx_stream_formats[i]);
- kfree(oxfw->rx_stream_formats[i]);
- }
-
mutex_destroy(&oxfw->mutex);
fw_unit_put(oxfw->unit);
}
@@ -205,7 +198,6 @@ static int detect_quirks(struct snd_oxfw *oxfw)
static void do_registration(struct work_struct *work)
{
struct snd_oxfw *oxfw = container_of(work, struct snd_oxfw, dwork.work);
- int i;
int err;
if (oxfw->registered)
@@ -268,12 +260,6 @@ error:
snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
if (oxfw->has_output)
snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
- for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; ++i) {
- kfree(oxfw->tx_stream_formats[i]);
- oxfw->tx_stream_formats[i] = NULL;
- kfree(oxfw->rx_stream_formats[i]);
- oxfw->rx_stream_formats[i] = NULL;
- }
snd_card_free(oxfw->card);
dev_info(&oxfw->unit->device,
"Sound card registration failed: %d\n", err);