1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
8 #include <hwspinlock.h>
14 /* Test that hwspinlock driver functions are called */
15 static int dm_test_hwspinlock_base(struct unit_test_state *uts)
17 struct sandbox_state *state = state_get_current();
18 struct hwspinlock hws;
20 ut_assertok(uclass_get_device(UCLASS_HWSPINLOCK, 0, &hws.dev));
21 ut_assertnonnull(hws.dev);
22 ut_asserteq(false, state->hwspinlock);
25 ut_assertok(hwspinlock_lock_timeout(&hws, 1));
26 ut_asserteq(true, state->hwspinlock);
28 ut_assertok(hwspinlock_unlock(&hws));
29 ut_asserteq(false, state->hwspinlock);
31 ut_assertok(hwspinlock_lock_timeout(&hws, 1));
32 ut_assertok(!hwspinlock_lock_timeout(&hws, 1));
34 ut_assertok(hwspinlock_unlock(&hws));
35 ut_assertok(!hwspinlock_unlock(&hws));
40 DM_TEST(dm_test_hwspinlock_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);