drm/panel-edp: Add STA 116QHD024002
[drm/drm-misc.git] / include / kunit / device.h
blob2450110ad64ead520a6c3dee974053c8cb22e180
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * KUnit basic device implementation
5 * Helpers for creating and managing fake devices for KUnit tests.
7 * Copyright (C) 2023, Google LLC.
8 * Author: David Gow <davidgow@google.com>
9 */
11 #ifndef _KUNIT_DEVICE_H
12 #define _KUNIT_DEVICE_H
14 #if IS_ENABLED(CONFIG_KUNIT)
16 #include <kunit/test.h>
18 struct device;
19 struct device_driver;
21 /**
22 * kunit_driver_create() - Create a struct device_driver attached to the kunit_bus
23 * @test: The test context object.
24 * @name: The name to give the created driver.
26 * Creates a struct device_driver attached to the kunit_bus, with the name @name.
27 * This driver will automatically be cleaned up on test exit.
29 * Return: a stub struct device_driver, managed by KUnit, with the name @name.
31 struct device_driver *kunit_driver_create(struct kunit *test, const char *name);
33 /**
34 * kunit_device_register() - Create a struct device for use in KUnit tests
35 * @test: The test context object.
36 * @name: The name to give the created device.
38 * Creates a struct kunit_device (which is a struct device) with the given name,
39 * and a corresponding driver. The device and driver will be cleaned up on test
40 * exit, or when kunit_device_unregister is called. See also
41 * kunit_device_register_with_driver, if you wish to provide your own
42 * struct device_driver.
44 * Return: a pointer to a struct device which will be cleaned up when the test
45 * exits, or an error pointer if the device could not be allocated or registered.
47 struct device *kunit_device_register(struct kunit *test, const char *name);
49 /**
50 * kunit_device_register_with_driver() - Create a struct device for use in KUnit tests
51 * @test: The test context object.
52 * @name: The name to give the created device.
53 * @drv: The struct device_driver to associate with the device.
55 * Creates a struct kunit_device (which is a struct device) with the given
56 * name, and driver. The device will be cleaned up on test exit, or when
57 * kunit_device_unregister is called. See also kunit_device_register, if you
58 * wish KUnit to create and manage a driver for you.
60 * Return: a pointer to a struct device which will be cleaned up when the test
61 * exits, or an error pointer if the device could not be allocated or registered.
63 struct device *kunit_device_register_with_driver(struct kunit *test,
64 const char *name,
65 const struct device_driver *drv);
67 /**
68 * kunit_device_unregister() - Unregister a KUnit-managed device
69 * @test: The test context object which created the device
70 * @dev: The device.
72 * Unregisters and destroys a struct device which was created with
73 * kunit_device_register or kunit_device_register_with_driver. If KUnit created
74 * a driver, cleans it up as well.
76 void kunit_device_unregister(struct kunit *test, struct device *dev);
78 #endif
80 #endif