On Tue, Jul 18, 2023 at 01:24:29AM +0800, suijingfeng wrote:
> On 2023/7/10 15:47, Maxime Ripard wrote:
> > The new helper to init the locking context allows to remove some
> > boilerplate.
> > 
> > Signed-off-by: Maxime Ripard <mrip...@kernel.org>
> > ---
> >   drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 42 
> > ++++++++++++--------------
> >   1 file changed, 19 insertions(+), 23 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c 
> > b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
> > index 776a7b01608f..ff1deaed0cab 100644
> > --- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
> > +++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
> > @@ -20,7 +20,6 @@
> >   struct pv_muxing_priv {
> >     struct vc4_dev *vc4;
> > -   struct drm_modeset_acquire_ctx ctx;
> >     struct drm_atomic_state *state;
> >   };
> > @@ -725,6 +724,7 @@ static void drm_vc4_test_pv_muxing_invalid(struct kunit 
> > *test)
> >   static int vc4_pv_muxing_test_init(struct kunit *test)
> >   {
> >     const struct pv_muxing_param *params = test->param_value;
> > +   struct drm_modeset_acquire_ctx *ctx;
> >     struct drm_atomic_state *state;
> >     struct pv_muxing_priv *priv;
> >     struct drm_device *drm;
> > @@ -738,13 +738,14 @@ static int vc4_pv_muxing_test_init(struct kunit *test)
> >     KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
> >     priv->vc4 = vc4;
> > -   drm_modeset_acquire_init(&priv->ctx, 0);
> > +   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
> 
> > +   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
> 
> The pointer returned by drm_kunit_helper_acquire_ctx_alloc() function can't
> be NULL,
> 
> if ctx is NULL, the current kthread will be terminated by the
> KUNIT_ASSERT_NOT_NULL() in the drm_kunit_helper_acquire_ctx_alloc().
> 
> so only a PTR_ERR is possible, right?
> 
> If so, probably invent a KUNIT_ASSERT_NOT_ERR() function to call is enough.
> 
> I'm fine with this patch, but I feel the checking if the ctx is NULL is
> redundant.

I guess, but we're still reference that pointer later on, so making sure
that it's a valid pointer still makes sense.

Maxime

Attachment: signature.asc
Description: PGP signature

Reply via email to