Re: [PATCH v2 01/11] drm/tests: Stop using deprecated dev_private member on drm_framebuffer tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Tue, Oct 24, 2023 at 04:09:52PM -0300, Carlos Eduardo Gallo Filho wrote:
> The dev_private member of drm_device is deprecated and its use should
> be avoided. Stop using it by embedding the drm_device onto a mock struct
> with a void pointer like dev_private, using it instead.
> 
> Also start using drm_kunit_helper_alloc_drm_device() for allocating
> the drm_device mock.
> 
> Signed-off-by: Carlos Eduardo Gallo Filho <gcarlos@xxxxxxxxxxx>
> ---
> v2:
>   - Start using drm_kunit_helper_alloc_drm_device() for drm_device mock.
>   - Rename struct drm_mock to drm_framebuffer_test_priv
> ---
>  drivers/gpu/drm/tests/drm_framebuffer_test.c | 42 ++++++++++++++------
>  1 file changed, 29 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tests/drm_framebuffer_test.c b/drivers/gpu/drm/tests/drm_framebuffer_test.c
> index f759d9f3b76e..9c6170edd5f7 100644
> --- a/drivers/gpu/drm/tests/drm_framebuffer_test.c
> +++ b/drivers/gpu/drm/tests/drm_framebuffer_test.c
> @@ -8,8 +8,10 @@
>  #include <kunit/test.h>
>  
>  #include <drm/drm_device.h>
> +#include <drm/drm_drv.h>
>  #include <drm/drm_mode.h>
>  #include <drm/drm_fourcc.h>
> +#include <drm/drm_kunit_helpers.h>
>  #include <drm/drm_print.h>
>  
>  #include "../drm_crtc_internal.h"
> @@ -317,11 +319,17 @@ static const struct drm_framebuffer_test drm_framebuffer_create_cases[] = {
>  },
>  };
>  
> +struct drm_framebuffer_test_priv {
> +	struct drm_device dev;
> +	void *private;
> +};
> +

I'm not super confident with using a void pointer to whatever the test
wants it to be. Especially since it seems like you only use it to store
whether the buffer has been created, so I guess this could just be
converted to a boolean?

>  static struct drm_framebuffer *fb_create_mock(struct drm_device *dev,
>  					      struct drm_file *file_priv,
>  					      const struct drm_mode_fb_cmd2 *mode_cmd)
>  {
> -	int *buffer_created = dev->dev_private;
> +	struct drm_framebuffer_test_priv *priv = container_of(dev, typeof(*priv), dev);
> +	int *buffer_created = priv->private;
>  	*buffer_created = 1;

And then you just need to change that line to priv->buffer_created = true;

Maxime

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux