Lines Matching +full:platform +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0
3 * Test managed platform driver
24 pdev = platform_device_alloc(params->name, params->id); in kunit_platform_device_alloc_init()
26 return -ENOMEM; in kunit_platform_device_alloc_init()
28 res->data = pdev; in kunit_platform_device_alloc_init()
35 struct platform_device *pdev = res->data; in kunit_platform_device_alloc_exit()
41 * kunit_platform_device_alloc() - Allocate a KUnit test managed platform device
43 * @name: device name of platform device to alloc
44 * @id: identifier of platform device to alloc.
46 * Allocate a test managed platform device. The device is put when the test completes.
48 * Return: Allocated platform device on success, NULL on failure.
67 struct platform_device *pdev = res->data; in kunit_platform_device_add_exit()
78 return res->data == pdev && res->free == kunit_platform_device_alloc_exit; in kunit_platform_device_alloc_match()
84 * kunit_platform_device_add() - Register a KUnit test managed platform device
86 * @pdev: platform device to add
88 * Register a test managed platform device. The device is unregistered when the
105 * Transfer the reference count of the platform device if it in kunit_platform_device_add()
121 res->free = kunit_platform_device_add_exit; in kunit_platform_device_add()
140 unsigned long event, void *data) in kunit_platform_device_probe_notify() argument
143 struct device *dev = data; in kunit_platform_device_probe_notify()
146 if (event != BUS_NOTIFY_BOUND_DRIVER || knb->dev != dev) in kunit_platform_device_probe_notify()
149 complete(knb->x); in kunit_platform_device_probe_notify()
160 * kunit_platform_device_prepare_wait_for_probe() - Prepare a completion
161 * variable to wait for a platform device to probe
163 * @pdev: platform device to prepare to wait for probe of
167 * completion forces a preemption, allowing the platform driver to probe.
171 * .. code-block:: c
184 * pdev = kunit_platform_device_alloc(test, "kunit-platform", -1);
191 * pdrv->probe = kunit_platform_driver_probe;
192 * pdrv->driver.name = "kunit-platform";
193 * pdrv->driver.owner = THIS_MODULE;
207 struct device *dev = &pdev->dev; in kunit_platform_device_prepare_wait_for_probe()
213 return -ENOMEM; in kunit_platform_device_prepare_wait_for_probe()
215 knb->nb.notifier_call = kunit_platform_device_probe_notify; in kunit_platform_device_prepare_wait_for_probe()
216 knb->dev = dev; in kunit_platform_device_prepare_wait_for_probe()
217 knb->x = x; in kunit_platform_device_prepare_wait_for_probe()
228 bus_register_notifier(&platform_bus_type, &knb->nb); in kunit_platform_device_prepare_wait_for_probe()
229 device_unlock(&pdev->dev); in kunit_platform_device_prepare_wait_for_probe()
231 return kunit_add_action_or_reset(test, kunit_platform_device_probe_nb_remove, &knb->nb); in kunit_platform_device_prepare_wait_for_probe()
238 * kunit_platform_driver_register() - Register a KUnit test managed platform driver
240 * @drv: platform driver to register
242 * Register a test managed platform driver. This allows callers to embed the
248 * .. code-block:: c
252 * const char *data;
258 * return container_of(to_platform_driver(pdev->dev.driver),
268 * ctx->data = "test data";
280 * ctx->pdrv.probe = kunit_platform_driver_probe;
281 * ctx->pdrv.driver.name = "kunit-platform";
282 * ctx->pdrv.driver.owner = THIS_MODULE;
284 * KUNIT_EXPECT_EQ(test, 0, kunit_platform_driver_register(test, &ctx->pdrv));
286 * KUNIT_EXPECT_STREQ(test, ctx->data, "test data");