diff options
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/rawmidi.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index be18162c380f..932396c81035 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c | |||
@@ -1443,6 +1443,11 @@ static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi, | |||
1443 | return 0; | 1443 | return 0; |
1444 | } | 1444 | } |
1445 | 1445 | ||
1446 | static void release_rawmidi_device(struct device *dev) | ||
1447 | { | ||
1448 | kfree(container_of(dev, struct snd_rawmidi, dev)); | ||
1449 | } | ||
1450 | |||
1446 | /** | 1451 | /** |
1447 | * snd_rawmidi_new - create a rawmidi instance | 1452 | * snd_rawmidi_new - create a rawmidi instance |
1448 | * @card: the card instance | 1453 | * @card: the card instance |
@@ -1487,6 +1492,11 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, | |||
1487 | 1492 | ||
1488 | if (id != NULL) | 1493 | if (id != NULL) |
1489 | strlcpy(rmidi->id, id, sizeof(rmidi->id)); | 1494 | strlcpy(rmidi->id, id, sizeof(rmidi->id)); |
1495 | |||
1496 | snd_device_initialize(&rmidi->dev, card); | ||
1497 | rmidi->dev.release = release_rawmidi_device; | ||
1498 | dev_set_name(&rmidi->dev, "midiC%iD%i", card->number, device); | ||
1499 | |||
1490 | if ((err = snd_rawmidi_alloc_substreams(rmidi, | 1500 | if ((err = snd_rawmidi_alloc_substreams(rmidi, |
1491 | &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT], | 1501 | &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT], |
1492 | SNDRV_RAWMIDI_STREAM_INPUT, | 1502 | SNDRV_RAWMIDI_STREAM_INPUT, |
@@ -1538,7 +1548,7 @@ static int snd_rawmidi_free(struct snd_rawmidi *rmidi) | |||
1538 | snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]); | 1548 | snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]); |
1539 | if (rmidi->private_free) | 1549 | if (rmidi->private_free) |
1540 | rmidi->private_free(rmidi); | 1550 | rmidi->private_free(rmidi); |
1541 | kfree(rmidi); | 1551 | put_device(&rmidi->dev); |
1542 | return 0; | 1552 | return 0; |
1543 | } | 1553 | } |
1544 | 1554 | ||
@@ -1571,12 +1581,12 @@ static int snd_rawmidi_dev_register(struct snd_device *device) | |||
1571 | return -EBUSY; | 1581 | return -EBUSY; |
1572 | } | 1582 | } |
1573 | list_add_tail(&rmidi->list, &snd_rawmidi_devices); | 1583 | list_add_tail(&rmidi->list, &snd_rawmidi_devices); |
1574 | sprintf(name, "midiC%iD%i", rmidi->card->number, rmidi->device); | 1584 | err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_RAWMIDI, |
1575 | if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, | 1585 | rmidi->card, rmidi->device, |
1576 | rmidi->card, rmidi->device, | 1586 | &snd_rawmidi_f_ops, rmidi, |
1577 | &snd_rawmidi_f_ops, rmidi, name)) < 0) { | 1587 | &rmidi->dev, NULL, NULL); |
1578 | rmidi_err(rmidi, "unable to register rawmidi device %i:%i\n", | 1588 | if (err < 0) { |
1579 | rmidi->card->number, rmidi->device); | 1589 | rmidi_err(rmidi, "unable to register\n"); |
1580 | list_del(&rmidi->list); | 1590 | list_del(&rmidi->list); |
1581 | mutex_unlock(®ister_mutex); | 1591 | mutex_unlock(®ister_mutex); |
1582 | return err; | 1592 | return err; |