drm: Use device_get_match_data()
authorRob Herring <robh@kernel.org>
Fri, 20 Oct 2023 12:52:13 +0000 (07:52 -0500)
committerRob Herring <robh@kernel.org>
Mon, 27 Nov 2023 19:56:32 +0000 (13:56 -0600)
Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data in a single step. With this, adjust the
includes to explicitly include the correct headers. That also serves as
preparation to remove implicit includes within the DT headers
(of_device.h in particular).

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Link: https://lore.kernel.org/r/20231020125214.2930329-1-robh@kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
drivers/gpu/drm/armada/armada_crtc.c
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
drivers/gpu/drm/exynos/exynos_drm_gsc.c
drivers/gpu/drm/imx/ipuv3/imx-ldb.c
drivers/gpu/drm/mxsfb/mxsfb_drv.c
drivers/gpu/drm/omapdrm/dss/dispc.c
drivers/gpu/drm/omapdrm/dss/dss.c

index 52d2c942d3d2a06c75aa54b32df11a14ea37c7d8..c78687c755a869a8d3eb824dff01b8e5828ea890 100644 (file)
@@ -7,8 +7,9 @@
 #include <linux/clk.h>
 #include <linux/component.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
@@ -1012,26 +1013,17 @@ armada_lcd_bind(struct device *dev, struct device *master, void *data)
        int irq = platform_get_irq(pdev, 0);
        const struct armada_variant *variant;
        struct device_node *port = NULL;
+       struct device_node *np, *parent = dev->of_node;
 
        if (irq < 0)
                return irq;
 
-       if (!dev->of_node) {
-               const struct platform_device_id *id;
 
-               id = platform_get_device_id(pdev);
-               if (!id)
-                       return -ENXIO;
-
-               variant = (const struct armada_variant *)id->driver_data;
-       } else {
-               const struct of_device_id *match;
-               struct device_node *np, *parent = dev->of_node;
-
-               match = of_match_device(dev->driver->of_match_table, dev);
-               if (!match)
-                       return -ENXIO;
+       variant = device_get_match_data(dev);
+       if (!variant)
+               return -ENXIO;
 
+       if (parent) {
                np = of_get_child_by_name(parent, "ports");
                if (np)
                        parent = np;
@@ -1041,8 +1033,6 @@ armada_lcd_bind(struct device *dev, struct device *master, void *data)
                        dev_err(dev, "no port node found in %pOF\n", parent);
                        return -ENXIO;
                }
-
-               variant = match->data;
        }
 
        return armada_drm_crtc_create(drm, dev, res, irq, variant, port);
index 78122b35a0cbb347fcd2e4dfce139800e26aba65..a7a6b70220eb8cc95919e97216d95a9690c82bd9 100644 (file)
@@ -6,10 +6,10 @@
 #include <linux/irq.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/reset.h>
 
@@ -143,7 +143,6 @@ static int aspeed_gfx_load(struct drm_device *drm)
        struct aspeed_gfx *priv = to_aspeed_gfx(drm);
        struct device_node *np = pdev->dev.of_node;
        const struct aspeed_gfx_config *config;
-       const struct of_device_id *match;
        struct resource *res;
        int ret;
 
@@ -152,10 +151,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
        if (IS_ERR(priv->base))
                return PTR_ERR(priv->base);
 
-       match = of_match_device(aspeed_gfx_match, &pdev->dev);
-       if (!match)
+       config = device_get_match_data(&pdev->dev);
+       if (!config)
                return -EINVAL;
-       config = match->data;
 
        priv->dac_reg = config->dac_reg;
        priv->int_clr_reg = config->int_clear_reg;
index 34cdabc30b4f5ee62fd788923cbf335bb4af9409..35771fb4e85d06402069a0e68d2fdf0a07606045 100644 (file)
 #include <linux/component.h>
 #include <linux/kernel.h>
 #include <linux/mfd/syscon.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 
 #include <drm/drm_fourcc.h>
@@ -103,7 +104,7 @@ struct gsc_context {
        unsigned int                    num_formats;
 
        void __iomem    *regs;
-       const char      **clk_names;
+       const char      *const *clk_names;
        struct clk      *clocks[GSC_MAX_CLOCKS];
        int             num_clocks;
        struct gsc_scaler       sc;
@@ -1217,7 +1218,7 @@ static const unsigned int gsc_tiled_formats[] = {
 static int gsc_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct gsc_driverdata *driver_data;
+       const struct gsc_driverdata *driver_data;
        struct exynos_drm_ipp_formats *formats;
        struct gsc_context *ctx;
        int num_formats, ret, i, j;
@@ -1226,7 +1227,7 @@ static int gsc_probe(struct platform_device *pdev)
        if (!ctx)
                return -ENOMEM;
 
-       driver_data = (struct gsc_driverdata *)of_device_get_match_data(dev);
+       driver_data = device_get_match_data(dev);
        ctx->dev = dev;
        ctx->num_clocks = driver_data->num_clocks;
        ctx->clk_names = driver_data->clk_names;
index 989eca32d3252a15a8a790cc425c493a6d48a69b..53840ab054c725bb7648419a8391e70992062dd8 100644 (file)
 #include <linux/mfd/syscon.h>
 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/of_graph.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/videodev2.h>
 
@@ -617,7 +619,6 @@ static int imx_ldb_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct device_node *np = dev->of_node;
-       const struct of_device_id *of_id = of_match_device(imx_ldb_dt_ids, dev);
        struct device_node *child;
        struct imx_ldb *imx_ldb;
        int dual;
@@ -638,9 +639,7 @@ static int imx_ldb_probe(struct platform_device *pdev)
        regmap_write(imx_ldb->regmap, IOMUXC_GPR2, 0);
 
        imx_ldb->dev = dev;
-
-       if (of_id)
-               imx_ldb->lvds_mux = of_id->data;
+       imx_ldb->lvds_mux = device_get_match_data(dev);
 
        dual = of_property_read_bool(np, "fsl,dual-channel");
        if (dual)
index 625c1bfc41733b23e05de4556e3c9841094f7922..b483ef48216aa12b80394c696ff2ff65eb85c531 100644 (file)
 #include <linux/clk.h>
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/pm_runtime.h>
 
 #include <drm/drm_atomic_helper.h>
@@ -346,18 +347,13 @@ MODULE_DEVICE_TABLE(of, mxsfb_dt_ids);
 static int mxsfb_probe(struct platform_device *pdev)
 {
        struct drm_device *drm;
-       const struct of_device_id *of_id =
-                       of_match_device(mxsfb_dt_ids, &pdev->dev);
        int ret;
 
-       if (!pdev->dev.of_node)
-               return -ENODEV;
-
        drm = drm_dev_alloc(&mxsfb_driver, &pdev->dev);
        if (IS_ERR(drm))
                return PTR_ERR(drm);
 
-       ret = mxsfb_load(drm, of_id->data);
+       ret = mxsfb_load(drm, device_get_match_data(&pdev->dev));
        if (ret)
                goto err_free;
 
index c26aab4939fa00c6c1ffc81f06711904c8c141b8..993691b3cc7ead3088a1be762a2dda319b144244 100644 (file)
 #include <linux/hardirq.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/sizes.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/component.h>
 #include <linux/sys_soc.h>
 #include <drm/drm_fourcc.h>
@@ -4765,7 +4765,7 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
        if (soc)
                dispc->feat = soc->data;
        else
-               dispc->feat = of_match_device(dispc_of_match, &pdev->dev)->data;
+               dispc->feat = device_get_match_data(&pdev->dev);
 
        r = dispc_errata_i734_wa_init(dispc);
        if (r)
index 02955f976845967f5fb1aa9645ee2282b4516767..988888e164d7b3e9a87cf340cb12dfebe30d64e8 100644 (file)
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/gfp.h>
 #include <linux/sizes.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/of_platform.h>
 #include <linux/of_graph.h>
 #include <linux/regulator/consumer.h>
 #include <linux/suspend.h>
@@ -1445,7 +1446,7 @@ static int dss_probe(struct platform_device *pdev)
        if (soc)
                dss->feat = soc->data;
        else
-               dss->feat = of_match_device(dss_of_match, &pdev->dev)->data;
+               dss->feat = device_get_match_data(&pdev->dev);
 
        /* Map I/O registers, get and setup clocks. */
        dss->base = devm_platform_ioremap_resource(pdev, 0);