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

ASoC: 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/20231006-dt-asoc-header-cleanups-v3-5-13a4f0f7fee6@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Rob Herring and committed by
Mark Brown
9958d859 ec5236c2

+42 -118
+1 -12
sound/soc/intel/keembay/kmb_platform.c
··· 11 11 #include <linux/io.h> 12 12 #include <linux/module.h> 13 13 #include <linux/of.h> 14 - #include <linux/of_device.h> 15 14 #include <sound/dmaengine_pcm.h> 16 15 #include <sound/pcm.h> 17 16 #include <sound/pcm_params.h> ··· 819 820 { 820 821 struct device_node *np = pdev->dev.of_node; 821 822 struct snd_soc_dai_driver *kmb_i2s_dai; 822 - const struct of_device_id *match; 823 823 struct device *dev = &pdev->dev; 824 824 struct kmb_i2s_info *kmb_i2s; 825 825 struct resource *res; ··· 829 831 if (!kmb_i2s) 830 832 return -ENOMEM; 831 833 832 - kmb_i2s_dai = devm_kzalloc(dev, sizeof(*kmb_i2s_dai), GFP_KERNEL); 833 - if (!kmb_i2s_dai) 834 - return -ENOMEM; 835 - 836 - match = of_match_device(kmb_plat_of_match, &pdev->dev); 837 - if (!match) { 838 - dev_err(&pdev->dev, "Error: No device match found\n"); 839 - return -ENODEV; 840 - } 841 - kmb_i2s_dai = (struct snd_soc_dai_driver *) match->data; 834 + kmb_i2s_dai = (struct snd_soc_dai_driver *)device_get_match_data(&pdev->dev); 842 835 843 836 /* Prepare the related clocks */ 844 837 kmb_i2s->clk_apb = devm_clk_get(dev, "apb_clk");
+5 -10
sound/soc/qcom/lpass-cpu.c
··· 9 9 #include <linux/kernel.h> 10 10 #include <linux/module.h> 11 11 #include <linux/of.h> 12 - #include <linux/of_device.h> 13 12 #include <linux/platform_device.h> 14 13 #include <sound/pcm.h> 15 14 #include <sound/pcm_params.h> ··· 1105 1106 struct resource *res; 1106 1107 const struct lpass_variant *variant; 1107 1108 struct device *dev = &pdev->dev; 1108 - const struct of_device_id *match; 1109 1109 int ret, i, dai_id; 1110 1110 1111 1111 dsp_of_node = of_parse_phandle(pdev->dev.of_node, "qcom,adsp", 0); ··· 1119 1121 return -ENOMEM; 1120 1122 platform_set_drvdata(pdev, drvdata); 1121 1123 1122 - match = of_match_device(dev->driver->of_match_table, dev); 1123 - if (!match || !match->data) 1124 + variant = device_get_match_data(dev); 1125 + if (!variant) 1124 1126 return -EINVAL; 1125 1127 1126 - if (of_device_is_compatible(dev->of_node, "qcom,lpass-cpu-apq8016")) { 1127 - dev_warn(dev, "%s compatible is deprecated\n", 1128 - match->compatible); 1129 - } 1128 + if (of_device_is_compatible(dev->of_node, "qcom,lpass-cpu-apq8016")) 1129 + dev_warn(dev, "qcom,lpass-cpu-apq8016 compatible is deprecated\n"); 1130 1130 1131 - drvdata->variant = (struct lpass_variant *)match->data; 1132 - variant = drvdata->variant; 1131 + drvdata->variant = variant; 1133 1132 1134 1133 of_lpass_cpu_parse_dai_data(dev, drvdata); 1135 1134
+3 -5
sound/soc/rockchip/rockchip_i2s.c
··· 10 10 #include <linux/module.h> 11 11 #include <linux/mfd/syscon.h> 12 12 #include <linux/delay.h> 13 + #include <linux/of.h> 13 14 #include <linux/of_gpio.h> 14 - #include <linux/of_device.h> 15 15 #include <linux/clk.h> 16 16 #include <linux/pinctrl/consumer.h> 17 17 #include <linux/pm_runtime.h> ··· 736 736 static int rockchip_i2s_probe(struct platform_device *pdev) 737 737 { 738 738 struct device_node *node = pdev->dev.of_node; 739 - const struct of_device_id *of_id; 740 739 struct rk_i2s_dev *i2s; 741 740 struct snd_soc_dai_driver *dai; 742 741 struct resource *res; ··· 751 752 752 753 i2s->grf = syscon_regmap_lookup_by_phandle(node, "rockchip,grf"); 753 754 if (!IS_ERR(i2s->grf)) { 754 - of_id = of_match_device(rockchip_i2s_match, &pdev->dev); 755 - if (!of_id || !of_id->data) 755 + i2s->pins = device_get_match_data(&pdev->dev); 756 + if (!i2s->pins) 756 757 return -EINVAL; 757 758 758 - i2s->pins = of_id->data; 759 759 } 760 760 761 761 /* try to prepare related clocks */
+8 -16
sound/soc/rockchip/rockchip_i2s_tdm.c
··· 10 10 #include <linux/delay.h> 11 11 #include <linux/mfd/syscon.h> 12 12 #include <linux/module.h> 13 - #include <linux/of_address.h> 14 - #include <linux/of_device.h> 15 - #include <linux/of_gpio.h> 13 + #include <linux/of.h> 16 14 #include <linux/pm_runtime.h> 17 15 #include <linux/regmap.h> 18 16 #include <linux/reset.h> ··· 73 75 struct snd_dmaengine_dai_dma_data playback_dma_data; 74 76 struct reset_control *tx_reset; 75 77 struct reset_control *rx_reset; 76 - struct rk_i2s_soc_data *soc_data; 78 + const struct rk_i2s_soc_data *soc_data; 77 79 bool is_master_mode; 78 80 bool io_multiplex; 79 81 bool mclk_calibrate; ··· 1275 1277 { 0xff800000, 0x10260, RV1126_I2S0_CLK_TXONLY, RV1126_I2S0_CLK_RXONLY }, 1276 1278 }; 1277 1279 1278 - static struct rk_i2s_soc_data px30_i2s_soc_data = { 1280 + static const struct rk_i2s_soc_data px30_i2s_soc_data = { 1279 1281 .softrst_offset = 0x0300, 1280 1282 .configs = px30_txrx_config, 1281 1283 .config_count = ARRAY_SIZE(px30_txrx_config), 1282 1284 .init = common_soc_init, 1283 1285 }; 1284 1286 1285 - static struct rk_i2s_soc_data rk1808_i2s_soc_data = { 1287 + static const struct rk_i2s_soc_data rk1808_i2s_soc_data = { 1286 1288 .softrst_offset = 0x0300, 1287 1289 .configs = rk1808_txrx_config, 1288 1290 .config_count = ARRAY_SIZE(rk1808_txrx_config), 1289 1291 .init = common_soc_init, 1290 1292 }; 1291 1293 1292 - static struct rk_i2s_soc_data rk3308_i2s_soc_data = { 1294 + static const struct rk_i2s_soc_data rk3308_i2s_soc_data = { 1293 1295 .softrst_offset = 0x0400, 1294 1296 .grf_reg_offset = 0x0308, 1295 1297 .grf_shift = 5, ··· 1298 1300 .init = common_soc_init, 1299 1301 }; 1300 1302 1301 - static struct rk_i2s_soc_data rk3568_i2s_soc_data = { 1303 + static const struct rk_i2s_soc_data rk3568_i2s_soc_data = { 1302 1304 .softrst_offset = 0x0400, 1303 1305 .configs = rk3568_txrx_config, 1304 1306 .config_count = ARRAY_SIZE(rk3568_txrx_config), 1305 1307 .init = common_soc_init, 1306 1308 }; 1307 1309 1308 - static struct rk_i2s_soc_data rv1126_i2s_soc_data = { 1310 + static const struct rk_i2s_soc_data rv1126_i2s_soc_data = { 1309 1311 .softrst_offset = 0x0300, 1310 1312 .configs = rv1126_txrx_config, 1311 1313 .config_count = ARRAY_SIZE(rv1126_txrx_config), ··· 1542 1544 static int rockchip_i2s_tdm_probe(struct platform_device *pdev) 1543 1545 { 1544 1546 struct device_node *node = pdev->dev.of_node; 1545 - const struct of_device_id *of_id; 1546 1547 struct rk_i2s_tdm_dev *i2s_tdm; 1547 1548 struct resource *res; 1548 1549 void __iomem *regs; ··· 1553 1556 1554 1557 i2s_tdm->dev = &pdev->dev; 1555 1558 1556 - of_id = of_match_device(rockchip_i2s_tdm_match, &pdev->dev); 1557 - if (!of_id) 1558 - return -EINVAL; 1559 - 1560 1559 spin_lock_init(&i2s_tdm->lock); 1561 - i2s_tdm->soc_data = (struct rk_i2s_soc_data *)of_id->data; 1562 - 1560 + i2s_tdm->soc_data = device_get_match_data(&pdev->dev); 1563 1561 i2s_tdm->frame_width = 64; 1564 1562 1565 1563 i2s_tdm->clk_trcm = TRCM_TXRX;
+1 -6
sound/soc/rockchip/rockchip_pdm.c
··· 8 8 #include <linux/module.h> 9 9 #include <linux/clk.h> 10 10 #include <linux/of.h> 11 - #include <linux/of_device.h> 12 11 #include <linux/pm_runtime.h> 13 12 #include <linux/rational.h> 14 13 #include <linux/regmap.h> ··· 571 572 static int rockchip_pdm_probe(struct platform_device *pdev) 572 573 { 573 574 struct device_node *node = pdev->dev.of_node; 574 - const struct of_device_id *match; 575 575 struct rk_pdm_dev *pdm; 576 576 struct resource *res; 577 577 void __iomem *regs; ··· 580 582 if (!pdm) 581 583 return -ENOMEM; 582 584 583 - match = of_match_device(rockchip_pdm_match, &pdev->dev); 584 - if (match) 585 - pdm->version = (uintptr_t)match->data; 586 - 585 + pdm->version = (enum rk_pdm_version)device_get_match_data(&pdev->dev); 587 586 if (pdm->version == RK_PDM_RK3308) { 588 587 pdm->reset = devm_reset_control_get(&pdev->dev, "pdm-m"); 589 588 if (IS_ERR(pdm->reset))
+3 -25
sound/soc/samsung/smdk_wm8994.c
··· 5 5 #include <sound/soc.h> 6 6 #include <linux/module.h> 7 7 #include <linux/of.h> 8 - #include <linux/of_device.h> 9 8 10 9 /* 11 10 * Default CFG switch settings to use this driver: ··· 30 31 31 32 /* SMDK has a 16.934MHZ crystal attached to WM8994 */ 32 33 #define SMDK_WM8994_FREQ 16934000 33 - 34 - struct smdk_wm8994_data { 35 - int mclk1_rate; 36 - }; 37 - 38 - /* Default SMDKs */ 39 - static struct smdk_wm8994_data smdk_board_data = { 40 - .mclk1_rate = SMDK_WM8994_FREQ, 41 - }; 42 34 43 35 static int smdk_hw_params(struct snd_pcm_substream *substream, 44 36 struct snd_pcm_hw_params *params) ··· 126 136 .num_links = ARRAY_SIZE(smdk_dai), 127 137 }; 128 138 129 - static const struct of_device_id samsung_wm8994_of_match[] __maybe_unused = { 130 - { .compatible = "samsung,smdk-wm8994", .data = &smdk_board_data }, 139 + static const struct of_device_id samsung_wm8994_of_match[] = { 140 + { .compatible = "samsung,smdk-wm8994" }, 131 141 {}, 132 142 }; 133 143 MODULE_DEVICE_TABLE(of, samsung_wm8994_of_match); ··· 137 147 int ret; 138 148 struct device_node *np = pdev->dev.of_node; 139 149 struct snd_soc_card *card = &smdk; 140 - struct smdk_wm8994_data *board; 141 - const struct of_device_id *id; 142 150 143 151 card->dev = &pdev->dev; 144 - 145 - board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL); 146 - if (!board) 147 - return -ENOMEM; 148 152 149 153 if (np) { 150 154 smdk_dai[0].cpus->dai_name = NULL; ··· 155 171 smdk_dai[0].platforms->of_node = smdk_dai[0].cpus->of_node; 156 172 } 157 173 158 - id = of_match_device(samsung_wm8994_of_match, &pdev->dev); 159 - if (id) 160 - *board = *((struct smdk_wm8994_data *)id->data); 161 - 162 - platform_set_drvdata(pdev, board); 163 - 164 174 ret = devm_snd_soc_register_card(&pdev->dev, card); 165 175 166 176 if (ret) ··· 166 188 static struct platform_driver smdk_audio_driver = { 167 189 .driver = { 168 190 .name = "smdk-audio-wm8994", 169 - .of_match_table = of_match_ptr(samsung_wm8994_of_match), 191 + .of_match_table = samsung_wm8994_of_match, 170 192 .pm = &snd_soc_pm_ops, 171 193 }, 172 194 .probe = smdk_audio_probe,
+2 -5
sound/soc/stm/stm32_i2s.c
··· 1024 1024 struct stm32_i2s_data *i2s) 1025 1025 { 1026 1026 struct device_node *np = pdev->dev.of_node; 1027 - const struct of_device_id *of_id; 1028 1027 struct reset_control *rst; 1029 1028 struct resource *res; 1030 1029 int irq, ret; ··· 1031 1032 if (!np) 1032 1033 return -ENODEV; 1033 1034 1034 - of_id = of_match_device(stm32_i2s_ids, &pdev->dev); 1035 - if (of_id) 1036 - i2s->regmap_conf = (const struct regmap_config *)of_id->data; 1037 - else 1035 + i2s->regmap_conf = device_get_match_data(&pdev->dev); 1036 + if (!i2s->regmap_conf) 1038 1037 return -EINVAL; 1039 1038 1040 1039 i2s->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+4 -4
sound/soc/stm/stm32_sai.c
··· 151 151 static int stm32_sai_probe(struct platform_device *pdev) 152 152 { 153 153 struct stm32_sai_data *sai; 154 + const struct stm32_sai_conf *conf; 154 155 struct reset_control *rst; 155 - const struct of_device_id *of_id; 156 156 u32 val; 157 157 int ret; 158 158 ··· 164 164 if (IS_ERR(sai->base)) 165 165 return PTR_ERR(sai->base); 166 166 167 - of_id = of_match_device(stm32_sai_ids, &pdev->dev); 168 - if (of_id) 169 - memcpy(&sai->conf, (const struct stm32_sai_conf *)of_id->data, 167 + conf = device_get_match_data(&pdev->dev); 168 + if (conf) 169 + memcpy(&sai->conf, (const struct stm32_sai_conf *)conf, 170 170 sizeof(struct stm32_sai_conf)); 171 171 else 172 172 return -EINVAL;
+1 -5
sound/soc/stm/stm32_sai_sub.c
··· 1506 1506 static int stm32_sai_sub_probe(struct platform_device *pdev) 1507 1507 { 1508 1508 struct stm32_sai_sub_data *sai; 1509 - const struct of_device_id *of_id; 1510 1509 const struct snd_dmaengine_pcm_config *conf = &stm32_sai_pcm_config; 1511 1510 int ret; 1512 1511 ··· 1513 1514 if (!sai) 1514 1515 return -ENOMEM; 1515 1516 1516 - of_id = of_match_device(stm32_sai_sub_ids, &pdev->dev); 1517 - if (!of_id) 1518 - return -EINVAL; 1519 - sai->id = (uintptr_t)of_id->data; 1517 + sai->id = (uintptr_t)device_get_match_data(&pdev->dev); 1520 1518 1521 1519 sai->pdev = pdev; 1522 1520 mutex_init(&sai->ctrl_lock);
+2 -6
sound/soc/stm/stm32_spdifrx.c
··· 908 908 struct stm32_spdifrx_data *spdifrx) 909 909 { 910 910 struct device_node *np = pdev->dev.of_node; 911 - const struct of_device_id *of_id; 912 911 struct resource *res; 913 912 914 913 if (!np) 915 914 return -ENODEV; 916 915 917 - of_id = of_match_device(stm32_spdifrx_ids, &pdev->dev); 918 - if (of_id) 919 - spdifrx->regmap_conf = 920 - (const struct regmap_config *)of_id->data; 921 - else 916 + spdifrx->regmap_conf = device_get_match_data(&pdev->dev); 917 + if (!spdifrx->regmap_conf) 922 918 return -EINVAL; 923 919 924 920 spdifrx->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+2 -8
sound/soc/tegra/tegra210_amx.c
··· 7 7 #include <linux/clk.h> 8 8 #include <linux/device.h> 9 9 #include <linux/io.h> 10 + #include <linux/mod_devicetable.h> 10 11 #include <linux/module.h> 11 - #include <linux/of.h> 12 - #include <linux/of_device.h> 13 12 #include <linux/platform_device.h> 14 13 #include <linux/pm_runtime.h> 15 14 #include <linux/regmap.h> ··· 535 536 struct tegra210_amx *amx; 536 537 void __iomem *regs; 537 538 int err; 538 - const struct of_device_id *match; 539 539 struct tegra210_amx_soc_data *soc_data; 540 - 541 - match = of_match_device(tegra210_amx_of_match, dev); 542 - 543 - soc_data = (struct tegra210_amx_soc_data *)match->data; 544 540 545 541 amx = devm_kzalloc(dev, sizeof(*amx), GFP_KERNEL); 546 542 if (!amx) 547 543 return -ENOMEM; 548 544 549 - amx->soc_data = soc_data; 545 + amx->soc_data = device_get_match_data(dev); 550 546 551 547 dev_set_drvdata(dev, amx); 552 548
+2 -5
sound/soc/ti/davinci-evm.c
··· 175 175 static int davinci_evm_probe(struct platform_device *pdev) 176 176 { 177 177 struct device_node *np = pdev->dev.of_node; 178 - const struct of_device_id *match; 179 178 struct snd_soc_dai_link *dai; 180 179 struct snd_soc_card_drvdata_davinci *drvdata = NULL; 181 180 struct clk *mclk; 182 181 int ret = 0; 183 182 184 - match = of_match_device(of_match_ptr(davinci_evm_dt_ids), &pdev->dev); 185 - if (!match) { 183 + dai = (struct snd_soc_dai_link *) device_get_match_data(&pdev->dev); 184 + if (!dai) { 186 185 dev_err(&pdev->dev, "Error: No device match found\n"); 187 186 return -ENODEV; 188 187 } 189 - 190 - dai = (struct snd_soc_dai_link *) match->data; 191 188 192 189 evm_soc_card.dai_link = dai; 193 190
+4 -5
sound/soc/ti/davinci-mcasp.c
··· 21 21 #include <linux/clk.h> 22 22 #include <linux/pm_runtime.h> 23 23 #include <linux/of.h> 24 - #include <linux/of_platform.h> 25 - #include <linux/of_device.h> 26 24 #include <linux/platform_data/davinci_asp.h> 27 25 #include <linux/math64.h> 28 26 #include <linux/bitmap.h> ··· 1880 1882 static int davinci_mcasp_get_config(struct davinci_mcasp *mcasp, 1881 1883 struct platform_device *pdev) 1882 1884 { 1883 - const struct of_device_id *match = of_match_device(mcasp_dt_ids, &pdev->dev); 1884 1885 struct device_node *np = pdev->dev.of_node; 1885 1886 struct davinci_mcasp_pdata *pdata = NULL; 1887 + const struct davinci_mcasp_pdata *match_pdata = 1888 + device_get_match_data(&pdev->dev); 1886 1889 const u32 *of_serial_dir32; 1887 1890 u32 val; 1888 1891 int i; ··· 1892 1893 pdata = pdev->dev.platform_data; 1893 1894 pdata->dismod = DISMOD_LOW; 1894 1895 goto out; 1895 - } else if (match) { 1896 - pdata = devm_kmemdup(&pdev->dev, match->data, sizeof(*pdata), 1896 + } else if (match_pdata) { 1897 + pdata = devm_kmemdup(&pdev->dev, match_pdata, sizeof(*pdata), 1897 1898 GFP_KERNEL); 1898 1899 if (!pdata) 1899 1900 return -ENOMEM;
+4 -6
sound/soc/ti/omap-mcbsp.c
··· 13 13 #include <linux/device.h> 14 14 #include <linux/pm_runtime.h> 15 15 #include <linux/of.h> 16 - #include <linux/of_device.h> 17 16 #include <sound/core.h> 18 17 #include <sound/pcm.h> 19 18 #include <sound/pcm_params.h> ··· 1359 1360 static int asoc_mcbsp_probe(struct platform_device *pdev) 1360 1361 { 1361 1362 struct omap_mcbsp_platform_data *pdata = dev_get_platdata(&pdev->dev); 1363 + const struct omap_mcbsp_platform_data *match_pdata = 1364 + device_get_match_data(&pdev->dev); 1362 1365 struct omap_mcbsp *mcbsp; 1363 - const struct of_device_id *match; 1364 1366 int ret; 1365 1367 1366 - match = of_match_device(omap_mcbsp_of_match, &pdev->dev); 1367 - if (match) { 1368 + if (match_pdata) { 1368 1369 struct device_node *node = pdev->dev.of_node; 1369 1370 struct omap_mcbsp_platform_data *pdata_quirk = pdata; 1370 1371 int buffer_size; 1371 1372 1372 - pdata = devm_kzalloc(&pdev->dev, 1373 + pdata = devm_kmemdup(&pdev->dev, match_pdata, 1373 1374 sizeof(struct omap_mcbsp_platform_data), 1374 1375 GFP_KERNEL); 1375 1376 if (!pdata) 1376 1377 return -ENOMEM; 1377 1378 1378 - memcpy(pdata, match->data, sizeof(*pdata)); 1379 1379 if (!of_property_read_u32(node, "ti,buffer-size", &buffer_size)) 1380 1380 pdata->buffer_size = buffer_size; 1381 1381 if (pdata_quirk)