ALSA: oxfw: use managed-resource to maintain model-specific data
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Tue, 2 Oct 2018 23:21:53 +0000 (08:21 +0900)
committerTakashi Iwai <tiwai@suse.de>
Thu, 4 Oct 2018 05:54:08 +0000 (07:54 +0200)
ALSA oxfw driver allocates memory objects for data specific to some
models. These objects are used to maintain functionalities specific
to the models for ALSA rawMIDI/control interfaces. 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>
sound/firewire/oxfw/oxfw-scs1x.c
sound/firewire/oxfw/oxfw-spkr.c
sound/firewire/oxfw/oxfw.c

index f33497cdc706e65584c2dfdecad43862b3906b27..9d9545880a28a4908e79f26e75e1a75470984a3c 100644 (file)
@@ -372,8 +372,9 @@ int snd_oxfw_scs1x_add(struct snd_oxfw *oxfw)
        struct fw_scs1x *scs;
        int err;
 
-       scs = kzalloc(sizeof(struct fw_scs1x), GFP_KERNEL);
-       if (scs == NULL)
+       scs = devm_kzalloc(&oxfw->card->card_dev, sizeof(struct fw_scs1x),
+                          GFP_KERNEL);
+       if (!scs)
                return -ENOMEM;
        scs->fw_dev = fw_parent_device(oxfw->unit);
        oxfw->spec = scs;
index cb905af0660dd29b119fcc2de8bc876fff004308..66d4b1f73f0fcb88e8fa0120b83468fbaf345b6d 100644 (file)
@@ -270,8 +270,9 @@ int snd_oxfw_add_spkr(struct snd_oxfw *oxfw, bool is_lacie)
        unsigned int i, first_ch;
        int err;
 
-       spkr = kzalloc(sizeof(struct fw_spkr), GFP_KERNEL);
-       if (spkr == NULL)
+       spkr = devm_kzalloc(&oxfw->card->card_dev, sizeof(struct fw_spkr),
+                           GFP_KERNEL);
+       if (!spkr)
                return -ENOMEM;
        oxfw->spec = spkr;
 
index b892a8642204358790377434685224ef57b63077..06d791acfdc5a3ffe578be5d15199cd09cb3f0d2 100644 (file)
@@ -126,7 +126,6 @@ static void oxfw_free(struct snd_oxfw *oxfw)
                kfree(oxfw->rx_stream_formats[i]);
        }
 
-       kfree(oxfw->spec);
        mutex_destroy(&oxfw->mutex);
        fw_unit_put(oxfw->unit);
 }
@@ -276,8 +275,6 @@ error:
                oxfw->rx_stream_formats[i] = NULL;
        }
        snd_card_free(oxfw->card);
-       kfree(oxfw->spec);
-       oxfw->spec = NULL;
        dev_info(&oxfw->unit->device,
                 "Sound card registration failed: %d\n", err);
 }