@@ -153,5 +153,7 @@ int snd_dice_create_midi(struct snd_dice *dice)
if ((midi_out_ports > 0) && (midi_in_ports > 0))
rmidi->info_flags |= SNDRV_RAWMIDI_INFO_DUPLEX;
+ dice->rmidi_dev = rmidi;
+
return 0;
}
@@ -426,5 +426,7 @@ int snd_dice_create_pcm(struct snd_dice *dice)
if (playback > 0)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
+ dice->pcm_dev = pcm;
+
return 0;
}
@@ -202,27 +202,30 @@ static void do_registration(struct work_struct *work)
if (dice->card->shutdown || dice->registered)
return;
+ dice->pcm_dev = NULL;
+ dice->rmidi_dev = NULL;
+
err = snd_dice_transaction_init(dice);
if (err < 0)
- goto end;
+ goto error;
err = dice_read_params(dice);
if (err < 0)
- goto end;
+ goto error;
dice_card_strings(dice);
err = snd_dice_create_pcm(dice);
if (err < 0)
- goto end;
+ goto error;
err = snd_dice_create_midi(dice);
if (err < 0)
- goto end;
+ goto error;
err = snd_card_register(dice->card);
if (err < 0)
- goto end;
+ goto error;
dice->registered = true;
@@ -234,6 +237,14 @@ static void do_registration(struct work_struct *work)
* card is released as the same way that usual sound cards are going to
* be released.
*/
+error:
+ snd_dice_transaction_destroy(dice);
+
+ if (dice->pcm_dev)
+ snd_device_free(dice->card, dice->pcm_dev);
+
+ if (dice->rmidi_dev)
+ snd_device_free(dice->card, dice->rmidi_dev);
}
static u64 calc_delay(struct snd_dice *dice)
@@ -47,6 +47,8 @@ struct snd_dice {
bool registered;
struct delayed_work dwork;
+ struct snd_pcm *pcm_dev;
+ struct snd_rawmidi *rmidi_dev;
/* Offsets for sub-addresses */
unsigned int global_offset;
When work of sound card registration fails, bus reset on IEEE 1394 can schedule the work again. In this case, currently instances of PCM and RawMIDI devices are not released, but allocated and errors occurs. This commit solves this issue. The allocated data is kept and released at any failures in the work. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> --- sound/firewire/dice/dice-midi.c | 2 ++ sound/firewire/dice/dice-pcm.c | 2 ++ sound/firewire/dice/dice.c | 21 ++++++++++++++++----- sound/firewire/dice/dice.h | 2 ++ 4 files changed, 22 insertions(+), 5 deletions(-)