Re: [PATCH v6 5/8] platform: Add test managed platform_device/driver APIs
From: Stephen Boyd
Date: Sun Jul 07 2024 - 14:09:03 EST
Quoting Stephen Boyd (2024-07-07 11:02:06)
> Quoting David Gow (2024-07-06 01:04:25)
> > On Sat, 6 Jul 2024 at 12:55, Stephen Boyd <sboyd@xxxxxxxxxx> wrote:
> > >
> > > Introduce KUnit resource wrappers around platform_driver_register(),
> > > platform_device_alloc(), and platform_device_add() so that test authors
> > > can register platform drivers/devices from their tests and have the
> > > drivers/devices automatically be unregistered when the test is done.
> > >
> > > This makes test setup code simpler when a platform driver or platform
> > > device is needed. Add a few test cases at the same time to make sure the
> > > APIs work as intended.
> > >
> > > Cc: Brendan Higgins <brendan.higgins@xxxxxxxxx>
> > > Reviewed-by: David Gow <davidgow@xxxxxxxxxx>
> > > Cc: Rae Moar <rmoar@xxxxxxxxxx>
> > > Reviewed-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> > > Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
> > > Signed-off-by: Stephen Boyd <sboyd@xxxxxxxxxx>
> > > ---
> >
> > Hmm... this is failing under KASAN for me. I'll take a closer look
> > next week, but in case there's anything super-obvious, here's the
> > report:
>
> Thanks. I reproduced with your commandline and I'll take a look.
>
Seems that I forgot to fold this in when I was testing.
----8<---
diff --git a/lib/kunit/platform.c b/lib/kunit/platform.c
index ba1b0006dc45..0b518de26065 100644
--- a/lib/kunit/platform.c
+++ b/lib/kunit/platform.c
@@ -75,7 +75,7 @@ kunit_platform_device_alloc_match(struct kunit *test,
{
struct platform_device *pdev = match_data;
- return res->data == pdev && res->free != kunit_platform_device_alloc_exit;
+ return res->data == pdev && res->free == kunit_platform_device_alloc_exit;
}
KUNIT_DEFINE_ACTION_WRAPPER(platform_device_unregister_wrapper,