drm/vc4: Use of_device_get_match_data to set generation
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Fri, 25 Oct 2024 17:15:32 +0000 (18:15 +0100)
committerDave Stevenson <dave.stevenson@raspberrypi.com>
Wed, 27 Nov 2024 14:37:19 +0000 (14:37 +0000)
Use of_device_get_match_data to retrieve the generation value
as set in the struct of_device_id, rather than manually comparing
compatible strings.

Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20241025-drm-vc4-2712-support-v2-1-35efa83c8fc0@raspberrypi.com
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/gpu/drm/vc4/vc4_drv.c

index bfceb1e7d0b4557efe336154c246208bf4f0611a..0b5121067863bf459f5e278974f6b66e1271a9f9 100644 (file)
@@ -300,10 +300,7 @@ static int vc4_drm_bind(struct device *dev)
 
        dev->coherent_dma_mask = DMA_BIT_MASK(32);
 
-       if (of_device_is_compatible(dev->of_node, "brcm,bcm2711-vc5"))
-               gen = VC4_GEN_5;
-       else
-               gen = VC4_GEN_4;
+       gen = (enum vc4_gen)of_device_get_match_data(dev);
 
        if (gen > VC4_GEN_4)
                driver = &vc5_drm_driver;
@@ -462,9 +459,9 @@ static void vc4_platform_drm_shutdown(struct platform_device *pdev)
 }
 
 static const struct of_device_id vc4_of_match[] = {
-       { .compatible = "brcm,bcm2711-vc5", },
-       { .compatible = "brcm,bcm2835-vc4", },
-       { .compatible = "brcm,cygnus-vc4", },
+       { .compatible = "brcm,bcm2711-vc5", .data = (void *)VC4_GEN_5 },
+       { .compatible = "brcm,bcm2835-vc4", .data = (void *)VC4_GEN_4 },
+       { .compatible = "brcm,cygnus-vc4", .data = (void *)VC4_GEN_4 },
        {},
 };
 MODULE_DEVICE_TABLE(of, vc4_of_match);