From: Dan Carpenter Date: Fri, 3 Oct 2025 09:29:31 +0000 (+0300) Subject: PM: runtime: Fix error checking for kunit_device_register() X-Git-Tag: v6.18-rc1~49^2~1^3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=92158fae2ed986f44347fc5b9a269830862c1529;p=thirdparty%2Fkernel%2Flinux.git PM: runtime: Fix error checking for kunit_device_register() The kunit_device_register() function never returns NULL, it returns error pointers. Update the assertions to use KUNIT_ASSERT_NOT_ERR_OR_NULL() instead of checking for NULL. Fixes: 7f7acd193ba8 ("PM: runtime: Add basic kunit tests for API contracts") Signed-off-by: Dan Carpenter Reviewed-by: Brian Norris Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/base/power/runtime-test.c b/drivers/base/power/runtime-test.c index eca9885e807d..477feca804c7 100644 --- a/drivers/base/power/runtime-test.c +++ b/drivers/base/power/runtime-test.c @@ -14,7 +14,7 @@ static void pm_runtime_depth_test(struct kunit *test) { struct device *dev = kunit_device_register(test, DEVICE_NAME); - KUNIT_ASSERT_PTR_NE(test, NULL, dev); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); pm_runtime_enable(dev); @@ -32,7 +32,7 @@ static void pm_runtime_already_suspended_test(struct kunit *test) { struct device *dev = kunit_device_register(test, DEVICE_NAME); - KUNIT_ASSERT_PTR_NE(test, NULL, dev); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); pm_runtime_enable(dev); KUNIT_EXPECT_TRUE(test, pm_runtime_suspended(dev)); @@ -70,7 +70,7 @@ static void pm_runtime_idle_test(struct kunit *test) { struct device *dev = kunit_device_register(test, DEVICE_NAME); - KUNIT_ASSERT_PTR_NE(test, NULL, dev); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); pm_runtime_enable(dev); @@ -91,7 +91,7 @@ static void pm_runtime_disabled_test(struct kunit *test) { struct device *dev = kunit_device_register(test, DEVICE_NAME); - KUNIT_ASSERT_PTR_NE(test, NULL, dev); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); /* Never called pm_runtime_enable() */ KUNIT_EXPECT_FALSE(test, pm_runtime_enabled(dev)); @@ -131,7 +131,7 @@ static void pm_runtime_error_test(struct kunit *test) { struct device *dev = kunit_device_register(test, DEVICE_NAME); - KUNIT_ASSERT_PTR_NE(test, NULL, dev); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); pm_runtime_enable(dev); KUNIT_EXPECT_TRUE(test, pm_runtime_suspended(dev)); @@ -214,7 +214,7 @@ static void pm_runtime_probe_active_test(struct kunit *test) { struct device *dev = kunit_device_register(test, DEVICE_NAME); - KUNIT_ASSERT_PTR_NE(test, NULL, dev); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); KUNIT_EXPECT_TRUE(test, pm_runtime_status_suspended(dev));