Platform Device API
The KUnit platform device API is used to test platform devices.
kunit_platform_device_alloc() #
struct platform_device * Allocate a KUnit test managed platform device
Parameters
struct kunit *test: test contextconst char *name: device name of platform device to allocint id: identifier of platform device to alloc.
Description
Allocate a test managed platform device. The device is put when the test completes.
Return
Allocated platform device on success, NULL on failure.
kunit_platform_device_add() #
int Register a KUnit test managed platform device
Parameters
struct kunit *test: test contextstruct platform_device *pdev: platform device to add
Description
Register a test managed platform device. The device is unregistered when the test completes.
Return
0 on success, negative errno on failure.
kunit_platform_device_prepare_wait_for_probe() #
int Prepare a completion variable to wait for a platform device to probe
Parameters
struct kunit *test: test contextstruct platform_device *pdev: platform device to prepare to wait for probe ofstruct completion *x: completion variable completed when dev has probed
Description
Prepare a completion variable x to wait for pdev to probe. Waiting on the completion forces a preemption, allowing the platform driver to probe.
Example
static int
static void
Return
0 on success, negative errno on failure.
kunit_platform_driver_register() #
int Register a KUnit test managed platform driver
Parameters
struct kunit *test: test contextstruct platform_driver *drv: platform driver to register
Description
Register a test managed platform driver. This allows callers to embed the
drv in a container structure and use container_of() in the probe function
to pass information to KUnit tests.
Example
;
static inline struct kunit_test_context *
static int
static void
Return
0 on success, negative errno on failure.