Skip to contentSkip to conversation

dma: tegra: don't open code of_device_get_match_data()

PATCH In review Laxman Dewangan 2 participants 3 messages Mar 2, 2016 – Mar 4, 2016

Subsystems (3)
lore
Share & tools
lore

Laxman Dewangan

author maintainer
#0 lore raw

PATCH v2 1/1 dma: tegra: don't open code of_device_get_match_data()

Use of_device_get_match_data() for getting matched data instead of implementing this locally.

---
Changes form V1:
- Found that it is possible to move of_device_id table to down where this is used i.e. just above the platform driver structure. Make this change on V2.
- Added Acked by from Thierry.

 drivers/dma/tegra20-apb-dma.c | 47 ++++++++++++++++++++-----------------------
 1 file changed, 22 insertions(+), 25 deletions(-)
drivers/dma/tegra20-apb-dma.c +22 -25
index 935da81..3871f29 100644
@@ -1292,40 +1292,19 @@ static const struct tegra_dma_chip_data tegra148_dma_chip_data = {
 	.support_separate_wcount_reg = true,
 };
 
-
-static const struct of_device_id tegra_dma_of_match[] = {
-	{
-		.compatible = "nvidia,tegra148-apbdma",
-		.data = &tegra148_dma_chip_data,
-	}, {
-		.compatible = "nvidia,tegra114-apbdma",
-		.data = &tegra114_dma_chip_data,
-	}, {
-		.compatible = "nvidia,tegra30-apbdma",
-		.data = &tegra30_dma_chip_data,
-	}, {
-		.compatible = "nvidia,tegra20-apbdma",
-		.data = &tegra20_dma_chip_data,
-	}, {
-	},
-};
-MODULE_DEVICE_TABLE(of, tegra_dma_of_match);
-
 static int tegra_dma_probe(struct platform_device *pdev)
 {
 	struct resource	*res;
 	struct tegra_dma *tdma;
 	int ret;
 	int i;
-	const struct tegra_dma_chip_data *cdata = NULL;
-	const struct of_device_id *match;
+	const struct tegra_dma_chip_data *cdata;
 
-	match = of_match_device(tegra_dma_of_match, &pdev->dev);
-	if (!match) {
-		dev_err(&pdev->dev, "Error: No device match found\n");
+	cdata = of_device_get_match_data(&pdev->dev);
+	if (!cdata) {
+		dev_err(&pdev->dev, "Error: No device match data found\n");
 		return -ENODEV;
 	}
-	cdata = match->data;
 
 	tdma = devm_kzalloc(&pdev->dev, sizeof(*tdma) + cdata->nr_channels *
 			sizeof(struct tegra_dma_channel), GFP_KERNEL);
@@ -1612,6 +1591,24 @@ static const struct dev_pm_ops tegra_dma_dev_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(tegra_dma_pm_suspend, tegra_dma_pm_resume)
 };
 
+static const struct of_device_id tegra_dma_of_match[] = {
+	{
+		.compatible = "nvidia,tegra148-apbdma",
+		.data = &tegra148_dma_chip_data,
+	}, {
+		.compatible = "nvidia,tegra114-apbdma",
+		.data = &tegra114_dma_chip_data,
+	}, {
+		.compatible = "nvidia,tegra30-apbdma",
+		.data = &tegra30_dma_chip_data,
+	}, {
+		.compatible = "nvidia,tegra20-apbdma",
+		.data = &tegra20_dma_chip_data,
+	}, {
+	},
+};
+MODULE_DEVICE_TABLE(of, tegra_dma_of_match);
+
 static struct platform_driver tegra_dmac_driver = {
 	.driver = {
 		.name	= "tegra-apbdma",
Signature · 1 line
2.1.4
#1 lore raw
Quoted 11 lines · Laxman Dewangan

Use of_device_get_match_data() for getting matched data instead of implementing this locally.

---
Changes form V1:
- Found that it is possible to move of_device_id table to down where this is used i.e. just above the platform driver structure. Make this change on V2.

But that is just noise and not relevant to the title which patch says. If you want to do this code move please send that separately. I have picked v1 for now

Signature · 1 line
~Vinod
author maintainer
#2 lore raw
Quoted 7 lines · Vinod Koul
Quoted 6 lines · Laxman Dewangan

Use of_device_get_match_data() for getting matched data instead of implementing this locally.

Quoted 9 lines
Quoted 5 lines

---
Changes form V1:
- Found that it is possible to move of_device_id table to down where this is used i.e. just above the platform driver structure. Make this change on V2.

But that is just noise and not relevant to the title which patch says. If you want to do this code move please send that separately. I have picked v1 for now

OK, fine with me. Will post another patch.