diff options
-rw-r--r-- | 0001-faux_test-test-module-for-faux-driver-api.patch | 104 | ||||
-rw-r--r-- | series | 1 |
2 files changed, 105 insertions, 0 deletions
diff --git a/0001-faux_test-test-module-for-faux-driver-api.patch b/0001-faux_test-test-module-for-faux-driver-api.patch new file mode 100644 index 00000000000000..5764635f65edaa --- /dev/null +++ b/0001-faux_test-test-module-for-faux-driver-api.patch @@ -0,0 +1,104 @@ +From e83d3deb1f5aebc95537cd4c8ed009199a6bed27 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Tue, 4 Feb 2025 08:46:00 +0100 +Subject: [PATCH] faux_test: test module for faux driver api + +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + drivers/base/Makefile | 2 + + drivers/base/faux_test.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 83 insertions(+) + create mode 100644 drivers/base/faux_test.c + +--- a/drivers/base/Makefile ++++ b/drivers/base/Makefile +@@ -35,3 +35,5 @@ ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBU + # define_trace.h needs to know how to find our header + CFLAGS_trace.o := -I$(src) + obj-$(CONFIG_TRACING) += trace.o ++ ++obj-m += faux_test.o +--- /dev/null ++++ b/drivers/base/faux_test.c +@@ -0,0 +1,81 @@ ++#include <linux/module.h> ++#include <linux/device/faux.h> ++ ++static struct faux_device *fd1; ++static struct faux_device *fd2; ++static struct faux_device *fd3; ++ ++static int faux_probe(struct faux_device *faux_dev) ++{ ++ dev_info(&faux_dev->dev, "%s\n", __func__); ++ return 0; ++} ++ ++static void faux_remove(struct faux_device *faux_dev) ++{ ++ dev_info(&faux_dev->dev, "%s\n", __func__); ++} ++ ++static struct faux_device_ops faux_ops = { ++ .probe = faux_probe, ++ .remove = faux_remove, ++}; ++ ++static int faux_probe_fail(struct faux_device *faux_dev) ++{ ++ dev_info(&faux_dev->dev, "%s\n", __func__); ++ return -ENODEV; ++} ++ ++static struct faux_device_ops faux_ops_fail = { ++ .probe = faux_probe_fail, ++ .remove = faux_remove, ++}; ++ ++static int __init faux_test_init(void) ++{ ++ fd1 = faux_device_create("fd1", NULL, NULL); ++ if (!fd1) { ++ pr_err("%s: fd1 creation failed\n", __func__); ++ goto error_fd1; ++ } ++ ++ fd2 = faux_device_create("fd2", &fd1->dev, &faux_ops); ++ if (!fd2) { ++ pr_err("%s: fd2 creation failed\n", __func__); ++ goto error_fd2; ++ } ++ ++ fd3 = faux_device_create("fd3", &fd2->dev, &faux_ops); ++ if (!fd3) { ++ pr_err("%s: fd3 creation failed\n", __func__); ++ goto error_fd3; ++ } ++ ++ struct faux_device *fd_bad = faux_device_create("fd4", &fd2->dev, &faux_ops_fail); ++ if (fd_bad) { ++ pr_err("%s: fd_bad creation succeeded\n", __func__); ++ goto error_fd_bad; ++ } ++ ++ return 0; ++error_fd_bad: ++ faux_device_destroy(fd3); ++error_fd3: ++ faux_device_destroy(fd2); ++error_fd2: ++ faux_device_destroy(fd1); ++error_fd1: ++ return -ENODEV; ++} ++ ++static void faux_test_exit(void) ++{ ++ faux_device_destroy(fd3); ++ faux_device_destroy(fd2); ++ faux_device_destroy(fd1); ++} ++ ++module_init(faux_test_init); ++module_exit(faux_test_exit); ++MODULE_LICENSE("GPL"); @@ -1,4 +1,5 @@ # +0001-faux_test-test-module-for-faux-driver-api.patch container_of_const_switch.patch 0001-misc-convert-to-guards.patch 0001-USB-gadget-dummy_hcd-switch-char-to-u8.patch |