Skip to content

Commit a67ba97

Browse files
robherringvinodkoul
authored andcommitted
dmaengine: 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 <robh@kernel.org> Link: https://lore.kernel.org/r/20231006213844.333027-1-robh@kernel.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 0481291 commit a67ba97

File tree

4 files changed

+15
-45
lines changed

4 files changed

+15
-45
lines changed

drivers/dma/fsl-edma-main.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313
#include <linux/interrupt.h>
1414
#include <linux/clk.h>
1515
#include <linux/of.h>
16-
#include <linux/of_device.h>
17-
#include <linux/of_address.h>
18-
#include <linux/of_irq.h>
1916
#include <linux/of_dma.h>
2017
#include <linux/dma-mapping.h>
2118
#include <linux/pm_runtime.h>
2219
#include <linux/pm_domain.h>
20+
#include <linux/property.h>
2321

2422
#include "fsl-edma-common.h"
2523

@@ -414,8 +412,6 @@ static int fsl_edma3_attach_pd(struct platform_device *pdev, struct fsl_edma_eng
414412

415413
static int fsl_edma_probe(struct platform_device *pdev)
416414
{
417-
const struct of_device_id *of_id =
418-
of_match_device(fsl_edma_dt_ids, &pdev->dev);
419415
struct device_node *np = pdev->dev.of_node;
420416
struct fsl_edma_engine *fsl_edma;
421417
const struct fsl_edma_drvdata *drvdata = NULL;
@@ -424,8 +420,7 @@ static int fsl_edma_probe(struct platform_device *pdev)
424420
int chans;
425421
int ret, i;
426422

427-
if (of_id)
428-
drvdata = of_id->data;
423+
drvdata = device_get_match_data(&pdev->dev);
429424
if (!drvdata) {
430425
dev_err(&pdev->dev, "unable to find driver data\n");
431426
return -EINVAL;

drivers/dma/mmp_tdma.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
#include <linux/slab.h>
1515
#include <linux/dmaengine.h>
1616
#include <linux/platform_device.h>
17+
#include <linux/property.h>
1718
#include <linux/device.h>
1819
#include <linux/genalloc.h>
19-
#include <linux/of_device.h>
2020
#include <linux/of_dma.h>
2121

2222
#include "dmaengine.h"
@@ -642,11 +642,7 @@ static int mmp_tdma_probe(struct platform_device *pdev)
642642
int chan_num = TDMA_CHANNEL_NUM;
643643
struct gen_pool *pool = NULL;
644644

645-
of_id = of_match_device(mmp_tdma_dt_ids, &pdev->dev);
646-
if (of_id)
647-
type = (uintptr_t) of_id->data;
648-
else
649-
type = platform_get_device_id(pdev)->driver_data;
645+
type = (enum mmp_tdma_type)device_get_match_data(&pdev->dev);
650646

651647
/* always have couple channels */
652648
tdev = devm_kzalloc(&pdev->dev, sizeof(*tdev), GFP_KERNEL);
@@ -724,32 +720,22 @@ static int mmp_tdma_probe(struct platform_device *pdev)
724720
return ret;
725721
}
726722

727-
if (pdev->dev.of_node) {
728-
ret = of_dma_controller_register(pdev->dev.of_node,
729-
mmp_tdma_xlate, tdev);
730-
if (ret) {
731-
dev_err(tdev->device.dev,
732-
"failed to register controller\n");
733-
return ret;
734-
}
723+
ret = of_dma_controller_register(pdev->dev.of_node,
724+
mmp_tdma_xlate, tdev);
725+
if (ret) {
726+
dev_err(tdev->device.dev, "failed to register controller\n");
727+
return ret;
735728
}
736729

737730
dev_info(tdev->device.dev, "initialized\n");
738731
return 0;
739732
}
740733

741-
static const struct platform_device_id mmp_tdma_id_table[] = {
742-
{ "mmp-adma", MMP_AUD_TDMA },
743-
{ "pxa910-squ", PXA910_SQU },
744-
{ },
745-
};
746-
747734
static struct platform_driver mmp_tdma_driver = {
748735
.driver = {
749736
.name = "mmp-tdma",
750737
.of_match_table = mmp_tdma_dt_ids,
751738
},
752-
.id_table = mmp_tdma_id_table,
753739
.probe = mmp_tdma_probe,
754740
.remove_new = mmp_tdma_remove,
755741
};

drivers/dma/mv_xor.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <linux/dma-mapping.h>
1111
#include <linux/spinlock.h>
1212
#include <linux/interrupt.h>
13-
#include <linux/of_device.h>
1413
#include <linux/platform_device.h>
14+
#include <linux/property.h>
1515
#include <linux/memory.h>
1616
#include <linux/clk.h>
1717
#include <linux/of.h>
@@ -1328,13 +1328,8 @@ static int mv_xor_probe(struct platform_device *pdev)
13281328
* setting up. In non-dt case it can only be the legacy one.
13291329
*/
13301330
xordev->xor_type = XOR_ORION;
1331-
if (pdev->dev.of_node) {
1332-
const struct of_device_id *of_id =
1333-
of_match_device(mv_xor_dt_ids,
1334-
&pdev->dev);
1335-
1336-
xordev->xor_type = (uintptr_t)of_id->data;
1337-
}
1331+
if (pdev->dev.of_node)
1332+
xordev->xor_type = (uintptr_t)device_get_match_data(&pdev->dev);
13381333

13391334
/*
13401335
* (Re-)program MBUS remapping windows if we are asked to.

drivers/dma/st_fdma.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
#include <linux/init.h>
1212
#include <linux/module.h>
13-
#include <linux/of_device.h>
13+
#include <linux/of.h>
1414
#include <linux/of_dma.h>
1515
#include <linux/platform_device.h>
16+
#include <linux/property.h>
1617
#include <linux/interrupt.h>
1718
#include <linux/remoteproc.h>
1819
#include <linux/slab.h>
@@ -739,18 +740,11 @@ static void st_fdma_free(struct st_fdma_dev *fdev)
739740
static int st_fdma_probe(struct platform_device *pdev)
740741
{
741742
struct st_fdma_dev *fdev;
742-
const struct of_device_id *match;
743743
struct device_node *np = pdev->dev.of_node;
744744
const struct st_fdma_driverdata *drvdata;
745745
int ret, i;
746746

747-
match = of_match_device((st_fdma_match), &pdev->dev);
748-
if (!match || !match->data) {
749-
dev_err(&pdev->dev, "No device match found\n");
750-
return -ENODEV;
751-
}
752-
753-
drvdata = match->data;
747+
drvdata = device_get_match_data(&pdev->dev);
754748

755749
fdev = devm_kzalloc(&pdev->dev, sizeof(*fdev), GFP_KERNEL);
756750
if (!fdev)

0 commit comments

Comments
 (0)