[PATCH v2 01/11] drm/tests: Stop using deprecated dev_private member on drm_framebuffer tests
Maxime Ripard
mripard at kernel.org
Wed Oct 25 14:34:00 UTC 2023
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 at disroot.org>
> ---
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20231025/723c4518/attachment.sig>
More information about the dri-devel
mailing list