mailbox: Use device_get_match_data()
authorRob Herring <robh@kernel.org>
Fri, 6 Oct 2023 22:44:06 +0000 (17:44 -0500)
committerJassi Brar <jaswinder.singh@linaro.org>
Sun, 15 Oct 2023 17:39:16 +0000 (12:39 -0500)
Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data. With this, adjust the includes to explicitly
include the correct headers.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
drivers/mailbox/bcm-pdc-mailbox.c
drivers/mailbox/mailbox-sti.c
drivers/mailbox/ti-msgmgr.c

index d67db63b482d8073a89180f9ac4ce0a4f46415ed..778faeced81e1d6c409b74a551f8b755dbb48553 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/wait.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/io.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
-#include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/mailbox_controller.h>
 #include <linux/mailbox/brcm-message.h>
@@ -1494,7 +1493,6 @@ static int pdc_dt_read(struct platform_device *pdev, struct pdc_state *pdcs)
 {
        struct device *dev = &pdev->dev;
        struct device_node *dn = pdev->dev.of_node;
-       const struct of_device_id *match;
        const int *hw_type;
        int err;
 
@@ -1509,11 +1507,9 @@ static int pdc_dt_read(struct platform_device *pdev, struct pdc_state *pdcs)
 
        pdcs->hw_type = PDC_HW;
 
-       match = of_match_device(of_match_ptr(pdc_mbox_of_match), dev);
-       if (match != NULL) {
-               hw_type = match->data;
+       hw_type = device_get_match_data(dev);
+       if (hw_type)
                pdcs->hw_type = *hw_type;
-       }
 
        return 0;
 }
index 823061dd8c8ea25d63ea65bfcd0ff2f5554131c7..b4b5bdd503cfa38cfea5813015391ac7a900f944 100644 (file)
@@ -17,8 +17,8 @@
 #include <linux/mailbox_controller.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 
 #include "mailbox.h"
@@ -403,7 +403,6 @@ MODULE_DEVICE_TABLE(of, sti_mailbox_match);
 
 static int sti_mbox_probe(struct platform_device *pdev)
 {
-       const struct of_device_id *match;
        struct mbox_controller *mbox;
        struct sti_mbox_device *mdev;
        struct device_node *np = pdev->dev.of_node;
@@ -411,12 +410,11 @@ static int sti_mbox_probe(struct platform_device *pdev)
        int irq;
        int ret;
 
-       match = of_match_device(sti_mailbox_match, &pdev->dev);
-       if (!match) {
+       pdev->dev.platform_data = (struct sti_mbox_pdata *)device_get_match_data(&pdev->dev);
+       if (!pdev->dev.platform_data) {
                dev_err(&pdev->dev, "No configuration found\n");
                return -ENODEV;
        }
-       pdev->dev.platform_data = (struct sti_mbox_pdata *) match->data;
 
        mdev = devm_kzalloc(&pdev->dev, sizeof(*mdev), GFP_KERNEL);
        if (!mdev)
index a94577f16a4730ab3f20e9100251806d1632a692..9d2d4ff6cda403b1dae8f195fe223db2ed28b657 100644 (file)
 #include <linux/kernel.h>
 #include <linux/mailbox_controller.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
 #include <linux/of.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/soc/ti/ti-msgmgr.h>
 
 #define Q_DATA_OFFSET(proxy, queue, reg)       \
@@ -810,7 +810,6 @@ MODULE_DEVICE_TABLE(of, ti_msgmgr_of_match);
 static int ti_msgmgr_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       const struct of_device_id *of_id;
        struct device_node *np;
        const struct ti_msgmgr_desc *desc;
        struct ti_msgmgr_inst *inst;
@@ -828,19 +827,12 @@ static int ti_msgmgr_probe(struct platform_device *pdev)
        }
        np = dev->of_node;
 
-       of_id = of_match_device(ti_msgmgr_of_match, dev);
-       if (!of_id) {
-               dev_err(dev, "OF data missing\n");
-               return -EINVAL;
-       }
-       desc = of_id->data;
-
        inst = devm_kzalloc(dev, sizeof(*inst), GFP_KERNEL);
        if (!inst)
                return -ENOMEM;
 
        inst->dev = dev;
-       inst->desc = desc;
+       inst->desc = desc = device_get_match_data(dev);
 
        inst->queue_proxy_region =
                devm_platform_ioremap_resource_byname(pdev, desc->data_region_name);