Skip to content

Commit 409c39e

Browse files
robherringbebarino
authored andcommitted
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>
1 parent faf6b92 commit 409c39e

File tree

13 files changed

+42
-96
lines changed

13 files changed

+42
-96
lines changed

drivers/clk/clk-lochnagar.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <linux/device.h>
1313
#include <linux/module.h>
1414
#include <linux/of.h>
15-
#include <linux/of_device.h>
1615
#include <linux/platform_device.h>
16+
#include <linux/property.h>
1717
#include <linux/regmap.h>
1818

1919
#include <linux/mfd/lochnagar1_regs.h>
@@ -242,22 +242,17 @@ static int lochnagar_clk_probe(struct platform_device *pdev)
242242
};
243243
struct device *dev = &pdev->dev;
244244
struct lochnagar_clk_priv *priv;
245-
const struct of_device_id *of_id;
246245
struct lochnagar_clk *lclk;
247246
struct lochnagar_config *conf;
248247
int ret, i;
249248

250-
of_id = of_match_device(lochnagar_of_match, dev);
251-
if (!of_id)
252-
return -EINVAL;
253-
254249
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
255250
if (!priv)
256251
return -ENOMEM;
257252

258253
priv->dev = dev;
259254
priv->regmap = dev_get_regmap(dev->parent, NULL);
260-
conf = (struct lochnagar_config *)of_id->data;
255+
conf = (struct lochnagar_config *)device_get_match_data(dev);
261256

262257
memcpy(priv->lclks, conf->clks, sizeof(priv->lclks));
263258

drivers/clk/davinci/da8xx-cfgchip.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
#include <linux/init.h>
1212
#include <linux/mfd/da8xx-cfgchip.h>
1313
#include <linux/mfd/syscon.h>
14-
#include <linux/of_device.h>
1514
#include <linux/of.h>
1615
#include <linux/platform_data/clk-da8xx-cfgchip.h>
1716
#include <linux/platform_device.h>
17+
#include <linux/property.h>
1818
#include <linux/regmap.h>
1919
#include <linux/slab.h>
2020

@@ -744,15 +744,13 @@ static int da8xx_cfgchip_probe(struct platform_device *pdev)
744744
{
745745
struct device *dev = &pdev->dev;
746746
struct da8xx_cfgchip_clk_platform_data *pdata = dev->platform_data;
747-
const struct of_device_id *of_id;
748747
da8xx_cfgchip_init clk_init = NULL;
749748
struct regmap *regmap = NULL;
750749

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) {
753752
struct device_node *parent;
754753

755-
clk_init = of_id->data;
756754
parent = of_get_parent(dev->of_node);
757755
regmap = syscon_node_to_regmap(parent);
758756
of_node_put(parent);

drivers/clk/davinci/pll.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
#include <linux/kernel.h>
1919
#include <linux/mfd/syscon.h>
2020
#include <linux/notifier.h>
21-
#include <linux/of_address.h>
22-
#include <linux/of_device.h>
2321
#include <linux/of.h>
2422
#include <linux/platform_data/clk-davinci-pll.h>
2523
#include <linux/platform_device.h>
24+
#include <linux/property.h>
2625
#include <linux/regmap.h>
2726
#include <linux/slab.h>
2827
#include <linux/types.h>
@@ -892,14 +891,11 @@ static int davinci_pll_probe(struct platform_device *pdev)
892891
{
893892
struct device *dev = &pdev->dev;
894893
struct davinci_pll_platform_data *pdata;
895-
const struct of_device_id *of_id;
896894
davinci_pll_init pll_init = NULL;
897895
void __iomem *base;
898896

899-
of_id = of_match_device(davinci_pll_of_match, dev);
900-
if (of_id)
901-
pll_init = of_id->data;
902-
else if (pdev->id_entry)
897+
pll_init = device_get_match_data(dev);
898+
if (!pll_init && pdev->id_entry)
903899
pll_init = (void *)pdev->id_entry->driver_data;
904900

905901
if (!pll_init) {

drivers/clk/davinci/psc.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
#include <linux/clk/davinci.h>
1919
#include <linux/clkdev.h>
2020
#include <linux/err.h>
21-
#include <linux/of_address.h>
22-
#include <linux/of_device.h>
2321
#include <linux/of.h>
2422
#include <linux/platform_device.h>
23+
#include <linux/property.h>
2524
#include <linux/pm_clock.h>
2625
#include <linux/pm_domain.h>
2726
#include <linux/regmap.h>
@@ -517,15 +516,12 @@ static const struct platform_device_id davinci_psc_id_table[] = {
517516
static int davinci_psc_probe(struct platform_device *pdev)
518517
{
519518
struct device *dev = &pdev->dev;
520-
const struct of_device_id *of_id;
521519
const struct davinci_psc_init_data *init_data = NULL;
522520
void __iomem *base;
523521
int ret;
524522

525-
of_id = of_match_device(davinci_psc_of_match, dev);
526-
if (of_id)
527-
init_data = of_id->data;
528-
else if (pdev->id_entry)
523+
init_data = device_get_match_data(dev);
524+
if (!init_data && pdev->id_entry)
529525
init_data = (void *)pdev->id_entry->driver_data;
530526

531527
if (!init_data) {

drivers/clk/qcom/gcc-msm8960.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
#include <linux/bitops.h>
88
#include <linux/err.h>
99
#include <linux/platform_device.h>
10+
#include <linux/property.h>
1011
#include <linux/module.h>
1112
#include <linux/of.h>
12-
#include <linux/of_device.h>
13+
#include <linux/of_platform.h>
1314
#include <linux/clk-provider.h>
1415
#include <linux/regmap.h>
1516
#include <linux/reset-controller.h>
@@ -3716,14 +3717,10 @@ MODULE_DEVICE_TABLE(of, gcc_msm8960_match_table);
37163717
static int gcc_msm8960_probe(struct platform_device *pdev)
37173718
{
37183719
struct device *dev = &pdev->dev;
3719-
const struct of_device_id *match;
37203720
struct platform_device *tsens;
3721+
const struct qcom_cc_desc *desc = device_get_match_data(dev);
37213722
int ret;
37223723

3723-
match = of_match_device(gcc_msm8960_match_table, &pdev->dev);
3724-
if (!match)
3725-
return -EINVAL;
3726-
37273724
ret = qcom_cc_register_board_clk(dev, "cxo_board", "cxo", 19200000);
37283725
if (ret)
37293726
return ret;
@@ -3732,11 +3729,11 @@ static int gcc_msm8960_probe(struct platform_device *pdev)
37323729
if (ret)
37333730
return ret;
37343731

3735-
ret = qcom_cc_probe(pdev, match->data);
3732+
ret = qcom_cc_probe(pdev, desc);
37363733
if (ret)
37373734
return ret;
37383735

3739-
if (match->data == &gcc_apq8064_desc) {
3736+
if (desc == &gcc_apq8064_desc) {
37403737
hfpll1.d = &hfpll1_8064_data;
37413738
hfpll_l2.d = &hfpll_l2_8064_data;
37423739
}

drivers/clk/qcom/gcc-msm8974.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#include <linux/bitops.h>
88
#include <linux/err.h>
99
#include <linux/platform_device.h>
10+
#include <linux/property.h>
1011
#include <linux/module.h>
1112
#include <linux/of.h>
12-
#include <linux/of_device.h>
1313
#include <linux/clk-provider.h>
1414
#include <linux/regmap.h>
1515
#include <linux/reset-controller.h>
@@ -2875,14 +2875,10 @@ static int gcc_msm8974_probe(struct platform_device *pdev)
28752875
{
28762876
int ret;
28772877
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);
28832879

28842880
if (!of_device_is_compatible(dev->of_node, "qcom,gcc-msm8974")) {
2885-
if (id->data == &gcc_msm8226_desc)
2881+
if (data == &gcc_msm8226_desc)
28862882
msm8226_clock_override();
28872883
else
28882884
msm8974_pro_clock_override();

drivers/clk/qcom/kpss-xcc.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#include <linux/init.h>
66
#include <linux/module.h>
77
#include <linux/platform_device.h>
8+
#include <linux/property.h>
89
#include <linux/err.h>
910
#include <linux/io.h>
1011
#include <linux/of.h>
11-
#include <linux/of_device.h>
1212
#include <linux/clk.h>
1313
#include <linux/clk-provider.h>
1414

@@ -32,20 +32,15 @@ MODULE_DEVICE_TABLE(of, kpss_xcc_match_table);
3232
static int kpss_xcc_driver_probe(struct platform_device *pdev)
3333
{
3434
struct device *dev = &pdev->dev;
35-
const struct of_device_id *id;
3635
void __iomem *base;
3736
struct clk_hw *hw;
3837
const char *name;
3938

40-
id = of_match_device(kpss_xcc_match_table, dev);
41-
if (!id)
42-
return -ENODEV;
43-
4439
base = devm_platform_ioremap_resource(pdev, 0);
4540
if (IS_ERR(base))
4641
return PTR_ERR(base);
4742

48-
if (id->data) {
43+
if (device_get_match_data(&pdev->dev)) {
4944
if (of_property_read_string_index(dev->of_node,
5045
"clock-output-names",
5146
0, &name))

drivers/clk/qcom/krait-cc.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#include <linux/init.h>
66
#include <linux/module.h>
77
#include <linux/platform_device.h>
8+
#include <linux/property.h>
89
#include <linux/err.h>
910
#include <linux/io.h>
1011
#include <linux/of.h>
11-
#include <linux/of_device.h>
1212
#include <linux/clk.h>
1313
#include <linux/clk-provider.h>
1414
#include <linux/slab.h>
@@ -347,22 +347,18 @@ MODULE_DEVICE_TABLE(of, krait_cc_match_table);
347347
static int krait_cc_probe(struct platform_device *pdev)
348348
{
349349
struct device *dev = &pdev->dev;
350-
const struct of_device_id *id;
351350
unsigned long cur_rate, aux_rate;
352351
int cpu;
353352
struct clk_hw *mux, *l2_pri_mux;
354353
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);
359355

360356
/* Rate is 1 because 0 causes problems for __clk_mux_determine_rate */
361357
clk = clk_register_fixed_rate(dev, "qsb", NULL, 0, 1);
362358
if (IS_ERR(clk))
363359
return PTR_ERR(clk);
364360

365-
if (!id->data) {
361+
if (!unique_aux) {
366362
clk = clk_register_fixed_factor(dev, "acpu_aux",
367363
"gpll0_vote", 0, 1, 2);
368364
if (IS_ERR(clk))
@@ -375,13 +371,13 @@ static int krait_cc_probe(struct platform_device *pdev)
375371
return -ENOMEM;
376372

377373
for_each_possible_cpu(cpu) {
378-
mux = krait_add_clks(dev, cpu, id->data);
374+
mux = krait_add_clks(dev, cpu, unique_aux);
379375
if (IS_ERR(mux))
380376
return PTR_ERR(mux);
381377
clks[cpu] = mux->clk;
382378
}
383379

384-
l2_pri_mux = krait_add_clks(dev, -1, id->data);
380+
l2_pri_mux = krait_add_clks(dev, -1, unique_aux);
385381
if (IS_ERR(l2_pri_mux))
386382
return PTR_ERR(l2_pri_mux);
387383
clks[l2_mux] = l2_pri_mux->clk;

drivers/clk/qcom/mmcc-msm8960.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#include <linux/err.h>
99
#include <linux/delay.h>
1010
#include <linux/platform_device.h>
11+
#include <linux/property.h>
1112
#include <linux/module.h>
1213
#include <linux/of.h>
13-
#include <linux/of_device.h>
1414
#include <linux/clk.h>
1515
#include <linux/clk-provider.h>
1616
#include <linux/regmap.h>
@@ -3105,30 +3105,24 @@ MODULE_DEVICE_TABLE(of, mmcc_msm8960_match_table);
31053105

31063106
static int mmcc_msm8960_probe(struct platform_device *pdev)
31073107
{
3108-
const struct of_device_id *match;
31093108
struct regmap *regmap;
3110-
bool is_8064;
31113109
struct device *dev = &pdev->dev;
3110+
const struct qcom_cc_desc *desc = device_get_match_data(dev);
31123111

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) {
31193113
gfx3d_src.freq_tbl = clk_tbl_gfx3d_8064;
31203114
gfx3d_src.clkr.hw.init = &gfx3d_8064_init;
31213115
gfx3d_src.s[0].parent_map = mmcc_pxo_pll8_pll2_pll15_map;
31223116
gfx3d_src.s[1].parent_map = mmcc_pxo_pll8_pll2_pll15_map;
31233117
}
31243118

3125-
regmap = qcom_cc_map(pdev, match->data);
3119+
regmap = qcom_cc_map(pdev, desc);
31263120
if (IS_ERR(regmap))
31273121
return PTR_ERR(regmap);
31283122

31293123
clk_pll_configure_sr(&pll15, regmap, &pll15_config, false);
31303124

3131-
return qcom_cc_really_probe(pdev, match->data, regmap);
3125+
return qcom_cc_really_probe(pdev, desc, regmap);
31323126
}
31333127

31343128
static struct platform_driver mmcc_msm8960_driver = {

drivers/clk/qcom/mmcc-sdm660.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#include <linux/bitops.h>
1010
#include <linux/err.h>
1111
#include <linux/platform_device.h>
12+
#include <linux/property.h>
1213
#include <linux/module.h>
1314
#include <linux/of.h>
14-
#include <linux/of_device.h>
1515
#include <linux/clk-provider.h>
1616
#include <linux/regmap.h>
1717
#include <linux/reset-controller.h>
@@ -2828,14 +2828,10 @@ static void sdm630_clock_override(void)
28282828

28292829
static int mmcc_660_probe(struct platform_device *pdev)
28302830
{
2831-
const struct of_device_id *id;
28322831
struct regmap *regmap;
28332832
bool is_sdm630;
28342833

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);
28392835

28402836
regmap = qcom_cc_map(pdev, &mmcc_660_desc);
28412837
if (IS_ERR(regmap))

0 commit comments

Comments
 (0)