@@ -115,7 +115,6 @@ struct snd_uart16550 {
115115 int irq ;
116116
117117 unsigned long base ;
118- struct resource * res_base ;
119118
120119 unsigned int speed ;
121120 unsigned int speed_base ;
@@ -323,8 +322,7 @@ static int snd_uart16550_detect(struct snd_uart16550 *uart)
323322 return - ENODEV ; /* Not configured */
324323 }
325324
326- uart -> res_base = request_region (io_base , 8 , "Serial MIDI" );
327- if (uart -> res_base == NULL ) {
325+ if (!devm_request_region (uart -> card -> dev , io_base , 8 , "Serial MIDI" )) {
328326 snd_printk (KERN_ERR "u16550: can't grab port 0x%lx\n" , io_base );
329327 return - EBUSY ;
330328 }
@@ -752,21 +750,6 @@ static const struct snd_rawmidi_ops snd_uart16550_input =
752750 .trigger = snd_uart16550_input_trigger ,
753751};
754752
755- static int snd_uart16550_free (struct snd_uart16550 * uart )
756- {
757- if (uart -> irq >= 0 )
758- free_irq (uart -> irq , uart );
759- release_and_free_resource (uart -> res_base );
760- kfree (uart );
761- return 0 ;
762- };
763-
764- static int snd_uart16550_dev_free (struct snd_device * device )
765- {
766- struct snd_uart16550 * uart = device -> device_data ;
767- return snd_uart16550_free (uart );
768- }
769-
770753static int snd_uart16550_create (struct snd_card * card ,
771754 unsigned long iobase ,
772755 int irq ,
@@ -776,14 +759,11 @@ static int snd_uart16550_create(struct snd_card *card,
776759 int droponfull ,
777760 struct snd_uart16550 * * ruart )
778761{
779- static const struct snd_device_ops ops = {
780- .dev_free = snd_uart16550_dev_free ,
781- };
782762 struct snd_uart16550 * uart ;
783763 int err ;
784764
785765
786- uart = kzalloc ( sizeof (* uart ), GFP_KERNEL );
766+ uart = devm_kzalloc ( card -> dev , sizeof (* uart ), GFP_KERNEL );
787767 if (!uart )
788768 return - ENOMEM ;
789769 uart -> adaptor = adaptor ;
@@ -796,13 +776,12 @@ static int snd_uart16550_create(struct snd_card *card,
796776 err = snd_uart16550_detect (uart );
797777 if (err <= 0 ) {
798778 printk (KERN_ERR "no UART detected at 0x%lx\n" , iobase );
799- snd_uart16550_free (uart );
800779 return - ENODEV ;
801780 }
802781
803782 if (irq >= 0 && irq != SNDRV_AUTO_IRQ ) {
804- if (request_irq ( irq , snd_uart16550_interrupt ,
805- 0 , "Serial MIDI" , uart )) {
783+ if (devm_request_irq ( card -> dev , irq , snd_uart16550_interrupt ,
784+ 0 , "Serial MIDI" , uart )) {
806785 snd_printk (KERN_WARNING
807786 "irq %d busy. Using Polling.\n" , irq );
808787 } else {
@@ -819,13 +798,6 @@ static int snd_uart16550_create(struct snd_card *card,
819798 timer_setup (& uart -> buffer_timer , snd_uart16550_buffer_timer , 0 );
820799 uart -> timer_running = 0 ;
821800
822- /* Register device */
823- err = snd_device_new (card , SNDRV_DEV_LOWLEVEL , uart , & ops );
824- if (err < 0 ) {
825- snd_uart16550_free (uart );
826- return err ;
827- }
828-
829801 switch (uart -> adaptor ) {
830802 case SNDRV_SERIAL_MS124W_SA :
831803 case SNDRV_SERIAL_MS124W_MB :
@@ -927,8 +899,8 @@ static int snd_serial_probe(struct platform_device *devptr)
927899 return - ENODEV ;
928900 }
929901
930- err = snd_card_new (& devptr -> dev , index [dev ], id [dev ], THIS_MODULE ,
931- 0 , & card );
902+ err = snd_devm_card_new (& devptr -> dev , index [dev ], id [dev ], THIS_MODULE ,
903+ 0 , & card );
932904 if (err < 0 )
933905 return err ;
934906
@@ -939,11 +911,11 @@ static int snd_serial_probe(struct platform_device *devptr)
939911 base [dev ], adaptor [dev ], droponfull [dev ],
940912 & uart );
941913 if (err < 0 )
942- goto _err ;
914+ return err ;
943915
944916 err = snd_uart16550_rmidi (uart , 0 , outs [dev ], ins [dev ], & uart -> rmidi );
945917 if (err < 0 )
946- goto _err ;
918+ return err ;
947919
948920 sprintf (card -> longname , "%s [%s] at %#lx, irq %d" ,
949921 card -> shortname ,
@@ -953,27 +925,16 @@ static int snd_serial_probe(struct platform_device *devptr)
953925
954926 err = snd_card_register (card );
955927 if (err < 0 )
956- goto _err ;
928+ return err ;
957929
958930 platform_set_drvdata (devptr , card );
959931 return 0 ;
960-
961- _err :
962- snd_card_free (card );
963- return err ;
964- }
965-
966- static int snd_serial_remove (struct platform_device * devptr )
967- {
968- snd_card_free (platform_get_drvdata (devptr ));
969- return 0 ;
970932}
971933
972934#define SND_SERIAL_DRIVER "snd_serial_u16550"
973935
974936static struct platform_driver snd_serial_driver = {
975937 .probe = snd_serial_probe ,
976- .remove = snd_serial_remove ,
977938 .driver = {
978939 .name = SND_SERIAL_DRIVER ,
979940 },
0 commit comments