mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
kunit: provide kunit_platform_device_register_full()
Provide a kunit-managed variant of platform_device_register_full(). Reviewed-by: David Gow <david@davidgow.net> Reviewed-by: Linus Walleij <linusw@kernel.org> Link: https://patch.msgid.link/20260522-gpiolib-kunit-v3-1-b15fe6987430@oss.qualcomm.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
parent
b12e12ee41
commit
4c237ab773
|
|
@ -6,10 +6,14 @@ struct completion;
|
|||
struct kunit;
|
||||
struct platform_device;
|
||||
struct platform_driver;
|
||||
struct platform_device_info;
|
||||
|
||||
struct platform_device *
|
||||
kunit_platform_device_alloc(struct kunit *test, const char *name, int id);
|
||||
int kunit_platform_device_add(struct kunit *test, struct platform_device *pdev);
|
||||
struct platform_device *
|
||||
kunit_platform_device_register_full(struct kunit *test,
|
||||
const struct platform_device_info *pdevinfo);
|
||||
|
||||
int kunit_platform_device_prepare_wait_for_probe(struct kunit *test,
|
||||
struct platform_device *pdev,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <linux/completion.h>
|
||||
#include <linux/device/bus.h>
|
||||
#include <linux/device/driver.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include <kunit/platform_device.h>
|
||||
|
|
@ -130,6 +131,36 @@ int kunit_platform_device_add(struct kunit *test, struct platform_device *pdev)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(kunit_platform_device_add);
|
||||
|
||||
/**
|
||||
* kunit_platform_device_register_full() - Register a KUnit test-managed platform
|
||||
* device described by platform device info
|
||||
* @test: test context
|
||||
* @pdevinfo: platform device information describing the new device
|
||||
*
|
||||
* Register a test-managed platform device. The device is unregistered when the
|
||||
* test completes.
|
||||
*
|
||||
* Return: New platform device on success, IS_ERR() on error.
|
||||
*/
|
||||
struct platform_device *
|
||||
kunit_platform_device_register_full(struct kunit *test,
|
||||
const struct platform_device_info *pdevinfo)
|
||||
{
|
||||
struct platform_device *pdev;
|
||||
int ret;
|
||||
|
||||
pdev = platform_device_register_full(pdevinfo);
|
||||
if (IS_ERR(pdev))
|
||||
return pdev;
|
||||
|
||||
ret = kunit_add_action_or_reset(test, platform_device_unregister_wrapper, pdev);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
return pdev;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(kunit_platform_device_register_full);
|
||||
|
||||
struct kunit_platform_device_probe_nb {
|
||||
struct completion *x;
|
||||
struct device *dev;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user