8
8
* Author: Dong Aisheng <[email protected] >
9
9
*/
10
10
11
+ #include <linux/cleanup.h>
11
12
#include <linux/clk.h>
12
13
#include <linux/err.h>
13
14
#include <linux/hwspinlock.h>
@@ -45,7 +46,6 @@ static const struct regmap_config syscon_regmap_config = {
45
46
static struct syscon * of_syscon_register (struct device_node * np , bool check_res )
46
47
{
47
48
struct clk * clk ;
48
- struct syscon * syscon ;
49
49
struct regmap * regmap ;
50
50
void __iomem * base ;
51
51
u32 reg_io_width ;
@@ -54,20 +54,16 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
54
54
struct resource res ;
55
55
struct reset_control * reset ;
56
56
57
- syscon = kzalloc (sizeof (* syscon ), GFP_KERNEL );
57
+ struct syscon * syscon __free ( kfree ) = kzalloc (sizeof (* syscon ), GFP_KERNEL );
58
58
if (!syscon )
59
59
return ERR_PTR (- ENOMEM );
60
60
61
- if (of_address_to_resource (np , 0 , & res )) {
62
- ret = - ENOMEM ;
63
- goto err_map ;
64
- }
61
+ if (of_address_to_resource (np , 0 , & res ))
62
+ return ERR_PTR (- ENOMEM );
65
63
66
64
base = of_iomap (np , 0 );
67
- if (!base ) {
68
- ret = - ENOMEM ;
69
- goto err_map ;
70
- }
65
+ if (!base )
66
+ return ERR_PTR (- ENOMEM );
71
67
72
68
/* Parse the device's DT node for an endianness specification */
73
69
if (of_property_read_bool (np , "big-endian" ))
@@ -152,7 +148,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
152
148
list_add_tail (& syscon -> list , & syscon_list );
153
149
spin_unlock (& syscon_list_slock );
154
150
155
- return syscon ;
151
+ return_ptr ( syscon ) ;
156
152
157
153
err_reset :
158
154
reset_control_put (reset );
@@ -163,8 +159,6 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
163
159
regmap_exit (regmap );
164
160
err_regmap :
165
161
iounmap (base );
166
- err_map :
167
- kfree (syscon );
168
162
return ERR_PTR (ret );
169
163
}
170
164
0 commit comments