11
11
// with code, comments and ideas from :-
12
12
// Richard Purdie <[email protected] >
13
13
14
+ #include <linux/cleanup.h>
14
15
#include <linux/module.h>
15
16
#include <linux/moduleparam.h>
16
17
#include <linux/init.h>
@@ -727,14 +728,14 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
727
728
struct soc_bytes * params = (void * )kcontrol -> private_value ;
728
729
int ret , len ;
729
730
unsigned int val , mask ;
730
- void * data ;
731
731
732
732
if (!component -> regmap || !params -> num_regs )
733
733
return - EINVAL ;
734
734
735
735
len = params -> num_regs * component -> val_bytes ;
736
736
737
- data = kmemdup (ucontrol -> value .bytes .data , len , GFP_KERNEL | GFP_DMA );
737
+ void * data __free (kfree ) = kmemdup (ucontrol -> value .bytes .data , len ,
738
+ GFP_KERNEL | GFP_DMA );
738
739
if (!data )
739
740
return - ENOMEM ;
740
741
@@ -746,7 +747,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
746
747
if (params -> mask ) {
747
748
ret = regmap_read (component -> regmap , params -> base , & val );
748
749
if (ret != 0 )
749
- goto out ;
750
+ return ret ;
750
751
751
752
val &= params -> mask ;
752
753
@@ -760,14 +761,14 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
760
761
ret = regmap_parse_val (component -> regmap ,
761
762
& mask , & mask );
762
763
if (ret != 0 )
763
- goto out ;
764
+ return ret ;
764
765
765
766
((u16 * )data )[0 ] &= mask ;
766
767
767
768
ret = regmap_parse_val (component -> regmap ,
768
769
& val , & val );
769
770
if (ret != 0 )
770
- goto out ;
771
+ return ret ;
771
772
772
773
((u16 * )data )[0 ] |= val ;
773
774
break ;
@@ -776,30 +777,23 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
776
777
ret = regmap_parse_val (component -> regmap ,
777
778
& mask , & mask );
778
779
if (ret != 0 )
779
- goto out ;
780
+ return ret ;
780
781
781
782
((u32 * )data )[0 ] &= mask ;
782
783
783
784
ret = regmap_parse_val (component -> regmap ,
784
785
& val , & val );
785
786
if (ret != 0 )
786
- goto out ;
787
+ return ret ;
787
788
788
789
((u32 * )data )[0 ] |= val ;
789
790
break ;
790
791
default :
791
- ret = - EINVAL ;
792
- goto out ;
792
+ return - EINVAL ;
793
793
}
794
794
}
795
795
796
- ret = regmap_raw_write (component -> regmap , params -> base ,
797
- data , len );
798
-
799
- out :
800
- kfree (data );
801
-
802
- return ret ;
796
+ return regmap_raw_write (component -> regmap , params -> base , data , len );
803
797
}
804
798
EXPORT_SYMBOL_GPL (snd_soc_bytes_put );
805
799
0 commit comments