88 * Author: Dong Aisheng <[email protected] > 99 */
1010
11+ #include <linux/cleanup.h>
1112#include <linux/clk.h>
1213#include <linux/err.h>
1314#include <linux/hwspinlock.h>
@@ -45,7 +46,6 @@ static const struct regmap_config syscon_regmap_config = {
4546static struct syscon * of_syscon_register (struct device_node * np , bool check_res )
4647{
4748 struct clk * clk ;
48- struct syscon * syscon ;
4949 struct regmap * regmap ;
5050 void __iomem * base ;
5151 u32 reg_io_width ;
@@ -54,20 +54,16 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
5454 struct resource res ;
5555 struct reset_control * reset ;
5656
57- syscon = kzalloc (sizeof (* syscon ), GFP_KERNEL );
57+ struct syscon * syscon __free ( kfree ) = kzalloc (sizeof (* syscon ), GFP_KERNEL );
5858 if (!syscon )
5959 return ERR_PTR (- ENOMEM );
6060
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 );
6563
6664 base = of_iomap (np , 0 );
67- if (!base ) {
68- ret = - ENOMEM ;
69- goto err_map ;
70- }
65+ if (!base )
66+ return ERR_PTR (- ENOMEM );
7167
7268 /* Parse the device's DT node for an endianness specification */
7369 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)
152148 list_add_tail (& syscon -> list , & syscon_list );
153149 spin_unlock (& syscon_list_slock );
154150
155- return syscon ;
151+ return_ptr ( syscon ) ;
156152
157153err_reset :
158154 reset_control_put (reset );
@@ -163,8 +159,6 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
163159 regmap_exit (regmap );
164160err_regmap :
165161 iounmap (base );
166- err_map :
167- kfree (syscon );
168162 return ERR_PTR (ret );
169163}
170164
0 commit comments