Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <robh@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20231009172923.2457844-1-robh@kernel.org

authored by

Rob Herring and committed by
Miquel Raynal
6135e730 3ee355db

+12 -20
+3 -7
drivers/mtd/maps/physmap-core.c
··· 30 30 #include <linux/slab.h> 31 31 #include <linux/device.h> 32 32 #include <linux/platform_device.h> 33 + #include <linux/property.h> 33 34 #include <linux/mtd/mtd.h> 34 35 #include <linux/mtd/map.h> 35 36 #include <linux/mtd/partitions.h> ··· 38 37 #include <linux/mtd/concat.h> 39 38 #include <linux/mtd/cfi_endian.h> 40 39 #include <linux/io.h> 41 - #include <linux/of_device.h> 40 + #include <linux/of.h> 42 41 #include <linux/pm_runtime.h> 43 42 #include <linux/gpio/consumer.h> 44 43 ··· 296 295 static const char *of_select_probe_type(struct platform_device *dev) 297 296 { 298 297 struct device_node *dp = dev->dev.of_node; 299 - const struct of_device_id *match; 300 298 const char *probe_type; 301 299 302 - match = of_match_device(of_flash_match, &dev->dev); 303 - if (!match) 304 - return NULL; 305 - 306 - probe_type = match->data; 300 + probe_type = device_get_match_data(&dev->dev); 307 301 if (probe_type) 308 302 return probe_type; 309 303
+5 -7
drivers/mtd/nand/raw/cadence-nand-controller.c
··· 15 15 #include <linux/module.h> 16 16 #include <linux/mtd/mtd.h> 17 17 #include <linux/mtd/rawnand.h> 18 - #include <linux/of_device.h> 19 18 #include <linux/iopoll.h> 19 + #include <linux/of.h> 20 + #include <linux/platform_device.h> 21 + #include <linux/property.h> 20 22 #include <linux/slab.h> 21 23 22 24 /* ··· 2997 2995 struct cadence_nand_dt *dt; 2998 2996 struct cdns_nand_ctrl *cdns_ctrl; 2999 2997 int ret; 3000 - const struct of_device_id *of_id; 3001 2998 const struct cadence_nand_dt_devdata *devdata; 3002 2999 u32 val; 3003 3000 3004 - of_id = of_match_device(cadence_nand_dt_ids, &ofdev->dev); 3005 - if (of_id) { 3006 - ofdev->id_entry = of_id->data; 3007 - devdata = of_id->data; 3008 - } else { 3001 + devdata = device_get_match_data(&ofdev->dev); 3002 + if (!devdata) { 3009 3003 pr_err("Failed to find the right device id.\n"); 3010 3004 return -ENOMEM; 3011 3005 }
+4 -6
drivers/mtd/nand/raw/vf610_nfc.c
··· 29 29 #include <linux/mtd/mtd.h> 30 30 #include <linux/mtd/rawnand.h> 31 31 #include <linux/mtd/partitions.h> 32 - #include <linux/of_device.h> 32 + #include <linux/of.h> 33 33 #include <linux/platform_device.h> 34 + #include <linux/property.h> 34 35 #include <linux/slab.h> 35 36 #include <linux/swab.h> 36 37 ··· 811 810 struct mtd_info *mtd; 812 811 struct nand_chip *chip; 813 812 struct device_node *child; 814 - const struct of_device_id *of_id; 815 813 int err; 816 814 int irq; 817 815 ··· 840 840 return PTR_ERR(nfc->clk); 841 841 } 842 842 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) 845 845 return -ENODEV; 846 - 847 - nfc->variant = (uintptr_t)of_id->data; 848 846 849 847 for_each_available_child_of_node(nfc->dev->of_node, child) { 850 848 if (of_device_is_compatible(child, "fsl,vf610-nfc-nandcs")) {