summaryrefslogtreecommitdiffstats
path: root/drivers/fpga/tests/fpga-mgr-test.c
diff options
context:
space:
mode:
authorMarco Pagani <marpagan@redhat.com>2024-03-29 18:48:47 +0100
committerXu Yilun <yilun.xu@linux.intel.com>2024-04-09 12:13:15 +0800
commit4d2bc3f7dea4d17243924c6758e0447cc1aa0eea (patch)
tree1329e7a09641bbd0e81b5ab70dc3ba0bee5c1870 /drivers/fpga/tests/fpga-mgr-test.c
parentf6c86fdf3716c9257612f8f001c6e95db84fb844 (diff)
downloadlinux-4d2bc3f7dea4d17243924c6758e0447cc1aa0eea.tar.gz
linux-4d2bc3f7dea4d17243924c6758e0447cc1aa0eea.tar.bz2
linux-4d2bc3f7dea4d17243924c6758e0447cc1aa0eea.zip
fpga: tests: use KUnit devices instead of platform devices
KUnit now provides helper functions to create fake devices, so use them instead of relying on platform devices. Other changes: remove an unnecessary white space in the fpga region suite. Reviewed-by: Russ Weight <russ.weight@linux.dev> Signed-off-by: Marco Pagani <marpagan@redhat.com> Acked-by: Xu Yilun <yilun.xu@intel.com> Link: https://lore.kernel.org/r/20240329174849.248243-1-marpagan@redhat.com Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>
Diffstat (limited to 'drivers/fpga/tests/fpga-mgr-test.c')
-rw-r--r--drivers/fpga/tests/fpga-mgr-test.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/fpga/tests/fpga-mgr-test.c b/drivers/fpga/tests/fpga-mgr-test.c
index 6acec55b60ce..125b3a4d43c6 100644
--- a/drivers/fpga/tests/fpga-mgr-test.c
+++ b/drivers/fpga/tests/fpga-mgr-test.c
@@ -7,8 +7,8 @@
* Author: Marco Pagani <marpagan@redhat.com>
*/
+#include <kunit/device.h>
#include <kunit/test.h>
-#include <linux/device.h>
#include <linux/fpga/fpga-mgr.h>
#include <linux/module.h>
#include <linux/scatterlist.h>
@@ -40,7 +40,7 @@ struct mgr_stats {
struct mgr_ctx {
struct fpga_image_info *img_info;
struct fpga_manager *mgr;
- struct platform_device *pdev;
+ struct device *dev;
struct mgr_stats stats;
};
@@ -194,7 +194,7 @@ static void fpga_mgr_test_get(struct kunit *test)
struct mgr_ctx *ctx = test->priv;
struct fpga_manager *mgr;
- mgr = fpga_mgr_get(&ctx->pdev->dev);
+ mgr = fpga_mgr_get(ctx->dev);
KUNIT_EXPECT_PTR_EQ(test, mgr, ctx->mgr);
fpga_mgr_put(ctx->mgr);
@@ -284,14 +284,14 @@ static int fpga_mgr_test_init(struct kunit *test)
ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
- ctx->pdev = platform_device_register_simple("mgr_pdev", PLATFORM_DEVID_AUTO, NULL, 0);
- KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->pdev);
+ ctx->dev = kunit_device_register(test, "fpga-manager-test-dev");
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->dev);
- ctx->mgr = devm_fpga_mgr_register(&ctx->pdev->dev, "Fake FPGA Manager", &fake_mgr_ops,
+ ctx->mgr = devm_fpga_mgr_register(ctx->dev, "Fake FPGA Manager", &fake_mgr_ops,
&ctx->stats);
KUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(ctx->mgr));
- ctx->img_info = fpga_image_info_alloc(&ctx->pdev->dev);
+ ctx->img_info = fpga_image_info_alloc(ctx->dev);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->img_info);
test->priv = ctx;
@@ -304,7 +304,7 @@ static void fpga_mgr_test_exit(struct kunit *test)
struct mgr_ctx *ctx = test->priv;
fpga_image_info_free(ctx->img_info);
- platform_device_unregister(ctx->pdev);
+ kunit_device_unregister(test, ctx->dev);
}
static struct kunit_case fpga_mgr_test_cases[] = {