]> www.infradead.org Git - users/jedix/linux-maple.git/commit
cleanup: Add conditional guard helper
authorDavid Lechner <dlechner@baylibre.com>
Tue, 1 Oct 2024 22:30:18 +0000 (17:30 -0500)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 25 Oct 2024 08:01:51 +0000 (10:01 +0200)
commit36c2cf88808d47e926d11b98734f154fe4a9f50f
tree0d2ecf68e8d6c112bebcb5a9ae7fc9e445312a5b
parentfcc22ac5baf06dd17193de44b60dbceea6461983
cleanup: Add conditional guard helper

Add a new if_not_guard() macro to cleanup.h for handling
conditional guards such as mutext_trylock().

This is more ergonomic than scoped_guard() for most use cases.
Instead of hiding the error handling statement in the macro args, it
works like a normal if statement and allow the error path to be indented
while the normal code flow path is not indented. And it avoid unwanted
side-effect from hidden for loop in scoped_guard().

Signed-off-by: David Lechner <dlechner@baylibre.com>
Co-developed-by: Fabio M. De Francesco <fabio.m.de.francesco@linux.intel.com>
Signed-off-by: Fabio M. De Francesco <fabio.m.de.francesco@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Link: https://lkml.kernel.org/r/20241001-cleanup-if_not_cond_guard-v1-1-7753810b0f7a@baylibre.com
include/linux/cleanup.h