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

clk: 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/20231006213959.334439-1-robh@kernel.org
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> #msm part
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> # Samsung
Acked-by: David Lechner <david@lechnology.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Rob Herring and committed by
Stephen Boyd
409c39ec faf6b92e

+42 -96
+2 -7
drivers/clk/clk-lochnagar.c
··· 12 12 #include <linux/device.h> 13 13 #include <linux/module.h> 14 14 #include <linux/of.h> 15 - #include <linux/of_device.h> 16 15 #include <linux/platform_device.h> 16 + #include <linux/property.h> 17 17 #include <linux/regmap.h> 18 18 19 19 #include <linux/mfd/lochnagar1_regs.h> ··· 242 242 }; 243 243 struct device *dev = &pdev->dev; 244 244 struct lochnagar_clk_priv *priv; 245 - const struct of_device_id *of_id; 246 245 struct lochnagar_clk *lclk; 247 246 struct lochnagar_config *conf; 248 247 int ret, i; 249 - 250 - of_id = of_match_device(lochnagar_of_match, dev); 251 - if (!of_id) 252 - return -EINVAL; 253 248 254 249 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 255 250 if (!priv) ··· 252 257 253 258 priv->dev = dev; 254 259 priv->regmap = dev_get_regmap(dev->parent, NULL); 255 - conf = (struct lochnagar_config *)of_id->data; 260 + conf = (struct lochnagar_config *)device_get_match_data(dev); 256 261 257 262 memcpy(priv->lclks, conf->clks, sizeof(priv->lclks)); 258 263
+3 -5
drivers/clk/davinci/da8xx-cfgchip.c
··· 11 11 #include <linux/init.h> 12 12 #include <linux/mfd/da8xx-cfgchip.h> 13 13 #include <linux/mfd/syscon.h> 14 - #include <linux/of_device.h> 15 14 #include <linux/of.h> 16 15 #include <linux/platform_data/clk-da8xx-cfgchip.h> 17 16 #include <linux/platform_device.h> 17 + #include <linux/property.h> 18 18 #include <linux/regmap.h> 19 19 #include <linux/slab.h> 20 20 ··· 744 744 { 745 745 struct device *dev = &pdev->dev; 746 746 struct da8xx_cfgchip_clk_platform_data *pdata = dev->platform_data; 747 - const struct of_device_id *of_id; 748 747 da8xx_cfgchip_init clk_init = NULL; 749 748 struct regmap *regmap = NULL; 750 749 751 - of_id = of_match_device(da8xx_cfgchip_of_match, dev); 752 - if (of_id) { 750 + clk_init = device_get_match_data(dev); 751 + if (clk_init) { 753 752 struct device_node *parent; 754 753 755 - clk_init = of_id->data; 756 754 parent = of_get_parent(dev->of_node); 757 755 regmap = syscon_node_to_regmap(parent); 758 756 of_node_put(parent);
+3 -7
drivers/clk/davinci/pll.c
··· 18 18 #include <linux/kernel.h> 19 19 #include <linux/mfd/syscon.h> 20 20 #include <linux/notifier.h> 21 - #include <linux/of_address.h> 22 - #include <linux/of_device.h> 23 21 #include <linux/of.h> 24 22 #include <linux/platform_data/clk-davinci-pll.h> 25 23 #include <linux/platform_device.h> 24 + #include <linux/property.h> 26 25 #include <linux/regmap.h> 27 26 #include <linux/slab.h> 28 27 #include <linux/types.h> ··· 891 892 { 892 893 struct device *dev = &pdev->dev; 893 894 struct davinci_pll_platform_data *pdata; 894 - const struct of_device_id *of_id; 895 895 davinci_pll_init pll_init = NULL; 896 896 void __iomem *base; 897 897 898 - of_id = of_match_device(davinci_pll_of_match, dev); 899 - if (of_id) 900 - pll_init = of_id->data; 901 - else if (pdev->id_entry) 898 + pll_init = device_get_match_data(dev); 899 + if (!pll_init && pdev->id_entry) 902 900 pll_init = (void *)pdev->id_entry->driver_data; 903 901 904 902 if (!pll_init) {
+3 -7
drivers/clk/davinci/psc.c
··· 18 18 #include <linux/clk/davinci.h> 19 19 #include <linux/clkdev.h> 20 20 #include <linux/err.h> 21 - #include <linux/of_address.h> 22 - #include <linux/of_device.h> 23 21 #include <linux/of.h> 24 22 #include <linux/platform_device.h> 23 + #include <linux/property.h> 25 24 #include <linux/pm_clock.h> 26 25 #include <linux/pm_domain.h> 27 26 #include <linux/regmap.h> ··· 516 517 static int davinci_psc_probe(struct platform_device *pdev) 517 518 { 518 519 struct device *dev = &pdev->dev; 519 - const struct of_device_id *of_id; 520 520 const struct davinci_psc_init_data *init_data = NULL; 521 521 void __iomem *base; 522 522 int ret; 523 523 524 - of_id = of_match_device(davinci_psc_of_match, dev); 525 - if (of_id) 526 - init_data = of_id->data; 527 - else if (pdev->id_entry) 524 + init_data = device_get_match_data(dev); 525 + if (!init_data && pdev->id_entry) 528 526 init_data = (void *)pdev->id_entry->driver_data; 529 527 530 528 if (!init_data) {
+5 -8
drivers/clk/qcom/gcc-msm8960.c
··· 7 7 #include <linux/bitops.h> 8 8 #include <linux/err.h> 9 9 #include <linux/platform_device.h> 10 + #include <linux/property.h> 10 11 #include <linux/module.h> 11 12 #include <linux/of.h> 12 - #include <linux/of_device.h> 13 + #include <linux/of_platform.h> 13 14 #include <linux/clk-provider.h> 14 15 #include <linux/regmap.h> 15 16 #include <linux/reset-controller.h> ··· 3717 3716 static int gcc_msm8960_probe(struct platform_device *pdev) 3718 3717 { 3719 3718 struct device *dev = &pdev->dev; 3720 - const struct of_device_id *match; 3721 3719 struct platform_device *tsens; 3720 + const struct qcom_cc_desc *desc = device_get_match_data(dev); 3722 3721 int ret; 3723 - 3724 - match = of_match_device(gcc_msm8960_match_table, &pdev->dev); 3725 - if (!match) 3726 - return -EINVAL; 3727 3722 3728 3723 ret = qcom_cc_register_board_clk(dev, "cxo_board", "cxo", 19200000); 3729 3724 if (ret) ··· 3729 3732 if (ret) 3730 3733 return ret; 3731 3734 3732 - ret = qcom_cc_probe(pdev, match->data); 3735 + ret = qcom_cc_probe(pdev, desc); 3733 3736 if (ret) 3734 3737 return ret; 3735 3738 3736 - if (match->data == &gcc_apq8064_desc) { 3739 + if (desc == &gcc_apq8064_desc) { 3737 3740 hfpll1.d = &hfpll1_8064_data; 3738 3741 hfpll_l2.d = &hfpll_l2_8064_data; 3739 3742 }
+3 -7
drivers/clk/qcom/gcc-msm8974.c
··· 7 7 #include <linux/bitops.h> 8 8 #include <linux/err.h> 9 9 #include <linux/platform_device.h> 10 + #include <linux/property.h> 10 11 #include <linux/module.h> 11 12 #include <linux/of.h> 12 - #include <linux/of_device.h> 13 13 #include <linux/clk-provider.h> 14 14 #include <linux/regmap.h> 15 15 #include <linux/reset-controller.h> ··· 2875 2875 { 2876 2876 int ret; 2877 2877 struct device *dev = &pdev->dev; 2878 - const struct of_device_id *id; 2879 - 2880 - id = of_match_device(gcc_msm8974_match_table, dev); 2881 - if (!id) 2882 - return -ENODEV; 2878 + const void *data = device_get_match_data(dev); 2883 2879 2884 2880 if (!of_device_is_compatible(dev->of_node, "qcom,gcc-msm8974")) { 2885 - if (id->data == &gcc_msm8226_desc) 2881 + if (data == &gcc_msm8226_desc) 2886 2882 msm8226_clock_override(); 2887 2883 else 2888 2884 msm8974_pro_clock_override();
+2 -7
drivers/clk/qcom/kpss-xcc.c
··· 5 5 #include <linux/init.h> 6 6 #include <linux/module.h> 7 7 #include <linux/platform_device.h> 8 + #include <linux/property.h> 8 9 #include <linux/err.h> 9 10 #include <linux/io.h> 10 11 #include <linux/of.h> 11 - #include <linux/of_device.h> 12 12 #include <linux/clk.h> 13 13 #include <linux/clk-provider.h> 14 14 ··· 32 32 static int kpss_xcc_driver_probe(struct platform_device *pdev) 33 33 { 34 34 struct device *dev = &pdev->dev; 35 - const struct of_device_id *id; 36 35 void __iomem *base; 37 36 struct clk_hw *hw; 38 37 const char *name; 39 - 40 - id = of_match_device(kpss_xcc_match_table, dev); 41 - if (!id) 42 - return -ENODEV; 43 38 44 39 base = devm_platform_ioremap_resource(pdev, 0); 45 40 if (IS_ERR(base)) 46 41 return PTR_ERR(base); 47 42 48 - if (id->data) { 43 + if (device_get_match_data(&pdev->dev)) { 49 44 if (of_property_read_string_index(dev->of_node, 50 45 "clock-output-names", 51 46 0, &name))
+5 -9
drivers/clk/qcom/krait-cc.c
··· 5 5 #include <linux/init.h> 6 6 #include <linux/module.h> 7 7 #include <linux/platform_device.h> 8 + #include <linux/property.h> 8 9 #include <linux/err.h> 9 10 #include <linux/io.h> 10 11 #include <linux/of.h> 11 - #include <linux/of_device.h> 12 12 #include <linux/clk.h> 13 13 #include <linux/clk-provider.h> 14 14 #include <linux/slab.h> ··· 347 347 static int krait_cc_probe(struct platform_device *pdev) 348 348 { 349 349 struct device *dev = &pdev->dev; 350 - const struct of_device_id *id; 351 350 unsigned long cur_rate, aux_rate; 352 351 int cpu; 353 352 struct clk_hw *mux, *l2_pri_mux; 354 353 struct clk *clk, **clks; 355 - 356 - id = of_match_device(krait_cc_match_table, dev); 357 - if (!id) 358 - return -ENODEV; 354 + bool unique_aux = !!device_get_match_data(dev); 359 355 360 356 /* Rate is 1 because 0 causes problems for __clk_mux_determine_rate */ 361 357 clk = clk_register_fixed_rate(dev, "qsb", NULL, 0, 1); 362 358 if (IS_ERR(clk)) 363 359 return PTR_ERR(clk); 364 360 365 - if (!id->data) { 361 + if (!unique_aux) { 366 362 clk = clk_register_fixed_factor(dev, "acpu_aux", 367 363 "gpll0_vote", 0, 1, 2); 368 364 if (IS_ERR(clk)) ··· 371 375 return -ENOMEM; 372 376 373 377 for_each_possible_cpu(cpu) { 374 - mux = krait_add_clks(dev, cpu, id->data); 378 + mux = krait_add_clks(dev, cpu, unique_aux); 375 379 if (IS_ERR(mux)) 376 380 return PTR_ERR(mux); 377 381 clks[cpu] = mux->clk; 378 382 } 379 383 380 - l2_pri_mux = krait_add_clks(dev, -1, id->data); 384 + l2_pri_mux = krait_add_clks(dev, -1, unique_aux); 381 385 if (IS_ERR(l2_pri_mux)) 382 386 return PTR_ERR(l2_pri_mux); 383 387 clks[l2_mux] = l2_pri_mux->clk;
+5 -11
drivers/clk/qcom/mmcc-msm8960.c
··· 8 8 #include <linux/err.h> 9 9 #include <linux/delay.h> 10 10 #include <linux/platform_device.h> 11 + #include <linux/property.h> 11 12 #include <linux/module.h> 12 13 #include <linux/of.h> 13 - #include <linux/of_device.h> 14 14 #include <linux/clk.h> 15 15 #include <linux/clk-provider.h> 16 16 #include <linux/regmap.h> ··· 3105 3105 3106 3106 static int mmcc_msm8960_probe(struct platform_device *pdev) 3107 3107 { 3108 - const struct of_device_id *match; 3109 3108 struct regmap *regmap; 3110 - bool is_8064; 3111 3109 struct device *dev = &pdev->dev; 3110 + const struct qcom_cc_desc *desc = device_get_match_data(dev); 3112 3111 3113 - match = of_match_device(mmcc_msm8960_match_table, dev); 3114 - if (!match) 3115 - return -EINVAL; 3116 - 3117 - is_8064 = of_device_is_compatible(dev->of_node, "qcom,mmcc-apq8064"); 3118 - if (is_8064) { 3112 + if (desc == &mmcc_apq8064_desc) { 3119 3113 gfx3d_src.freq_tbl = clk_tbl_gfx3d_8064; 3120 3114 gfx3d_src.clkr.hw.init = &gfx3d_8064_init; 3121 3115 gfx3d_src.s[0].parent_map = mmcc_pxo_pll8_pll2_pll15_map; 3122 3116 gfx3d_src.s[1].parent_map = mmcc_pxo_pll8_pll2_pll15_map; 3123 3117 } 3124 3118 3125 - regmap = qcom_cc_map(pdev, match->data); 3119 + regmap = qcom_cc_map(pdev, desc); 3126 3120 if (IS_ERR(regmap)) 3127 3121 return PTR_ERR(regmap); 3128 3122 3129 3123 clk_pll_configure_sr(&pll15, regmap, &pll15_config, false); 3130 3124 3131 - return qcom_cc_really_probe(pdev, match->data, regmap); 3125 + return qcom_cc_really_probe(pdev, desc, regmap); 3132 3126 } 3133 3127 3134 3128 static struct platform_driver mmcc_msm8960_driver = {
+2 -6
drivers/clk/qcom/mmcc-sdm660.c
··· 9 9 #include <linux/bitops.h> 10 10 #include <linux/err.h> 11 11 #include <linux/platform_device.h> 12 + #include <linux/property.h> 12 13 #include <linux/module.h> 13 14 #include <linux/of.h> 14 - #include <linux/of_device.h> 15 15 #include <linux/clk-provider.h> 16 16 #include <linux/regmap.h> 17 17 #include <linux/reset-controller.h> ··· 2828 2828 2829 2829 static int mmcc_660_probe(struct platform_device *pdev) 2830 2830 { 2831 - const struct of_device_id *id; 2832 2831 struct regmap *regmap; 2833 2832 bool is_sdm630; 2834 2833 2835 - id = of_match_device(mmcc_660_match_table, &pdev->dev); 2836 - if (!id) 2837 - return -ENODEV; 2838 - is_sdm630 = !!(id->data); 2834 + is_sdm630 = !!device_get_match_data(&pdev->dev); 2839 2835 2840 2836 regmap = qcom_cc_map(pdev, &mmcc_660_desc); 2841 2837 if (IS_ERR(regmap))
+2 -7
drivers/clk/rockchip/clk-rk3399.c
··· 9 9 #include <linux/io.h> 10 10 #include <linux/of.h> 11 11 #include <linux/of_address.h> 12 - #include <linux/of_device.h> 13 12 #include <linux/platform_device.h> 13 + #include <linux/property.h> 14 14 #include <linux/regmap.h> 15 15 #include <dt-bindings/clock/rk3399-cru.h> 16 16 #include "clk.h" ··· 1634 1634 static int __init clk_rk3399_probe(struct platform_device *pdev) 1635 1635 { 1636 1636 struct device_node *np = pdev->dev.of_node; 1637 - const struct of_device_id *match; 1638 1637 const struct clk_rk3399_inits *init_data; 1639 1638 1640 - match = of_match_device(clk_rk3399_match_table, &pdev->dev); 1641 - if (!match || !match->data) 1642 - return -EINVAL; 1643 - 1644 - init_data = match->data; 1639 + init_data = device_get_match_data(&pdev->dev); 1645 1640 if (init_data->inits) 1646 1641 init_data->inits(np); 1647 1642
+3 -5
drivers/clk/samsung/clk-exynos-clkout.c
··· 13 13 #include <linux/io.h> 14 14 #include <linux/of.h> 15 15 #include <linux/of_address.h> 16 - #include <linux/of_device.h> 17 16 #include <linux/platform_device.h> 18 17 #include <linux/pm.h> 18 + #include <linux/property.h> 19 19 20 20 #define EXYNOS_CLKOUT_NR_CLKS 1 21 21 #define EXYNOS_CLKOUT_PARENTS 32 ··· 84 84 static int exynos_clkout_match_parent_dev(struct device *dev, u32 *mux_mask) 85 85 { 86 86 const struct exynos_clkout_variant *variant; 87 - const struct of_device_id *match; 88 87 89 88 if (!dev->parent) { 90 89 dev_err(dev, "not instantiated from MFD\n"); 91 90 return -EINVAL; 92 91 } 93 92 94 - match = of_match_device(exynos_clkout_ids, dev->parent); 95 - if (!match) { 93 + variant = device_get_match_data(dev->parent); 94 + if (!variant) { 96 95 dev_err(dev, "cannot match parent device\n"); 97 96 return -EINVAL; 98 97 } 99 - variant = match->data; 100 98 101 99 *mux_mask = variant->mux_mask; 102 100
+4 -10
drivers/clk/ti/adpll.c
··· 8 8 #include <linux/io.h> 9 9 #include <linux/math64.h> 10 10 #include <linux/module.h> 11 - #include <linux/of_device.h> 11 + #include <linux/of.h> 12 + #include <linux/platform_device.h> 13 + #include <linux/property.h> 12 14 #include <linux/string.h> 13 15 14 16 #define ADPLL_PLLSS_MMR_LOCK_OFFSET 0x00 /* Managed by MPPULL */ ··· 862 860 { 863 861 struct device_node *node = pdev->dev.of_node; 864 862 struct device *dev = &pdev->dev; 865 - const struct of_device_id *match; 866 - const struct ti_adpll_platform_data *pdata; 867 863 struct ti_adpll_data *d; 868 864 struct resource *res; 869 865 int err; 870 - 871 - match = of_match_device(ti_adpll_match, dev); 872 - if (match) 873 - pdata = match->data; 874 - else 875 - return -ENODEV; 876 866 877 867 d = devm_kzalloc(dev, sizeof(*d), GFP_KERNEL); 878 868 if (!d) 879 869 return -ENOMEM; 880 870 d->dev = dev; 881 871 d->np = node; 882 - d->c = pdata; 872 + d->c = device_get_match_data(dev); 883 873 dev_set_drvdata(d->dev, d); 884 874 spin_lock_init(&d->lock); 885 875