From f2af7cb8ac0f825b415b4846a526bddba68807b1 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Fri, 8 Sep 2023 17:07:02 -0700 Subject: clk: asm9620: Remove 'hw' local variable that isn't checked The 'hw' pointer local variable in this function became unused after commit f5290d8e4f0c ("clk: asm9260: use parent index to link the reference clock"). Remove it to silence an unused but set variable warning. drivers/clk/clk-asm9260.c:258:17: warning: variable 'hw' set but not used [-Wunused-but-set-variable] struct clk_hw *hw, *pll_hw; ^ 1 warning generated. Cc: Dmitry Baryshkov Fixes: f5290d8e4f0c ("clk: asm9260: use parent index to link the reference clock") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202309042014.IWERPl09-lkp@intel.com/ Signed-off-by: Stephen Boyd Link: https://lore.kernel.org/r/20230909000703.3478902-1-sboyd@kernel.org --- drivers/clk/clk-asm9260.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-asm9260.c b/drivers/clk/clk-asm9260.c index 8b3c059e19a1..3432c801f1bd 100644 --- a/drivers/clk/clk-asm9260.c +++ b/drivers/clk/clk-asm9260.c @@ -255,7 +255,7 @@ static struct asm9260_mux_clock asm9260_mux_clks[] __initdata = { static void __init asm9260_acc_init(struct device_node *np) { - struct clk_hw *hw, *pll_hw; + struct clk_hw *pll_hw; struct clk_hw **hws; const char *pll_clk = "pll"; struct clk_parent_data pll_parent_data = { .index = 0 }; @@ -283,7 +283,7 @@ static void __init asm9260_acc_init(struct device_node *np) for (n = 0; n < ARRAY_SIZE(asm9260_mux_clks); n++) { const struct asm9260_mux_clock *mc = &asm9260_mux_clks[n]; - hw = clk_hw_register_mux_table_parent_data(NULL, mc->name, mc->parent_data, + clk_hw_register_mux_table_parent_data(NULL, mc->name, mc->parent_data, mc->num_parents, mc->flags, base + mc->offset, 0, mc->mask, 0, mc->table, &asm9260_clk_lock); } @@ -292,7 +292,7 @@ static void __init asm9260_acc_init(struct device_node *np) for (n = 0; n < ARRAY_SIZE(asm9260_mux_gates); n++) { const struct asm9260_gate_data *gd = &asm9260_mux_gates[n]; - hw = clk_hw_register_gate(NULL, gd->name, + clk_hw_register_gate(NULL, gd->name, gd->parent_name, gd->flags | CLK_SET_RATE_PARENT, base + gd->reg, gd->bit_idx, 0, &asm9260_clk_lock); } -- cgit From 14aaccbd34e93c0bbaaf475d174ece170f10f694 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Thu, 31 Aug 2023 15:36:55 +0300 Subject: clk: gate: fix comment typo and grammar Change ouput -> output. While at it change also grammatically incorrect "it's" to "its". Signed-off-by: Baruch Siach Link: https://lore.kernel.org/r/d47978a09dd0320f9929a19fa3e829608a02b224.1693485415.git.baruch@tkos.co.il Signed-off-by: Stephen Boyd --- drivers/clk/clk-gate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c index 64283807600b..68e585a02fd9 100644 --- a/drivers/clk/clk-gate.c +++ b/drivers/clk/clk-gate.c @@ -15,7 +15,7 @@ #include /** - * DOC: basic gatable clock which can gate and ungate it's ouput + * DOC: basic gatable clock which can gate and ungate its output * * Traits of this clock: * prepare - clk_(un)prepare only ensures parent is (un)prepared -- cgit From 619102313466eaf8a6ac188e711f5df749dac6d4 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 27 Aug 2023 04:39:32 +0200 Subject: clk: ralink: mtmips: quiet unused variable warning When CONFIG_OF is disabled then the matching table is not referenced and the following warning appears: drivers/clk/ralink/clk-mtmips.c:821:34: warning: unused variable 'mtmips_of_match' [-Wunused-const-variable] 821 | static const struct of_device_id mtmips_of_match[] = { | ^ There are two match tables in the driver: one for the clock driver and the other for the reset driver. The only difference between them is that the clock driver uses 'data' and does not have 'ralink,rt2880-reset' compatible. Both just can be merged into a single one just by adding the compatible 'ralink,rt2880-reset' entry to 'mtmips_of_match[]', which will allow it to be used for 'mtmips_clk_driver' (which doesn't use the data) as well as for 'mtmips_clk_init()' (which doesn't need get called for 'ralink,rt2880-reset'). Doing in this way ensures that 'CONFIG_OF' is not disabled anymore so the above warning disapears. Fixes: 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS SoCs") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202307242310.CdOnd2py-lkp@intel.com/ Suggested-by: Arnd Bergmann Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20230827023932.501102-1-sergio.paracuellos@gmail.com Reviewed-by: Nathan Chancellor Signed-off-by: Stephen Boyd --- drivers/clk/ralink/clk-mtmips.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/clk/ralink/clk-mtmips.c b/drivers/clk/ralink/clk-mtmips.c index 1e7991439527..50a443bf79ec 100644 --- a/drivers/clk/ralink/clk-mtmips.c +++ b/drivers/clk/ralink/clk-mtmips.c @@ -821,6 +821,10 @@ static const struct mtmips_clk_data mt76x8_clk_data = { }; static const struct of_device_id mtmips_of_match[] = { + { + .compatible = "ralink,rt2880-reset", + .data = NULL, + }, { .compatible = "ralink,rt2880-sysc", .data = &rt2880_clk_data, @@ -1088,25 +1092,11 @@ static int mtmips_clk_probe(struct platform_device *pdev) return 0; } -static const struct of_device_id mtmips_clk_of_match[] = { - { .compatible = "ralink,rt2880-reset" }, - { .compatible = "ralink,rt2880-sysc" }, - { .compatible = "ralink,rt3050-sysc" }, - { .compatible = "ralink,rt3052-sysc" }, - { .compatible = "ralink,rt3352-sysc" }, - { .compatible = "ralink,rt3883-sysc" }, - { .compatible = "ralink,rt5350-sysc" }, - { .compatible = "ralink,mt7620-sysc" }, - { .compatible = "ralink,mt7628-sysc" }, - { .compatible = "ralink,mt7688-sysc" }, - {} -}; - static struct platform_driver mtmips_clk_driver = { .probe = mtmips_clk_probe, .driver = { .name = "mtmips-clk", - .of_match_table = mtmips_clk_of_match, + .of_match_table = mtmips_of_match, }, }; -- cgit From a5d14f8b551eb1551c10053653ee8e27f19672fa Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 5 Oct 2023 17:01:57 +0300 Subject: clk: keystone: pll: fix a couple NULL vs IS_ERR() checks The clk_register_divider() and clk_register_mux() functions returns error pointers on error but this code checks for NULL. Fix that. Fixes: b9e0d40c0d83 ("clk: keystone: add Keystone PLL clock driver") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/d9da4c97-0da9-499f-9a21-1f8e3f148dc1@moroto.mountain Signed-off-by: Stephen Boyd --- drivers/clk/keystone/pll.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/clk/keystone/pll.c b/drivers/clk/keystone/pll.c index ee5c72369334..6bbdd4705d71 100644 --- a/drivers/clk/keystone/pll.c +++ b/drivers/clk/keystone/pll.c @@ -281,12 +281,13 @@ static void __init of_pll_div_clk_init(struct device_node *node) clk = clk_register_divider(NULL, clk_name, parent_name, 0, reg, shift, mask, 0, NULL); - if (clk) { - of_clk_add_provider(node, of_clk_src_simple_get, clk); - } else { + if (IS_ERR(clk)) { pr_err("%s: error registering divider %s\n", __func__, clk_name); iounmap(reg); + return; } + + of_clk_add_provider(node, of_clk_src_simple_get, clk); } CLK_OF_DECLARE(pll_divider_clock, "ti,keystone,pll-divider-clock", of_pll_div_clk_init); @@ -328,10 +329,12 @@ static void __init of_pll_mux_clk_init(struct device_node *node) clk = clk_register_mux(NULL, clk_name, (const char **)&parents, ARRAY_SIZE(parents) , 0, reg, shift, mask, 0, NULL); - if (clk) - of_clk_add_provider(node, of_clk_src_simple_get, clk); - else + if (IS_ERR(clk)) { pr_err("%s: error registering mux %s\n", __func__, clk_name); + return; + } + + of_clk_add_provider(node, of_clk_src_simple_get, clk); } CLK_OF_DECLARE(pll_mux_clock, "ti,keystone,pll-mux-clock", of_pll_mux_clk_init); -- cgit From 7af5b9eadd64c9e02a71f97c45bcdf3b64841f6b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 2 Oct 2023 10:04:36 +0300 Subject: clk: ti: fix double free in of_ti_divider_clk_setup() The "div" pointer is freed in _register_divider() and again in of_ti_divider_clk_setup(). Delete the free in _register_divider() Fixes: fbbc18591585 ("clk: ti: divider: cleanup _register_divider and ti_clk_get_div_table") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/6d36eeec-6c8a-4f11-a579-aa3cd7c38749@moroto.mountain Reviewed-by: Tony Lindgren Signed-off-by: Stephen Boyd --- drivers/clk/ti/divider.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/clk/ti/divider.c b/drivers/clk/ti/divider.c index 768a1f3398b4..5d5bb123ba94 100644 --- a/drivers/clk/ti/divider.c +++ b/drivers/clk/ti/divider.c @@ -309,7 +309,6 @@ static struct clk *_register_divider(struct device_node *node, u32 flags, struct clk_omap_divider *div) { - struct clk *clk; struct clk_init_data init; const char *parent_name; const char *name; @@ -326,12 +325,7 @@ static struct clk *_register_divider(struct device_node *node, div->hw.init = &init; /* register the clock */ - clk = of_ti_clk_register(node, &div->hw, name); - - if (IS_ERR(clk)) - kfree(div); - - return clk; + return of_ti_clk_register(node, &div->hw, name); } int ti_clk_parse_divider_data(int *div_table, int num_dividers, int max_div, -- cgit From 43a354a21a6a21f050b95317148661a465108cba Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 17 Oct 2023 17:06:53 +0300 Subject: clk: at91: remove unnecessary conditions This code checks "if (parent_hw)" is non-NULL, but then it has more checks if parent_hw is non-NULL on the lines inside the if statement. It is a bit confusing. For the else statement, keep in mind that at the start of the function we checked: if (!(parent_name || parent_hw)) return ERR_PTR(-EINVAL); That check ensures that if parent_hw is NULL that means that parent_name is non-NULL. At least one must always be non-NULL. So here again, the checks inside the if statement can be removed. In the original code, it was a bit confusing and you could easily get the impression that "init.num_parents" could be zero. When we remove the unnecessary checking it's more obvious that it's always set to 1. Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/7782b4f1-deed-49dc-8207-b6ea06d7602f@moroto.mountain Reviewed-by: Claudiu Beznea Signed-off-by: Stephen Boyd --- drivers/clk/at91/clk-utmi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/clk/at91/clk-utmi.c b/drivers/clk/at91/clk-utmi.c index 40c84f5af5e8..b991180beea1 100644 --- a/drivers/clk/at91/clk-utmi.c +++ b/drivers/clk/at91/clk-utmi.c @@ -161,13 +161,11 @@ at91_clk_register_utmi_internal(struct regmap *regmap_pmc, init.name = name; init.ops = ops; - if (parent_hw) { - init.parent_hws = parent_hw ? (const struct clk_hw **)&parent_hw : NULL; - init.num_parents = parent_hw ? 1 : 0; - } else { - init.parent_names = parent_name ? &parent_name : NULL; - init.num_parents = parent_name ? 1 : 0; - } + if (parent_hw) + init.parent_hws = (const struct clk_hw **)&parent_hw; + else + init.parent_names = &parent_name; + init.num_parents = 1; init.flags = flags; utmi->hw.init = &init; -- cgit From bbc5080bef4a245106aa8e8d424ba8847ca7c0ca Mon Sep 17 00:00:00 2001 From: Jonathan Neuschäfer Date: Sat, 23 Sep 2023 15:31:27 +0200 Subject: clk: npcm7xx: Fix incorrect kfree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The corresponding allocation is: > npcm7xx_clk_data = kzalloc(struct_size(npcm7xx_clk_data, hws, > NPCM7XX_NUM_CLOCKS), GFP_KERNEL); ... so, kfree should be applied to npcm7xx_clk_data, not npcm7xx_clk_data->hws. Fixes: fcfd14369856 ("clk: npcm7xx: add clock controller") Signed-off-by: Jonathan Neuschäfer Link: https://lore.kernel.org/r/20230923133127.1815621-1-j.neuschaefer@gmx.net Signed-off-by: Stephen Boyd --- drivers/clk/clk-npcm7xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/clk-npcm7xx.c b/drivers/clk/clk-npcm7xx.c index e319cfa51a8a..030186def9c6 100644 --- a/drivers/clk/clk-npcm7xx.c +++ b/drivers/clk/clk-npcm7xx.c @@ -510,7 +510,7 @@ static void __init npcm7xx_clk_init(struct device_node *clk_np) return; npcm7xx_init_fail: - kfree(npcm7xx_clk_data->hws); + kfree(npcm7xx_clk_data); npcm7xx_init_np_err: iounmap(clk_base); npcm7xx_init_error: -- cgit From ebcae17f87b34f71e8e55512226c4da35a9e3233 Mon Sep 17 00:00:00 2001 From: Biju Das Date: Sat, 9 Sep 2023 16:28:47 +0100 Subject: clk: si521xx: Use i2c_get_match_data() instead of device_get_match_data() The device_get_match_data(), is to get match data for firmware interfaces such as just OF/ACPI. This driver has I2C matching table as well. Use i2c_get_match_data() to get match data for I2C, ACPI and DT-based matching. Signed-off-by: Biju Das Link: https://lore.kernel.org/r/20230909152847.16216-1-biju.das.jz@bp.renesas.com Signed-off-by: Stephen Boyd --- drivers/clk/clk-si521xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/clk-si521xx.c b/drivers/clk/clk-si521xx.c index 4eaf1b53f06b..14c8741b9ba0 100644 --- a/drivers/clk/clk-si521xx.c +++ b/drivers/clk/clk-si521xx.c @@ -279,7 +279,7 @@ si521xx_of_clk_get(struct of_phandle_args *clkspec, void *data) static int si521xx_probe(struct i2c_client *client) { - const u16 chip_info = (u16)(uintptr_t)device_get_match_data(&client->dev); + const u16 chip_info = (u16)(uintptr_t)i2c_get_match_data(client); const struct clk_parent_data clk_parent_data = { .index = 0 }; struct si521xx *si; unsigned char name[6] = "DIFF0"; -- cgit From b28f95c61965fd31ca15556e7ac65dfc84a15fad Mon Sep 17 00:00:00 2001 From: Biju Das Date: Sat, 9 Sep 2023 16:54:18 +0100 Subject: clk: clk-si544: Simplify probe() and is_valid_frequency() The driver has an OF match table, still, it uses an ID lookup table for retrieving match data. Currently, the driver is working on the assumption that an I2C device registered via OF will always match a legacy I2C device ID. The correct approach is to have an OF device ID table using i2c_get_match_data() if the devices are registered via OF/ID. Unify the OF/ID table by using max_freq as match data instead of enum si544_speed_grade and replace the ID lookup table for the match data by i2c_get_match_data(). This allows to simplify both probe() and is_valid_frequency(). Drop enum si544_speed_grade as there is no user. While at it, remove the trailing comma in the terminator entry for the OF table making code robust against (theoretical) misrebases or other similar things where the new entry goes _after_ the termination without the compiler noticing. Signed-off-by: Biju Das Link: https://lore.kernel.org/r/20230909155418.24426-1-biju.das.jz@bp.renesas.com Signed-off-by: Stephen Boyd --- drivers/clk/clk-si544.c | 51 +++++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/drivers/clk/clk-si544.c b/drivers/clk/clk-si544.c index 22925968aa35..4132db706144 100644 --- a/drivers/clk/clk-si544.c +++ b/drivers/clk/clk-si544.c @@ -56,17 +56,11 @@ #define DELTA_M_FRAC_NUM 19 #define DELTA_M_FRAC_DEN 20000 -enum si544_speed_grade { - si544a, - si544b, - si544c, -}; - struct clk_si544 { struct clk_hw hw; struct regmap *regmap; struct i2c_client *i2c_client; - enum si544_speed_grade speed_grade; + unsigned long max_freq; }; #define to_clk_si544(_hw) container_of(_hw, struct clk_si544, hw) @@ -196,24 +190,10 @@ static int si544_set_muldiv(struct clk_si544 *data, static bool is_valid_frequency(const struct clk_si544 *data, unsigned long frequency) { - unsigned long max_freq = 0; - if (frequency < SI544_MIN_FREQ) return false; - switch (data->speed_grade) { - case si544a: - max_freq = 1500000000; - break; - case si544b: - max_freq = 800000000; - break; - case si544c: - max_freq = 350000000; - break; - } - - return frequency <= max_freq; + return frequency <= data->max_freq; } /* Calculate divider settings for a given frequency */ @@ -451,19 +431,10 @@ static const struct regmap_config si544_regmap_config = { .volatile_reg = si544_regmap_is_volatile, }; -static const struct i2c_device_id si544_id[] = { - { "si544a", si544a }, - { "si544b", si544b }, - { "si544c", si544c }, - { } -}; -MODULE_DEVICE_TABLE(i2c, si544_id); - static int si544_probe(struct i2c_client *client) { struct clk_si544 *data; struct clk_init_data init; - const struct i2c_device_id *id = i2c_match_id(si544_id, client); int err; data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); @@ -475,7 +446,7 @@ static int si544_probe(struct i2c_client *client) init.num_parents = 0; data->hw.init = &init; data->i2c_client = client; - data->speed_grade = id->driver_data; + data->max_freq = (uintptr_t)i2c_get_match_data(client); if (of_property_read_string(client->dev.of_node, "clock-output-names", &init.name)) @@ -507,11 +478,19 @@ static int si544_probe(struct i2c_client *client) return 0; } +static const struct i2c_device_id si544_id[] = { + { "si544a", 1500000000 }, + { "si544b", 800000000 }, + { "si544c", 350000000 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, si544_id); + static const struct of_device_id clk_si544_of_match[] = { - { .compatible = "silabs,si544a" }, - { .compatible = "silabs,si544b" }, - { .compatible = "silabs,si544c" }, - { }, + { .compatible = "silabs,si544a", .data = (void *)1500000000 }, + { .compatible = "silabs,si544b", .data = (void *)800000000 }, + { .compatible = "silabs,si544c", .data = (void *)350000000 }, + { } }; MODULE_DEVICE_TABLE(of, clk_si544_of_match); -- cgit From 38a929ab128d7f0ac61f7cb506e6687d145b9eba Mon Sep 17 00:00:00 2001 From: Biju Das Date: Sat, 9 Sep 2023 17:02:18 +0100 Subject: clk: rs9: Use i2c_get_match_data() instead of device_get_match_data() The device_get_match_data(), is to get match data for firmware interfaces such as just OF/ACPI. This driver has I2C matching table as well. Use i2c_get_match_data() to get match data for I2C, ACPI and DT-based matching. Signed-off-by: Biju Das Link: https://lore.kernel.org/r/20230909160218.33078-1-biju.das.jz@bp.renesas.com Signed-off-by: Stephen Boyd --- drivers/clk/clk-renesas-pcie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/clk-renesas-pcie.c b/drivers/clk/clk-renesas-pcie.c index 7d7b2cb75318..380245f635d6 100644 --- a/drivers/clk/clk-renesas-pcie.c +++ b/drivers/clk/clk-renesas-pcie.c @@ -298,7 +298,7 @@ static int rs9_probe(struct i2c_client *client) i2c_set_clientdata(client, rs9); rs9->client = client; - rs9->chip_info = device_get_match_data(&client->dev); + rs9->chip_info = i2c_get_match_data(client); if (!rs9->chip_info) return -EINVAL; -- cgit From f234f028727f8634973f8a9ef2ec933eb0eade5b Mon Sep 17 00:00:00 2001 From: Biju Das Date: Sat, 9 Sep 2023 17:20:47 +0100 Subject: clk: si5351: Simplify probe The driver has an OF match table, still, it uses an ID lookup table for retrieving match data. Currently, the driver is working on the assumption that an I2C device registered via OF will always match a legacy I2C device ID. The correct approach is to have an OF device ID table using i2c_get_match_data() if the devices are registered via OF/ID. Simplify probe() by replacing ID lookup table for retrieving match data with i2c_get_match_data(). Signed-off-by: Biju Das Link: https://lore.kernel.org/r/20230909162047.41845-1-biju.das.jz@bp.renesas.com Signed-off-by: Stephen Boyd --- drivers/clk/clk-si5351.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk-si5351.c b/drivers/clk/clk-si5351.c index 00fb9b09e030..afe12d1a9ddc 100644 --- a/drivers/clk/clk-si5351.c +++ b/drivers/clk/clk-si5351.c @@ -1385,8 +1385,7 @@ MODULE_DEVICE_TABLE(i2c, si5351_i2c_ids); static int si5351_i2c_probe(struct i2c_client *client) { - const struct i2c_device_id *id = i2c_match_id(si5351_i2c_ids, client); - enum si5351_variant variant = (enum si5351_variant)id->driver_data; + enum si5351_variant variant; struct si5351_platform_data *pdata; struct si5351_driver_data *drvdata; struct clk_init_data init; @@ -1394,6 +1393,7 @@ static int si5351_i2c_probe(struct i2c_client *client) u8 num_parents, num_clocks; int ret, n; + variant = (enum si5351_variant)(uintptr_t)i2c_get_match_data(client); ret = si5351_dt_parse(client, variant); if (ret) return ret; -- cgit From 15f5e2e4225a94fe76302e87ecdf95e56e571382 Mon Sep 17 00:00:00 2001 From: Biju Das Date: Sat, 9 Sep 2023 17:47:38 +0100 Subject: clk: si570: Simplify probe The driver has an OF match table, still, it uses an ID lookup table for retrieving match data. Currently, the driver is working on the assumption that an I2C device registered via OF will always match a legacy I2C device ID. The correct approach is to have an OF device ID table using i2c_get_match_data() if the devices are registered via OF/ID. Unify the OF/ID table by adding struct clk_si570_info as match data instead of clk_si570_variant and replace the ID lookup table for the match data by i2c_get_match_data(). This allows to simplify probe(). Drop enum clk_si570_variant as there is no user. While at it, remove the trailing comma in the terminator entry for the OF table making code robust against (theoretical) misrebases or other similar things where the new entry goes _after_ the termination without the compiler noticing. Signed-off-by: Biju Das Link: https://lore.kernel.org/r/20230909164738.47708-1-biju.das.jz@bp.renesas.com Signed-off-by: Stephen Boyd --- drivers/clk/clk-si570.c | 67 ++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/drivers/clk/clk-si570.c b/drivers/clk/clk-si570.c index de0212fb5f87..ad053a922a42 100644 --- a/drivers/clk/clk-si570.c +++ b/drivers/clk/clk-si570.c @@ -49,12 +49,22 @@ #define SI570_FREEZE_DCO (1 << 4) +/** + * struct clk_si570_info: + * @max_freq: Maximum frequency for this device + * @has_temperature_stability: Device support temperature stability + */ +struct clk_si570_info { + u64 max_freq; + bool has_temperature_stability; +}; + /** * struct clk_si570: * @hw: Clock hw struct * @regmap: Device's regmap * @div_offset: Rgister offset for dividers - * @max_freq: Maximum frequency for this device + * @info: Device info * @fxtal: Factory xtal frequency * @n1: Clock divider N1 * @hs_div: Clock divider HSDIV @@ -66,7 +76,7 @@ struct clk_si570 { struct clk_hw hw; struct regmap *regmap; unsigned int div_offset; - u64 max_freq; + const struct clk_si570_info *info; u64 fxtal; unsigned int n1; unsigned int hs_div; @@ -76,11 +86,6 @@ struct clk_si570 { }; #define to_clk_si570(_hw) container_of(_hw, struct clk_si570, hw) -enum clk_si570_variant { - si57x, - si59x -}; - /** * si570_get_divs() - Read clock dividers from HW * @data: Pointer to struct clk_si570 @@ -341,7 +346,7 @@ static int si570_set_rate(struct clk_hw *hw, unsigned long rate, struct i2c_client *client = data->i2c_client; int err; - if (rate < SI570_MIN_FREQ || rate > data->max_freq) { + if (rate < SI570_MIN_FREQ || rate > data->info->max_freq) { dev_err(&client->dev, "requested frequency %lu Hz is out of range\n", rate); return -EINVAL; @@ -398,24 +403,13 @@ static const struct regmap_config si570_regmap_config = { .volatile_reg = si570_regmap_is_volatile, }; -static const struct i2c_device_id si570_id[] = { - { "si570", si57x }, - { "si571", si57x }, - { "si598", si59x }, - { "si599", si59x }, - { } -}; -MODULE_DEVICE_TABLE(i2c, si570_id); - static int si570_probe(struct i2c_client *client) { struct clk_si570 *data; struct clk_init_data init; - const struct i2c_device_id *id = i2c_match_id(si570_id, client); u32 initial_fout, factory_fout, stability; bool skip_recall; int err; - enum clk_si570_variant variant = id->driver_data; data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); if (!data) @@ -427,7 +421,8 @@ static int si570_probe(struct i2c_client *client) data->hw.init = &init; data->i2c_client = client; - if (variant == si57x) { + data->info = i2c_get_match_data(client); + if (data->info->has_temperature_stability) { err = of_property_read_u32(client->dev.of_node, "temperature-stability", &stability); if (err) { @@ -438,10 +433,6 @@ static int si570_probe(struct i2c_client *client) /* adjust register offsets for 7ppm devices */ if (stability == 7) data->div_offset = SI570_DIV_OFFSET_7PPM; - - data->max_freq = SI570_MAX_FREQ; - } else { - data->max_freq = SI598_MAX_FREQ; } if (of_property_read_string(client->dev.of_node, "clock-output-names", @@ -496,12 +487,30 @@ static int si570_probe(struct i2c_client *client) return 0; } +static const struct clk_si570_info clk_si570_info = { + .max_freq = SI570_MAX_FREQ, + .has_temperature_stability = true, +}; + +static const struct clk_si570_info clk_si590_info = { + .max_freq = SI598_MAX_FREQ, +}; + +static const struct i2c_device_id si570_id[] = { + { "si570", (kernel_ulong_t)&clk_si570_info }, + { "si571", (kernel_ulong_t)&clk_si570_info }, + { "si598", (kernel_ulong_t)&clk_si590_info }, + { "si599", (kernel_ulong_t)&clk_si590_info }, + { } +}; +MODULE_DEVICE_TABLE(i2c, si570_id); + static const struct of_device_id clk_si570_of_match[] = { - { .compatible = "silabs,si570" }, - { .compatible = "silabs,si571" }, - { .compatible = "silabs,si598" }, - { .compatible = "silabs,si599" }, - { }, + { .compatible = "silabs,si570", .data = &clk_si570_info }, + { .compatible = "silabs,si571", .data = &clk_si570_info }, + { .compatible = "silabs,si598", .data = &clk_si590_info }, + { .compatible = "silabs,si599", .data = &clk_si590_info }, + { } }; MODULE_DEVICE_TABLE(of, clk_si570_of_match); -- cgit From faf6b92ee0091ff7a7bba03a1726a1a97112e9db Mon Sep 17 00:00:00 2001 From: Biju Das Date: Sat, 9 Sep 2023 16:05:16 +0100 Subject: clk: cdce925: Extend match support for OF tables The driver has an OF match table, still, it uses an ID lookup table for retrieving match data. Currently, the driver is working on the assumption that an I2C device registered via OF will always match a legacy I2C device ID. The correct approach is to have an OF device ID table using i2c_get_match_data() if the devices are registered via OF/ID. Unify the OF/ID table by using struct clk_cdce925_chip_info as match data for both these tables and replace the ID lookup table for the match data by i2c_get_match_data(). Split the array clk_cdce925_chip_info_tbl[] as individual variables, and make lines shorter by referring to e.g. &clk_cdce913_info instead of &clk_cdce925_chip_info_tbl[CDCE913]. Drop enum related to chip type as there is no user. While at it, remove the trailing comma in the terminator entry for the OF table making code robust against (theoretical) misrebases or other similar things where the new entry goes _after_ the termination without the compiler noticing. Signed-off-by: Biju Das Link: https://lore.kernel.org/r/20230909150516.10353-1-biju.das.jz@bp.renesas.com Signed-off-by: Stephen Boyd --- drivers/clk/clk-cdce925.c | 65 +++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/drivers/clk/clk-cdce925.c b/drivers/clk/clk-cdce925.c index cdee4958f26d..584c103394bb 100644 --- a/drivers/clk/clk-cdce925.c +++ b/drivers/clk/clk-cdce925.c @@ -25,25 +25,11 @@ * Model this as 2 PLL clocks which are parents to the outputs. */ -enum { - CDCE913, - CDCE925, - CDCE937, - CDCE949, -}; - struct clk_cdce925_chip_info { int num_plls; int num_outputs; }; -static const struct clk_cdce925_chip_info clk_cdce925_chip_info_tbl[] = { - [CDCE913] = { .num_plls = 1, .num_outputs = 3 }, - [CDCE925] = { .num_plls = 2, .num_outputs = 5 }, - [CDCE937] = { .num_plls = 3, .num_outputs = 7 }, - [CDCE949] = { .num_plls = 4, .num_outputs = 9 }, -}; - #define MAX_NUMBER_OF_PLLS 4 #define MAX_NUMBER_OF_OUTPUTS 9 @@ -621,20 +607,10 @@ static struct regmap_bus regmap_cdce925_bus = { .read = cdce925_regmap_i2c_read, }; -static const struct i2c_device_id cdce925_id[] = { - { "cdce913", CDCE913 }, - { "cdce925", CDCE925 }, - { "cdce937", CDCE937 }, - { "cdce949", CDCE949 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, cdce925_id); - static int cdce925_probe(struct i2c_client *client) { struct clk_cdce925_chip *data; struct device_node *node = client->dev.of_node; - const struct i2c_device_id *id = i2c_match_id(cdce925_id, client); const char *parent_name; const char *pll_clk_name[MAX_NUMBER_OF_PLLS] = {NULL,}; struct clk_init_data init; @@ -665,7 +641,7 @@ static int cdce925_probe(struct i2c_client *client) return -ENOMEM; data->i2c_client = client; - data->chip_info = &clk_cdce925_chip_info_tbl[id->driver_data]; + data->chip_info = i2c_get_match_data(client); config.max_register = CDCE925_OFFSET_PLL + data->chip_info->num_plls * 0x10 - 1; data->regmap = devm_regmap_init(&client->dev, ®map_cdce925_bus, @@ -822,12 +798,41 @@ error: return err; } +static const struct clk_cdce925_chip_info clk_cdce913_info = { + .num_plls = 1, + .num_outputs = 3, +}; + +static const struct clk_cdce925_chip_info clk_cdce925_info = { + .num_plls = 2, + .num_outputs = 5, +}; + +static const struct clk_cdce925_chip_info clk_cdce937_info = { + .num_plls = 3, + .num_outputs = 7, +}; + +static const struct clk_cdce925_chip_info clk_cdce949_info = { + .num_plls = 4, + .num_outputs = 9, +}; + +static const struct i2c_device_id cdce925_id[] = { + { "cdce913", (kernel_ulong_t)&clk_cdce913_info }, + { "cdce925", (kernel_ulong_t)&clk_cdce925_info }, + { "cdce937", (kernel_ulong_t)&clk_cdce937_info }, + { "cdce949", (kernel_ulong_t)&clk_cdce949_info }, + { } +}; +MODULE_DEVICE_TABLE(i2c, cdce925_id); + static const struct of_device_id clk_cdce925_of_match[] = { - { .compatible = "ti,cdce913" }, - { .compatible = "ti,cdce925" }, - { .compatible = "ti,cdce937" }, - { .compatible = "ti,cdce949" }, - { }, + { .compatible = "ti,cdce913", .data = &clk_cdce913_info }, + { .compatible = "ti,cdce925", .data = &clk_cdce925_info }, + { .compatible = "ti,cdce937", .data = &clk_cdce937_info }, + { .compatible = "ti,cdce949", .data = &clk_cdce949_info }, + { } }; MODULE_DEVICE_TABLE(of, clk_cdce925_of_match); -- cgit From 409c39ec92a35e3708f5b5798c78eae78512cd71 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 6 Oct 2023 16:39:58 -0500 Subject: 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 Link: https://lore.kernel.org/r/20231006213959.334439-1-robh@kernel.org Reviewed-by: Dmitry Baryshkov #msm part Acked-by: Krzysztof Kozlowski # Samsung Acked-by: David Lechner Acked-by: Chanwoo Choi Acked-by: Charles Keepax Reviewed-by: Bjorn Andersson Signed-off-by: Stephen Boyd --- drivers/clk/clk-lochnagar.c | 9 ++------- drivers/clk/davinci/da8xx-cfgchip.c | 8 +++----- drivers/clk/davinci/pll.c | 10 +++------- drivers/clk/davinci/psc.c | 10 +++------- drivers/clk/qcom/gcc-msm8960.c | 13 +++++-------- drivers/clk/qcom/gcc-msm8974.c | 10 +++------- drivers/clk/qcom/kpss-xcc.c | 9 ++------- drivers/clk/qcom/krait-cc.c | 14 +++++--------- drivers/clk/qcom/mmcc-msm8960.c | 16 +++++----------- drivers/clk/qcom/mmcc-sdm660.c | 8 ++------ drivers/clk/rockchip/clk-rk3399.c | 9 ++------- drivers/clk/samsung/clk-exynos-clkout.c | 8 +++----- drivers/clk/ti/adpll.c | 14 ++++---------- 13 files changed, 42 insertions(+), 96 deletions(-) diff --git a/drivers/clk/clk-lochnagar.c b/drivers/clk/clk-lochnagar.c index db468a62c8d7..5561a2c66b69 100644 --- a/drivers/clk/clk-lochnagar.c +++ b/drivers/clk/clk-lochnagar.c @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include #include @@ -242,22 +242,17 @@ static int lochnagar_clk_probe(struct platform_device *pdev) }; struct device *dev = &pdev->dev; struct lochnagar_clk_priv *priv; - const struct of_device_id *of_id; struct lochnagar_clk *lclk; struct lochnagar_config *conf; int ret, i; - of_id = of_match_device(lochnagar_of_match, dev); - if (!of_id) - return -EINVAL; - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; priv->dev = dev; priv->regmap = dev_get_regmap(dev->parent, NULL); - conf = (struct lochnagar_config *)of_id->data; + conf = (struct lochnagar_config *)device_get_match_data(dev); memcpy(priv->lclks, conf->clks, sizeof(priv->lclks)); diff --git a/drivers/clk/davinci/da8xx-cfgchip.c b/drivers/clk/davinci/da8xx-cfgchip.c index e5b2cdfe88ce..ad2d0df43dc6 100644 --- a/drivers/clk/davinci/da8xx-cfgchip.c +++ b/drivers/clk/davinci/da8xx-cfgchip.c @@ -11,10 +11,10 @@ #include #include #include -#include #include #include #include +#include #include #include @@ -744,15 +744,13 @@ static int da8xx_cfgchip_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct da8xx_cfgchip_clk_platform_data *pdata = dev->platform_data; - const struct of_device_id *of_id; da8xx_cfgchip_init clk_init = NULL; struct regmap *regmap = NULL; - of_id = of_match_device(da8xx_cfgchip_of_match, dev); - if (of_id) { + clk_init = device_get_match_data(dev); + if (clk_init) { struct device_node *parent; - clk_init = of_id->data; parent = of_get_parent(dev->of_node); regmap = syscon_node_to_regmap(parent); of_node_put(parent); diff --git a/drivers/clk/davinci/pll.c b/drivers/clk/davinci/pll.c index 87bdf8879045..5bbbb3a66477 100644 --- a/drivers/clk/davinci/pll.c +++ b/drivers/clk/davinci/pll.c @@ -18,11 +18,10 @@ #include #include #include -#include -#include #include #include #include +#include #include #include #include @@ -892,14 +891,11 @@ static int davinci_pll_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct davinci_pll_platform_data *pdata; - const struct of_device_id *of_id; davinci_pll_init pll_init = NULL; void __iomem *base; - of_id = of_match_device(davinci_pll_of_match, dev); - if (of_id) - pll_init = of_id->data; - else if (pdev->id_entry) + pll_init = device_get_match_data(dev); + if (!pll_init && pdev->id_entry) pll_init = (void *)pdev->id_entry->driver_data; if (!pll_init) { diff --git a/drivers/clk/davinci/psc.c b/drivers/clk/davinci/psc.c index cd85d9f158b0..355d1be0b5d8 100644 --- a/drivers/clk/davinci/psc.c +++ b/drivers/clk/davinci/psc.c @@ -18,10 +18,9 @@ #include #include #include -#include -#include #include #include +#include #include #include #include @@ -517,15 +516,12 @@ static const struct platform_device_id davinci_psc_id_table[] = { static int davinci_psc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - const struct of_device_id *of_id; const struct davinci_psc_init_data *init_data = NULL; void __iomem *base; int ret; - of_id = of_match_device(davinci_psc_of_match, dev); - if (of_id) - init_data = of_id->data; - else if (pdev->id_entry) + init_data = device_get_match_data(dev); + if (!init_data && pdev->id_entry) init_data = (void *)pdev->id_entry->driver_data; if (!init_data) { diff --git a/drivers/clk/qcom/gcc-msm8960.c b/drivers/clk/qcom/gcc-msm8960.c index dbc7093ab9cc..6236a458e4eb 100644 --- a/drivers/clk/qcom/gcc-msm8960.c +++ b/drivers/clk/qcom/gcc-msm8960.c @@ -7,9 +7,10 @@ #include #include #include +#include #include #include -#include +#include #include #include #include @@ -3716,14 +3717,10 @@ MODULE_DEVICE_TABLE(of, gcc_msm8960_match_table); static int gcc_msm8960_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - const struct of_device_id *match; struct platform_device *tsens; + const struct qcom_cc_desc *desc = device_get_match_data(dev); int ret; - match = of_match_device(gcc_msm8960_match_table, &pdev->dev); - if (!match) - return -EINVAL; - ret = qcom_cc_register_board_clk(dev, "cxo_board", "cxo", 19200000); if (ret) return ret; @@ -3732,11 +3729,11 @@ static int gcc_msm8960_probe(struct platform_device *pdev) if (ret) return ret; - ret = qcom_cc_probe(pdev, match->data); + ret = qcom_cc_probe(pdev, desc); if (ret) return ret; - if (match->data == &gcc_apq8064_desc) { + if (desc == &gcc_apq8064_desc) { hfpll1.d = &hfpll1_8064_data; hfpll_l2.d = &hfpll_l2_8064_data; } diff --git a/drivers/clk/qcom/gcc-msm8974.c b/drivers/clk/qcom/gcc-msm8974.c index 0231c1efd286..b32e66714951 100644 --- a/drivers/clk/qcom/gcc-msm8974.c +++ b/drivers/clk/qcom/gcc-msm8974.c @@ -7,9 +7,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -2875,14 +2875,10 @@ static int gcc_msm8974_probe(struct platform_device *pdev) { int ret; struct device *dev = &pdev->dev; - const struct of_device_id *id; - - id = of_match_device(gcc_msm8974_match_table, dev); - if (!id) - return -ENODEV; + const void *data = device_get_match_data(dev); if (!of_device_is_compatible(dev->of_node, "qcom,gcc-msm8974")) { - if (id->data == &gcc_msm8226_desc) + if (data == &gcc_msm8226_desc) msm8226_clock_override(); else msm8974_pro_clock_override(); diff --git a/drivers/clk/qcom/kpss-xcc.c b/drivers/clk/qcom/kpss-xcc.c index 97358c98c6c9..23b0b11f0007 100644 --- a/drivers/clk/qcom/kpss-xcc.c +++ b/drivers/clk/qcom/kpss-xcc.c @@ -5,10 +5,10 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -32,20 +32,15 @@ MODULE_DEVICE_TABLE(of, kpss_xcc_match_table); static int kpss_xcc_driver_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - const struct of_device_id *id; void __iomem *base; struct clk_hw *hw; const char *name; - id = of_match_device(kpss_xcc_match_table, dev); - if (!id) - return -ENODEV; - base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) return PTR_ERR(base); - if (id->data) { + if (device_get_match_data(&pdev->dev)) { if (of_property_read_string_index(dev->of_node, "clock-output-names", 0, &name)) diff --git a/drivers/clk/qcom/krait-cc.c b/drivers/clk/qcom/krait-cc.c index 410ae8390f1c..ae325f4e1047 100644 --- a/drivers/clk/qcom/krait-cc.c +++ b/drivers/clk/qcom/krait-cc.c @@ -5,10 +5,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -347,22 +347,18 @@ MODULE_DEVICE_TABLE(of, krait_cc_match_table); static int krait_cc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - const struct of_device_id *id; unsigned long cur_rate, aux_rate; int cpu; struct clk_hw *mux, *l2_pri_mux; struct clk *clk, **clks; - - id = of_match_device(krait_cc_match_table, dev); - if (!id) - return -ENODEV; + bool unique_aux = !!device_get_match_data(dev); /* Rate is 1 because 0 causes problems for __clk_mux_determine_rate */ clk = clk_register_fixed_rate(dev, "qsb", NULL, 0, 1); if (IS_ERR(clk)) return PTR_ERR(clk); - if (!id->data) { + if (!unique_aux) { clk = clk_register_fixed_factor(dev, "acpu_aux", "gpll0_vote", 0, 1, 2); if (IS_ERR(clk)) @@ -375,13 +371,13 @@ static int krait_cc_probe(struct platform_device *pdev) return -ENOMEM; for_each_possible_cpu(cpu) { - mux = krait_add_clks(dev, cpu, id->data); + mux = krait_add_clks(dev, cpu, unique_aux); if (IS_ERR(mux)) return PTR_ERR(mux); clks[cpu] = mux->clk; } - l2_pri_mux = krait_add_clks(dev, -1, id->data); + l2_pri_mux = krait_add_clks(dev, -1, unique_aux); if (IS_ERR(l2_pri_mux)) return PTR_ERR(l2_pri_mux); clks[l2_mux] = l2_pri_mux->clk; diff --git a/drivers/clk/qcom/mmcc-msm8960.c b/drivers/clk/qcom/mmcc-msm8960.c index 6bf908a51f53..50638ab341ec 100644 --- a/drivers/clk/qcom/mmcc-msm8960.c +++ b/drivers/clk/qcom/mmcc-msm8960.c @@ -8,9 +8,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -3105,30 +3105,24 @@ MODULE_DEVICE_TABLE(of, mmcc_msm8960_match_table); static int mmcc_msm8960_probe(struct platform_device *pdev) { - const struct of_device_id *match; struct regmap *regmap; - bool is_8064; struct device *dev = &pdev->dev; + const struct qcom_cc_desc *desc = device_get_match_data(dev); - match = of_match_device(mmcc_msm8960_match_table, dev); - if (!match) - return -EINVAL; - - is_8064 = of_device_is_compatible(dev->of_node, "qcom,mmcc-apq8064"); - if (is_8064) { + if (desc == &mmcc_apq8064_desc) { gfx3d_src.freq_tbl = clk_tbl_gfx3d_8064; gfx3d_src.clkr.hw.init = &gfx3d_8064_init; gfx3d_src.s[0].parent_map = mmcc_pxo_pll8_pll2_pll15_map; gfx3d_src.s[1].parent_map = mmcc_pxo_pll8_pll2_pll15_map; } - regmap = qcom_cc_map(pdev, match->data); + regmap = qcom_cc_map(pdev, desc); if (IS_ERR(regmap)) return PTR_ERR(regmap); clk_pll_configure_sr(&pll15, regmap, &pll15_config, false); - return qcom_cc_really_probe(pdev, match->data, regmap); + return qcom_cc_really_probe(pdev, desc, regmap); } static struct platform_driver mmcc_msm8960_driver = { diff --git a/drivers/clk/qcom/mmcc-sdm660.c b/drivers/clk/qcom/mmcc-sdm660.c index bc19a23e13f8..996bd01fb9ac 100644 --- a/drivers/clk/qcom/mmcc-sdm660.c +++ b/drivers/clk/qcom/mmcc-sdm660.c @@ -9,9 +9,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -2828,14 +2828,10 @@ static void sdm630_clock_override(void) static int mmcc_660_probe(struct platform_device *pdev) { - const struct of_device_id *id; struct regmap *regmap; bool is_sdm630; - id = of_match_device(mmcc_660_match_table, &pdev->dev); - if (!id) - return -ENODEV; - is_sdm630 = !!(id->data); + is_sdm630 = !!device_get_match_data(&pdev->dev); regmap = qcom_cc_map(pdev, &mmcc_660_desc); if (IS_ERR(regmap)) diff --git a/drivers/clk/rockchip/clk-rk3399.c b/drivers/clk/rockchip/clk-rk3399.c index 9ebd6c451b3d..9316e5c8a0ea 100644 --- a/drivers/clk/rockchip/clk-rk3399.c +++ b/drivers/clk/rockchip/clk-rk3399.c @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include #include #include #include "clk.h" @@ -1634,14 +1634,9 @@ static const struct of_device_id clk_rk3399_match_table[] = { static int __init clk_rk3399_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - const struct of_device_id *match; const struct clk_rk3399_inits *init_data; - match = of_match_device(clk_rk3399_match_table, &pdev->dev); - if (!match || !match->data) - return -EINVAL; - - init_data = match->data; + init_data = device_get_match_data(&pdev->dev); if (init_data->inits) init_data->inits(np); diff --git a/drivers/clk/samsung/clk-exynos-clkout.c b/drivers/clk/samsung/clk-exynos-clkout.c index 72b6cf83aff4..3484e6cc80ad 100644 --- a/drivers/clk/samsung/clk-exynos-clkout.c +++ b/drivers/clk/samsung/clk-exynos-clkout.c @@ -13,9 +13,9 @@ #include #include #include -#include #include #include +#include #define EXYNOS_CLKOUT_NR_CLKS 1 #define EXYNOS_CLKOUT_PARENTS 32 @@ -84,19 +84,17 @@ MODULE_DEVICE_TABLE(of, exynos_clkout_ids); static int exynos_clkout_match_parent_dev(struct device *dev, u32 *mux_mask) { const struct exynos_clkout_variant *variant; - const struct of_device_id *match; if (!dev->parent) { dev_err(dev, "not instantiated from MFD\n"); return -EINVAL; } - match = of_match_device(exynos_clkout_ids, dev->parent); - if (!match) { + variant = device_get_match_data(dev->parent); + if (!variant) { dev_err(dev, "cannot match parent device\n"); return -EINVAL; } - variant = match->data; *mux_mask = variant->mux_mask; diff --git a/drivers/clk/ti/adpll.c b/drivers/clk/ti/adpll.c index ff42ea75cb43..6121020b4b38 100644 --- a/drivers/clk/ti/adpll.c +++ b/drivers/clk/ti/adpll.c @@ -8,7 +8,9 @@ #include #include #include -#include +#include +#include +#include #include #define ADPLL_PLLSS_MMR_LOCK_OFFSET 0x00 /* Managed by MPPULL */ @@ -860,24 +862,16 @@ static int ti_adpll_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; struct device *dev = &pdev->dev; - const struct of_device_id *match; - const struct ti_adpll_platform_data *pdata; struct ti_adpll_data *d; struct resource *res; int err; - match = of_match_device(ti_adpll_match, dev); - if (match) - pdata = match->data; - else - return -ENODEV; - d = devm_kzalloc(dev, sizeof(*d), GFP_KERNEL); if (!d) return -ENOMEM; d->dev = dev; d->np = node; - d->c = pdata; + d->c = device_get_match_data(dev); dev_set_drvdata(d->dev, d); spin_lock_init(&d->lock); -- cgit From 7e52b1164a474dc7b90f68fbb40e35ccd7f7e2e2 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 27 Oct 2023 10:58:24 +0200 Subject: clk: si521xx: Increase stack based print buffer size in probe Increase the size of temporary print buffer on stack to fix the following warnings reported by LKP. Since all the input parameters of snprintf() are under control of this driver, it is not possible to trigger and overflow here, but since the print buffer is on stack and discarded once driver probe() finishes, it is not an issue to increase it by 10 bytes and fix the warning in the process. Make it so. " drivers/clk/clk-si521xx.c: In function 'si521xx_probe': >> drivers/clk/clk-si521xx.c:318:26: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=] snprintf(name, 6, "DIFF%d", i); ^~ drivers/clk/clk-si521xx.c:318:21: note: directive argument in the range [0, 2147483647] snprintf(name, 6, "DIFF%d", i); ^~~~~~~~ drivers/clk/clk-si521xx.c:318:3: note: 'snprintf' output between 6 and 15 bytes into a destination of size 6 snprintf(name, 6, "DIFF%d", i); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " Fixes: edc12763a3a2 ("clk: si521xx: Clock driver for Skyworks Si521xx I2C PCIe clock generators") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202310260412.AGASjFN4-lkp@intel.com/ Signed-off-by: Marek Vasut Link: https://lore.kernel.org/r/20231027085840.30098-1-marex@denx.de Signed-off-by: Stephen Boyd --- drivers/clk/clk-si521xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk-si521xx.c b/drivers/clk/clk-si521xx.c index 14c8741b9ba0..0f8da64f87bb 100644 --- a/drivers/clk/clk-si521xx.c +++ b/drivers/clk/clk-si521xx.c @@ -282,7 +282,7 @@ static int si521xx_probe(struct i2c_client *client) const u16 chip_info = (u16)(uintptr_t)i2c_get_match_data(client); const struct clk_parent_data clk_parent_data = { .index = 0 }; struct si521xx *si; - unsigned char name[6] = "DIFF0"; + unsigned char name[16] = "DIFF0"; struct clk_init_data init = {}; int i, ret; @@ -315,7 +315,7 @@ static int si521xx_probe(struct i2c_client *client) /* Register clock */ for (i = 0; i < hweight16(chip_info); i++) { memset(&init, 0, sizeof(init)); - snprintf(name, 6, "DIFF%d", i); + snprintf(name, sizeof(name), "DIFF%d", i); init.name = name; init.ops = &si521xx_diff_clk_ops; init.parent_data = &clk_parent_data; -- cgit