@@ -115,7 +115,6 @@ struct snd_uart16550 {
115
115
int irq ;
116
116
117
117
unsigned long base ;
118
- struct resource * res_base ;
119
118
120
119
unsigned int speed ;
121
120
unsigned int speed_base ;
@@ -323,8 +322,7 @@ static int snd_uart16550_detect(struct snd_uart16550 *uart)
323
322
return - ENODEV ; /* Not configured */
324
323
}
325
324
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" )) {
328
326
snd_printk (KERN_ERR "u16550: can't grab port 0x%lx\n" , io_base );
329
327
return - EBUSY ;
330
328
}
@@ -752,21 +750,6 @@ static const struct snd_rawmidi_ops snd_uart16550_input =
752
750
.trigger = snd_uart16550_input_trigger ,
753
751
};
754
752
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
-
770
753
static int snd_uart16550_create (struct snd_card * card ,
771
754
unsigned long iobase ,
772
755
int irq ,
@@ -776,14 +759,11 @@ static int snd_uart16550_create(struct snd_card *card,
776
759
int droponfull ,
777
760
struct snd_uart16550 * * ruart )
778
761
{
779
- static const struct snd_device_ops ops = {
780
- .dev_free = snd_uart16550_dev_free ,
781
- };
782
762
struct snd_uart16550 * uart ;
783
763
int err ;
784
764
785
765
786
- uart = kzalloc ( sizeof (* uart ), GFP_KERNEL );
766
+ uart = devm_kzalloc ( card -> dev , sizeof (* uart ), GFP_KERNEL );
787
767
if (!uart )
788
768
return - ENOMEM ;
789
769
uart -> adaptor = adaptor ;
@@ -796,13 +776,12 @@ static int snd_uart16550_create(struct snd_card *card,
796
776
err = snd_uart16550_detect (uart );
797
777
if (err <= 0 ) {
798
778
printk (KERN_ERR "no UART detected at 0x%lx\n" , iobase );
799
- snd_uart16550_free (uart );
800
779
return - ENODEV ;
801
780
}
802
781
803
782
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 )) {
806
785
snd_printk (KERN_WARNING
807
786
"irq %d busy. Using Polling.\n" , irq );
808
787
} else {
@@ -819,13 +798,6 @@ static int snd_uart16550_create(struct snd_card *card,
819
798
timer_setup (& uart -> buffer_timer , snd_uart16550_buffer_timer , 0 );
820
799
uart -> timer_running = 0 ;
821
800
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
-
829
801
switch (uart -> adaptor ) {
830
802
case SNDRV_SERIAL_MS124W_SA :
831
803
case SNDRV_SERIAL_MS124W_MB :
@@ -927,8 +899,8 @@ static int snd_serial_probe(struct platform_device *devptr)
927
899
return - ENODEV ;
928
900
}
929
901
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 );
932
904
if (err < 0 )
933
905
return err ;
934
906
@@ -939,11 +911,11 @@ static int snd_serial_probe(struct platform_device *devptr)
939
911
base [dev ], adaptor [dev ], droponfull [dev ],
940
912
& uart );
941
913
if (err < 0 )
942
- goto _err ;
914
+ return err ;
943
915
944
916
err = snd_uart16550_rmidi (uart , 0 , outs [dev ], ins [dev ], & uart -> rmidi );
945
917
if (err < 0 )
946
- goto _err ;
918
+ return err ;
947
919
948
920
sprintf (card -> longname , "%s [%s] at %#lx, irq %d" ,
949
921
card -> shortname ,
@@ -953,27 +925,16 @@ static int snd_serial_probe(struct platform_device *devptr)
953
925
954
926
err = snd_card_register (card );
955
927
if (err < 0 )
956
- goto _err ;
928
+ return err ;
957
929
958
930
platform_set_drvdata (devptr , card );
959
931
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 ;
970
932
}
971
933
972
934
#define SND_SERIAL_DRIVER "snd_serial_u16550"
973
935
974
936
static struct platform_driver snd_serial_driver = {
975
937
.probe = snd_serial_probe ,
976
- .remove = snd_serial_remove ,
977
938
.driver = {
978
939
.name = SND_SERIAL_DRIVER ,
979
940
},
0 commit comments