Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

of: resolver: Simplify of_resolve_phandles() using __free()

Use the __free() cleanup to simplify of_resolve_phandles() and remove
all the goto's.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>

+11 -23
+11 -23
drivers/of/resolver.c
··· 250 250 int of_resolve_phandles(struct device_node *overlay) 251 251 { 252 252 struct device_node *child, *local_fixups, *refnode; 253 - struct device_node *tree_symbols, *overlay_fixups; 253 + struct device_node *overlay_fixups; 254 254 struct property *prop; 255 255 const char *refpath; 256 256 phandle phandle, phandle_delta; 257 257 int err; 258 258 259 - tree_symbols = NULL; 260 - 261 259 if (!overlay) { 262 260 pr_err("null overlay\n"); 263 - err = -EINVAL; 264 - goto out; 261 + return -EINVAL; 265 262 } 266 263 267 264 if (!of_node_check_flag(overlay, OF_DETACHED)) { 268 265 pr_err("overlay not detached\n"); 269 - err = -EINVAL; 270 - goto out; 266 + return -EINVAL; 271 267 } 272 268 273 269 phandle_delta = live_tree_max_phandle() + 1; ··· 275 279 276 280 err = adjust_local_phandle_references(local_fixups, overlay, phandle_delta); 277 281 if (err) 278 - goto out; 282 + return err; 279 283 280 284 overlay_fixups = NULL; 281 285 ··· 284 288 overlay_fixups = child; 285 289 } 286 290 287 - if (!overlay_fixups) { 288 - err = 0; 289 - goto out; 290 - } 291 + if (!overlay_fixups) 292 + return 0; 291 293 292 - tree_symbols = of_find_node_by_path("/__symbols__"); 294 + struct device_node __free(device_node) *tree_symbols = of_find_node_by_path("/__symbols__"); 293 295 if (!tree_symbols) { 294 296 pr_err("no symbols in root of device tree.\n"); 295 - err = -EINVAL; 296 - goto out; 297 + return -EINVAL; 297 298 } 298 299 299 300 for_each_property_of_node(overlay_fixups, prop) { ··· 304 311 if (err) { 305 312 pr_err("node label '%s' not found in live devicetree symbols table\n", 306 313 prop->name); 307 - goto out; 314 + return err; 308 315 } 309 316 310 317 refnode = of_find_node_by_path(refpath); 311 - if (!refnode) { 312 - err = -ENOENT; 313 - goto out; 314 - } 318 + if (!refnode) 319 + return -ENOENT; 315 320 316 321 phandle = refnode->phandle; 317 322 of_node_put(refnode); ··· 319 328 break; 320 329 } 321 330 322 - out: 323 331 if (err) 324 332 pr_err("overlay phandle fixup failed: %d\n", err); 325 - of_node_put(tree_symbols); 326 - 327 333 return err; 328 334 } 329 335 EXPORT_SYMBOL_GPL(of_resolve_phandles);