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.

cdx: Use mutex guard to simplify error handling

Mutex guard allows to drop one goto/break in error handling and the
less expected code of assigning -EINVAL to unsigned size_t count
variable.

Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Link: https://patch.msgid.link/20260109-of-for-each-compatible-scoped-v3-7-c22fa2c0749a@oss.qualcomm.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Rob Herring (Arm)
3bf312f3 2ff81fe3

+3 -8
+3 -8
drivers/cdx/cdx.c
··· 616 616 if (!val) 617 617 return -EINVAL; 618 618 619 - mutex_lock(&cdx_controller_lock); 619 + guard(mutex)(&cdx_controller_lock); 620 620 621 621 /* Unregister all the devices on the bus */ 622 622 cdx_unregister_devices(&cdx_bus_type); ··· 624 624 /* Rescan all the devices */ 625 625 for_each_compatible_node_scoped(np, NULL, compat_node_name) { 626 626 pd = of_find_device_by_node(np); 627 - if (!pd) { 628 - count = -EINVAL; 629 - goto unlock; 630 - } 627 + if (!pd) 628 + return -EINVAL; 631 629 632 630 cdx = platform_get_drvdata(pd); 633 631 if (cdx && cdx->controller_registered && cdx->ops->scan) ··· 633 635 634 636 put_device(&pd->dev); 635 637 } 636 - 637 - unlock: 638 - mutex_unlock(&cdx_controller_lock); 639 638 640 639 return count; 641 640 }