aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/drivers/serial-u16550.c68
1 files changed, 45 insertions, 23 deletions
diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c
index ec28587247f4..3381a43c592e 100644
--- a/sound/drivers/serial-u16550.c
+++ b/sound/drivers/serial-u16550.c
@@ -33,6 +33,8 @@
33#include <sound/driver.h> 33#include <sound/driver.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/err.h>
37#include <linux/platform_device.h>
36#include <linux/slab.h> 38#include <linux/slab.h>
37#include <linux/ioport.h> 39#include <linux/ioport.h>
38#include <linux/moduleparam.h> 40#include <linux/moduleparam.h>
@@ -166,8 +168,6 @@ typedef struct _snd_uart16550 {
166 168
167} snd_uart16550_t; 169} snd_uart16550_t;
168 170
169static struct snd_card *snd_serial_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
170
171static inline void snd_uart16550_add_timer(snd_uart16550_t *uart) 171static inline void snd_uart16550_add_timer(snd_uart16550_t *uart)
172{ 172{
173 if (! uart->timer_running) { 173 if (! uart->timer_running) {
@@ -869,14 +869,12 @@ static int __init snd_uart16550_rmidi(snd_uart16550_t *uart, int device, int out
869 return 0; 869 return 0;
870} 870}
871 871
872static int __init snd_serial_probe(int dev) 872static int __init snd_serial_probe(struct platform_device *devptr)
873{ 873{
874 struct snd_card *card; 874 struct snd_card *card;
875 snd_uart16550_t *uart; 875 snd_uart16550_t *uart;
876 int err; 876 int err;
877 877 int dev = devptr->id;
878 if (!enable[dev])
879 return -ENOENT;
880 878
881 switch (adaptor[dev]) { 879 switch (adaptor[dev]) {
882 case SNDRV_SERIAL_SOUNDCANVAS: 880 case SNDRV_SERIAL_SOUNDCANVAS:
@@ -942,13 +940,12 @@ static int __init snd_serial_probe(int dev)
942 adaptor_names[uart->adaptor], 940 adaptor_names[uart->adaptor],
943 uart->drop_on_full); 941 uart->drop_on_full);
944 942
945 if ((err = snd_card_set_generic_dev(card)) < 0) 943 snd_card_set_dev(card, &devptr->dev);
946 goto _err;
947 944
948 if ((err = snd_card_register(card)) < 0) 945 if ((err = snd_card_register(card)) < 0)
949 goto _err; 946 goto _err;
950 947
951 snd_serial_cards[dev] = card; 948 platform_set_drvdata(devptr, card);
952 return 0; 949 return 0;
953 950
954 _err: 951 _err:
@@ -956,33 +953,58 @@ static int __init snd_serial_probe(int dev)
956 return err; 953 return err;
957} 954}
958 955
956static int snd_serial_remove(struct platform_device *devptr)
957{
958 snd_card_free(platform_get_drvdata(devptr));
959 platform_set_drvdata(devptr, NULL);
960 return 0;
961}
962
963#define SND_SERIAL_DRIVER "snd_serial_u16550"
964
965static struct platform_driver snd_serial_driver = {
966 .probe = snd_serial_probe,
967 .remove = snd_serial_remove,
968 .driver = {
969 .name = SND_SERIAL_DRIVER
970 },
971};
972
959static int __init alsa_card_serial_init(void) 973static int __init alsa_card_serial_init(void)
960{ 974{
961 int dev = 0; 975 int i, cards, err;
962 int cards = 0;
963 976
964 for (dev = 0; dev < SNDRV_CARDS; dev++) { 977 if ((err = platform_driver_register(&snd_serial_driver)) < 0)
965 if (snd_serial_probe(dev) == 0) 978 return err;
966 cards++;
967 }
968 979
969 if (cards == 0) { 980 cards = 0;
981 for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
982 struct platform_device *device;
983 device = platform_device_register_simple(SND_SERIAL_DRIVER,
984 i, NULL, 0);
985 if (IS_ERR(device)) {
986 err = PTR_ERR(device);
987 goto errout;
988 }
989 cards++;
990 }
991 if (! cards) {
970#ifdef MODULE 992#ifdef MODULE
971 printk(KERN_ERR "serial midi soundcard not found or device busy\n"); 993 printk(KERN_ERR "serial midi soundcard not found or device busy\n");
972#endif 994#endif
973 return -ENODEV; 995 err = -ENODEV;
996 goto errout;
974 } 997 }
975 return 0; 998 return 0;
999
1000 errout:
1001 platform_driver_unregister(&snd_serial_driver);
1002 return err;
976} 1003}
977 1004
978static void __exit alsa_card_serial_exit(void) 1005static void __exit alsa_card_serial_exit(void)
979{ 1006{
980 int dev; 1007 platform_driver_unregister(&snd_serial_driver);
981
982 for (dev = 0; dev < SNDRV_CARDS; dev++) {
983 if (snd_serial_cards[dev] != NULL)
984 snd_card_free(snd_serial_cards[dev]);
985 }
986} 1008}
987 1009
988module_init(alsa_card_serial_init) 1010module_init(alsa_card_serial_init)