Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 5cb5d0c

Browse files
robherringJassiBrar
authored andcommitted
mailbox: Use device_get_match_data()
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 <[email protected]> Signed-off-by: Jassi Brar <[email protected]>
1 parent 81186dc commit 5cb5d0c

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

drivers/mailbox/bcm-pdc-mailbox.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@
3333
#include <linux/interrupt.h>
3434
#include <linux/wait.h>
3535
#include <linux/platform_device.h>
36+
#include <linux/property.h>
3637
#include <linux/io.h>
3738
#include <linux/of.h>
38-
#include <linux/of_device.h>
39-
#include <linux/of_address.h>
4039
#include <linux/of_irq.h>
4140
#include <linux/mailbox_controller.h>
4241
#include <linux/mailbox/brcm-message.h>
@@ -1494,7 +1493,6 @@ static int pdc_dt_read(struct platform_device *pdev, struct pdc_state *pdcs)
14941493
{
14951494
struct device *dev = &pdev->dev;
14961495
struct device_node *dn = pdev->dev.of_node;
1497-
const struct of_device_id *match;
14981496
const int *hw_type;
14991497
int err;
15001498

@@ -1509,11 +1507,9 @@ static int pdc_dt_read(struct platform_device *pdev, struct pdc_state *pdcs)
15091507

15101508
pdcs->hw_type = PDC_HW;
15111509

1512-
match = of_match_device(of_match_ptr(pdc_mbox_of_match), dev);
1513-
if (match != NULL) {
1514-
hw_type = match->data;
1510+
hw_type = device_get_match_data(dev);
1511+
if (hw_type)
15151512
pdcs->hw_type = *hw_type;
1516-
}
15171513

15181514
return 0;
15191515
}

drivers/mailbox/mailbox-sti.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include <linux/mailbox_controller.h>
1818
#include <linux/module.h>
1919
#include <linux/of.h>
20-
#include <linux/of_device.h>
2120
#include <linux/platform_device.h>
21+
#include <linux/property.h>
2222
#include <linux/slab.h>
2323

2424
#include "mailbox.h"
@@ -403,20 +403,18 @@ MODULE_DEVICE_TABLE(of, sti_mailbox_match);
403403

404404
static int sti_mbox_probe(struct platform_device *pdev)
405405
{
406-
const struct of_device_id *match;
407406
struct mbox_controller *mbox;
408407
struct sti_mbox_device *mdev;
409408
struct device_node *np = pdev->dev.of_node;
410409
struct mbox_chan *chans;
411410
int irq;
412411
int ret;
413412

414-
match = of_match_device(sti_mailbox_match, &pdev->dev);
415-
if (!match) {
413+
pdev->dev.platform_data = (struct sti_mbox_pdata *)device_get_match_data(&pdev->dev);
414+
if (!pdev->dev.platform_data) {
416415
dev_err(&pdev->dev, "No configuration found\n");
417416
return -ENODEV;
418417
}
419-
pdev->dev.platform_data = (struct sti_mbox_pdata *) match->data;
420418

421419
mdev = devm_kzalloc(&pdev->dev, sizeof(*mdev), GFP_KERNEL);
422420
if (!mdev)

drivers/mailbox/ti-msgmgr.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#include <linux/kernel.h>
1616
#include <linux/mailbox_controller.h>
1717
#include <linux/module.h>
18-
#include <linux/of_device.h>
1918
#include <linux/of.h>
2019
#include <linux/of_irq.h>
2120
#include <linux/platform_device.h>
21+
#include <linux/property.h>
2222
#include <linux/soc/ti/ti-msgmgr.h>
2323

2424
#define Q_DATA_OFFSET(proxy, queue, reg) \
@@ -810,7 +810,6 @@ MODULE_DEVICE_TABLE(of, ti_msgmgr_of_match);
810810
static int ti_msgmgr_probe(struct platform_device *pdev)
811811
{
812812
struct device *dev = &pdev->dev;
813-
const struct of_device_id *of_id;
814813
struct device_node *np;
815814
const struct ti_msgmgr_desc *desc;
816815
struct ti_msgmgr_inst *inst;
@@ -828,19 +827,12 @@ static int ti_msgmgr_probe(struct platform_device *pdev)
828827
}
829828
np = dev->of_node;
830829

831-
of_id = of_match_device(ti_msgmgr_of_match, dev);
832-
if (!of_id) {
833-
dev_err(dev, "OF data missing\n");
834-
return -EINVAL;
835-
}
836-
desc = of_id->data;
837-
838830
inst = devm_kzalloc(dev, sizeof(*inst), GFP_KERNEL);
839831
if (!inst)
840832
return -ENOMEM;
841833

842834
inst->dev = dev;
843-
inst->desc = desc;
835+
inst->desc = desc = device_get_match_data(dev);
844836

845837
inst->queue_proxy_region =
846838
devm_platform_ioremap_resource_byname(pdev, desc->data_region_name);

0 commit comments

Comments
 (0)