mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
gpu: nvgpu: unit: add unit_assert helper
Add unit_assert helper to check condition. In case of failure, the macro reports failed condition as well as line number, then runs bail out code. Jira NVGPU-3476 Change-Id: I9971e7fa0337661d46a06dfa05b67a98e3c46eee Signed-off-by: Thomas Fleury <tfleury@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2129675 GVS: Gerrit_Virtual_Submit Reviewed-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
eb380fcbdb
commit
04cf2f1ba6
@@ -60,6 +60,21 @@ struct unit_module;
|
|||||||
#define unit_err(unit, msg, ...) \
|
#define unit_err(unit, msg, ...) \
|
||||||
__unit_info_color(unit, C_RED, msg, ##__VA_ARGS__)
|
__unit_info_color(unit, C_RED, msg, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* helper to check a condition, output and error if condition is false
|
||||||
|
* and execute bail_out_code
|
||||||
|
*/
|
||||||
|
#define unit_assert(cond, bail_out_code) \
|
||||||
|
do { \
|
||||||
|
if (!(cond)) { \
|
||||||
|
unit_err(m, "%s:%d (" #cond ") is false\n", \
|
||||||
|
__func__, __LINE__); \
|
||||||
|
bail_out_code; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't go overboard with these!!!
|
* Don't go overboard with these!!!
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -55,11 +55,7 @@
|
|||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct test_tsg_args {
|
#define assert(cond) unit_assert(cond, goto done)
|
||||||
bool init_done;
|
|
||||||
struct nvgpu_tsg *tsg;
|
|
||||||
struct nvgpu_channel *ch;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct test_tsg_args test_args = {
|
struct test_tsg_args test_args = {
|
||||||
.init_done = false,
|
.init_done = false,
|
||||||
|
|||||||
Reference in New Issue
Block a user