1
1
// SPDX-License-Identifier: GPL-2.0-only
2
2
// Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
3
3
4
+ #include <linux/cleanup.h>
4
5
#include <linux/module.h>
5
6
#include <linux/init.h>
6
7
#include <linux/io.h>
@@ -2725,8 +2726,6 @@ static const struct snd_soc_component_driver wsa_macro_component_drv = {
2725
2726
static int wsa_macro_probe (struct platform_device * pdev )
2726
2727
{
2727
2728
struct device * dev = & pdev -> dev ;
2728
- struct reg_default * reg_defaults ;
2729
- struct regmap_config * reg_config ;
2730
2729
struct wsa_macro * wsa ;
2731
2730
kernel_ulong_t flags ;
2732
2731
void __iomem * base ;
@@ -2765,6 +2764,8 @@ static int wsa_macro_probe(struct platform_device *pdev)
2765
2764
return PTR_ERR (base );
2766
2765
2767
2766
wsa -> codec_version = lpass_macro_get_codec_version ();
2767
+ struct reg_default * reg_defaults __free (kfree ) = NULL ;
2768
+
2768
2769
switch (wsa -> codec_version ) {
2769
2770
case LPASS_CODEC_VERSION_1_0 :
2770
2771
case LPASS_CODEC_VERSION_1_1 :
@@ -2773,9 +2774,8 @@ static int wsa_macro_probe(struct platform_device *pdev)
2773
2774
case LPASS_CODEC_VERSION_2_1 :
2774
2775
wsa -> reg_layout = & wsa_codec_v2_1 ;
2775
2776
def_count = ARRAY_SIZE (wsa_defaults ) + ARRAY_SIZE (wsa_defaults_v2_1 );
2776
- reg_defaults = devm_kmalloc_array (dev , def_count ,
2777
- sizeof (* reg_defaults ),
2778
- GFP_KERNEL );
2777
+ reg_defaults = kmalloc_array (def_count , sizeof (* reg_defaults ),
2778
+ GFP_KERNEL );
2779
2779
if (!reg_defaults )
2780
2780
return - ENOMEM ;
2781
2781
memcpy (& reg_defaults [0 ], wsa_defaults , sizeof (wsa_defaults ));
@@ -2789,9 +2789,8 @@ static int wsa_macro_probe(struct platform_device *pdev)
2789
2789
case LPASS_CODEC_VERSION_2_8 :
2790
2790
wsa -> reg_layout = & wsa_codec_v2_5 ;
2791
2791
def_count = ARRAY_SIZE (wsa_defaults ) + ARRAY_SIZE (wsa_defaults_v2_5 );
2792
- reg_defaults = devm_kmalloc_array (dev , def_count ,
2793
- sizeof (* reg_defaults ),
2794
- GFP_KERNEL );
2792
+ reg_defaults = kmalloc_array (def_count , sizeof (* reg_defaults ),
2793
+ GFP_KERNEL );
2795
2794
if (!reg_defaults )
2796
2795
return - ENOMEM ;
2797
2796
memcpy (& reg_defaults [0 ], wsa_defaults , sizeof (wsa_defaults ));
@@ -2804,8 +2803,9 @@ static int wsa_macro_probe(struct platform_device *pdev)
2804
2803
return - EINVAL ;
2805
2804
}
2806
2805
2807
- reg_config = devm_kmemdup (dev , & wsa_regmap_config ,
2808
- sizeof (* reg_config ), GFP_KERNEL );
2806
+ struct regmap_config * reg_config __free (kfree ) = kmemdup (& wsa_regmap_config ,
2807
+ sizeof (* reg_config ),
2808
+ GFP_KERNEL );
2809
2809
if (!reg_config )
2810
2810
return - ENOMEM ;
2811
2811
@@ -2816,8 +2816,6 @@ static int wsa_macro_probe(struct platform_device *pdev)
2816
2816
if (IS_ERR (wsa -> regmap ))
2817
2817
return PTR_ERR (wsa -> regmap );
2818
2818
2819
- devm_kfree (dev , reg_config );
2820
- devm_kfree (dev , reg_defaults );
2821
2819
dev_set_drvdata (dev , wsa );
2822
2820
2823
2821
wsa -> dev = dev ;
0 commit comments