Skip to content

Commit 6135e73

Browse files
robherringmiquelraynal
authored andcommitted
mtd: 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: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 3ee355d commit 6135e73

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

drivers/mtd/maps/physmap-core.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@
3030
#include <linux/slab.h>
3131
#include <linux/device.h>
3232
#include <linux/platform_device.h>
33+
#include <linux/property.h>
3334
#include <linux/mtd/mtd.h>
3435
#include <linux/mtd/map.h>
3536
#include <linux/mtd/partitions.h>
3637
#include <linux/mtd/physmap.h>
3738
#include <linux/mtd/concat.h>
3839
#include <linux/mtd/cfi_endian.h>
3940
#include <linux/io.h>
40-
#include <linux/of_device.h>
41+
#include <linux/of.h>
4142
#include <linux/pm_runtime.h>
4243
#include <linux/gpio/consumer.h>
4344

@@ -295,14 +296,9 @@ static const char * const *of_get_part_probes(struct platform_device *dev)
295296
static const char *of_select_probe_type(struct platform_device *dev)
296297
{
297298
struct device_node *dp = dev->dev.of_node;
298-
const struct of_device_id *match;
299299
const char *probe_type;
300300

301-
match = of_match_device(of_flash_match, &dev->dev);
302-
if (!match)
303-
return NULL;
304-
305-
probe_type = match->data;
301+
probe_type = device_get_match_data(&dev->dev);
306302
if (probe_type)
307303
return probe_type;
308304

drivers/mtd/nand/raw/cadence-nand-controller.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
#include <linux/module.h>
1616
#include <linux/mtd/mtd.h>
1717
#include <linux/mtd/rawnand.h>
18-
#include <linux/of_device.h>
1918
#include <linux/iopoll.h>
19+
#include <linux/of.h>
20+
#include <linux/platform_device.h>
21+
#include <linux/property.h>
2022
#include <linux/slab.h>
2123

2224
/*
@@ -2995,15 +2997,11 @@ static int cadence_nand_dt_probe(struct platform_device *ofdev)
29952997
struct cadence_nand_dt *dt;
29962998
struct cdns_nand_ctrl *cdns_ctrl;
29972999
int ret;
2998-
const struct of_device_id *of_id;
29993000
const struct cadence_nand_dt_devdata *devdata;
30003001
u32 val;
30013002

3002-
of_id = of_match_device(cadence_nand_dt_ids, &ofdev->dev);
3003-
if (of_id) {
3004-
ofdev->id_entry = of_id->data;
3005-
devdata = of_id->data;
3006-
} else {
3003+
devdata = device_get_match_data(&ofdev->dev);
3004+
if (!devdata) {
30073005
pr_err("Failed to find the right device id.\n");
30083006
return -ENOMEM;
30093007
}

drivers/mtd/nand/raw/vf610_nfc.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
#include <linux/mtd/mtd.h>
3030
#include <linux/mtd/rawnand.h>
3131
#include <linux/mtd/partitions.h>
32-
#include <linux/of_device.h>
32+
#include <linux/of.h>
3333
#include <linux/platform_device.h>
34+
#include <linux/property.h>
3435
#include <linux/slab.h>
3536
#include <linux/swab.h>
3637

@@ -810,7 +811,6 @@ static int vf610_nfc_probe(struct platform_device *pdev)
810811
struct mtd_info *mtd;
811812
struct nand_chip *chip;
812813
struct device_node *child;
813-
const struct of_device_id *of_id;
814814
int err;
815815
int irq;
816816

@@ -840,12 +840,10 @@ static int vf610_nfc_probe(struct platform_device *pdev)
840840
return PTR_ERR(nfc->clk);
841841
}
842842

843-
of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev);
844-
if (!of_id)
843+
nfc->variant = (enum vf610_nfc_variant)device_get_match_data(&pdev->dev);
844+
if (!nfc->variant)
845845
return -ENODEV;
846846

847-
nfc->variant = (uintptr_t)of_id->data;
848-
849847
for_each_available_child_of_node(nfc->dev->of_node, child) {
850848
if (of_device_is_compatible(child, "fsl,vf610-nfc-nandcs")) {
851849

0 commit comments

Comments
 (0)