From a95fb581b144b5e73da382eaedb2e32027610597 Mon Sep 17 00:00:00 2001 From: Nathan Huckleberry Date: Thu, 27 Jun 2019 15:06:42 -0700 Subject: clk: qoriq: Fix -Wunused-const-variable drivers/clk/clk-qoriq.c:138:38: warning: unused variable 'p5020_cmux_grp1' [-Wunused-const-variable] static const struct clockgen_muxinfo p5020_cmux_grp1 drivers/clk/clk-qoriq.c:146:38: warning: unused variable 'p5020_cmux_grp2' [-Wunused-const-variable] static const struct clockgen_muxinfo p5020_cmux_grp2 In the definition of the p5020 chip, the p2041 chip's info was used instead. The p5020 and p2041 chips have different info. This is most likely a typo. Link: https://github.com/ClangBuiltLinux/linux/issues/525 Cc: clang-built-linux@googlegroups.com Signed-off-by: Nathan Huckleberry Link: https://lkml.kernel.org/r/20190627220642.78575-1-nhuck@google.com Reviewed-by: Nick Desaulniers Acked-by: Scott Wood Signed-off-by: Stephen Boyd --- drivers/clk/clk-qoriq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/clk') diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c index 07f3b252f3e0..bed140f7375f 100644 --- a/drivers/clk/clk-qoriq.c +++ b/drivers/clk/clk-qoriq.c @@ -686,7 +686,7 @@ static const struct clockgen_chipinfo chipinfo[] = { .guts_compat = "fsl,qoriq-device-config-1.0", .init_periph = p5020_init_periph, .cmux_groups = { - &p2041_cmux_grp1, &p2041_cmux_grp2 + &p5020_cmux_grp1, &p5020_cmux_grp2 }, .cmux_to_group = { 0, 1, -1 -- cgit v1.2.3-59-g8ed1b From e2f2402f3be89e4407d94d92d326204f70261754 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 1 Jul 2019 17:50:20 +0100 Subject: clk: Si5341/Si5340: remove redundant assignment to n_den The variable n_den is initialized however that value is never read as n_den is re-assigned a little later in the two paths of a following if-statement. Remove the redundant assignment. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Link: https://lkml.kernel.org/r/20190701165020.19840-1-colin.king@canonical.com Acked-by: Mike Looijmans Signed-off-by: Stephen Boyd --- drivers/clk/clk-si5341.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/clk') diff --git a/drivers/clk/clk-si5341.c b/drivers/clk/clk-si5341.c index 72424eb7e5f8..6e780c2a9e6b 100644 --- a/drivers/clk/clk-si5341.c +++ b/drivers/clk/clk-si5341.c @@ -547,7 +547,6 @@ static int si5341_synth_clk_set_rate(struct clk_hw *hw, unsigned long rate, bool is_integer; n_num = synth->data->freq_vco; - n_den = rate; /* see if there's an integer solution */ r = do_div(n_num, rate); -- cgit v1.2.3-59-g8ed1b From 5911dba556cf41a14907ed04b5636cf852b17933 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Sun, 4 Aug 2019 22:04:44 +0530 Subject: clk: versatile: Add of_node_put() in cm_osc_setup() In function cm_osc_setup, variable parent takes the value returned by of_get_parent, which gets a node but does not put it. If parent is not put before it goes out of scope, it may cause a memory leak. Hence put parent before the function terminates. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lkml.kernel.org/r/20190804163445.6862-1-nishkadg.linux@gmail.com Reviewed-by: Linus Walleij Signed-off-by: Stephen Boyd --- drivers/clk/versatile/clk-versatile.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/clk') diff --git a/drivers/clk/versatile/clk-versatile.c b/drivers/clk/versatile/clk-versatile.c index 90bb0b041b7a..fd54d5c0251c 100644 --- a/drivers/clk/versatile/clk-versatile.c +++ b/drivers/clk/versatile/clk-versatile.c @@ -70,6 +70,7 @@ static void __init cm_osc_setup(struct device_node *np, return; } cm_base = of_iomap(parent, 0); + of_node_put(parent); if (!cm_base) { pr_err("could not remap core module base\n"); return; -- cgit v1.2.3-59-g8ed1b From d55841ce1115ce08614bde66a780211f4ea12ae1 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Sun, 4 Aug 2019 21:58:24 +0530 Subject: clk: davinci: pll: Add of_node_put() in of_davinci_pll_init() The variable child in the function of_davinci_pll_init takes the value of of_get_child_by_name, which gets a node but does not put it. If child is not put before the function returns it may cause a memory leak. Hence put child before two return statements. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lkml.kernel.org/r/20190804162824.6338-1-nishkadg.linux@gmail.com Signed-off-by: Stephen Boyd --- drivers/clk/davinci/pll.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/clk') diff --git a/drivers/clk/davinci/pll.c b/drivers/clk/davinci/pll.c index 1c99e992d638..1ac11b6a47a3 100644 --- a/drivers/clk/davinci/pll.c +++ b/drivers/clk/davinci/pll.c @@ -778,12 +778,15 @@ int of_davinci_pll_init(struct device *dev, struct device_node *node, int i; clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); - if (!clk_data) + if (!clk_data) { + of_node_put(child); return -ENOMEM; + } clks = kmalloc_array(n_clks, sizeof(*clks), GFP_KERNEL); if (!clks) { kfree(clk_data); + of_node_put(child); return -ENOMEM; } -- cgit v1.2.3-59-g8ed1b From d432d04560301c6350158dc4a7e8275b331fd480 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Sun, 4 Aug 2019 22:01:51 +0530 Subject: clk: st: clk-flexgen: Add of_node_put() in st_of_flexgen_setup() In function st_of_flexgen_setup, variable pnode takes the return value of of_get_parent, which gets a node but does not put it. If pnode is not put before the function returns, it may cause a memory leak. Hence put pnode after its last occurrence. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lkml.kernel.org/r/20190804163151.6511-1-nishkadg.linux@gmail.com Signed-off-by: Stephen Boyd --- drivers/clk/st/clk-flexgen.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/clk') diff --git a/drivers/clk/st/clk-flexgen.c b/drivers/clk/st/clk-flexgen.c index d18e49b4976f..4413b6e04a8e 100644 --- a/drivers/clk/st/clk-flexgen.c +++ b/drivers/clk/st/clk-flexgen.c @@ -326,6 +326,7 @@ static void __init st_of_flexgen_setup(struct device_node *np) return; reg = of_iomap(pnode, 0); + of_node_put(pnode); if (!reg) return; -- cgit v1.2.3-59-g8ed1b From b684702f6e471d5e7dd80dfbb926489b87f60bd8 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Sun, 4 Aug 2019 22:03:28 +0530 Subject: clk: ti: dm814x: Add of_node_put() to prevent memory leak In function dm814x_adpll_early_init, variable np takes the value returned by of_find_node_by_name, which gets a node but does not put it. If np is not put before return, it may cause a memory leak. Hence put np before return. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lkml.kernel.org/r/20190804163328.6693-1-nishkadg.linux@gmail.com Signed-off-by: Stephen Boyd --- drivers/clk/ti/clk-814x.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/clk') diff --git a/drivers/clk/ti/clk-814x.c b/drivers/clk/ti/clk-814x.c index e8cee6f3b4a0..087cfa75ac24 100644 --- a/drivers/clk/ti/clk-814x.c +++ b/drivers/clk/ti/clk-814x.c @@ -66,6 +66,7 @@ static int __init dm814x_adpll_early_init(void) } of_platform_populate(np, NULL, NULL, NULL); + of_node_put(np); return 0; } -- cgit v1.2.3-59-g8ed1b From 1bd37a46770017e89943769112c5f09e5a7b24c1 Mon Sep 17 00:00:00 2001 From: Leonard Crestez Date: Tue, 2 Jul 2019 16:27:09 +0300 Subject: clk: Add clk_min/max_rate entries in debugfs Add two files to expose min/max clk rates as determined by clk_core_get_boundaries, taking all consumer requests into account. This information does not appear to be otherwise exposed to userspace. Signed-off-by: Leonard Crestez Link: https://lkml.kernel.org/r/68e96af2df96512300604d797ade2088d7e6e496.1562073871.git.leonard.crestez@nxp.com [sboyd@kernel.org: Drop if statements for JSON printing] Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'drivers/clk') diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index c0990703ce54..a7cee0fac071 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2896,15 +2896,21 @@ DEFINE_SHOW_ATTRIBUTE(clk_summary); static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level) { + unsigned long min_rate, max_rate; + if (!c) return; + clk_core_get_boundaries(c, &min_rate, &max_rate); + /* This should be JSON format, i.e. elements separated with a comma */ seq_printf(s, "\"%s\": { ", c->name); seq_printf(s, "\"enable_count\": %d,", c->enable_count); seq_printf(s, "\"prepare_count\": %d,", c->prepare_count); seq_printf(s, "\"protect_count\": %d,", c->protect_count); seq_printf(s, "\"rate\": %lu,", clk_core_get_rate(c)); + seq_printf(s, "\"min_rate\": %lu,", min_rate); + seq_printf(s, "\"max_rate\": %lu,", max_rate); seq_printf(s, "\"accuracy\": %lu,", clk_core_get_accuracy(c)); seq_printf(s, "\"phase\": %d,", clk_core_get_phase(c)); seq_printf(s, "\"duty_cycle\": %u", @@ -3064,6 +3070,34 @@ static int clk_duty_cycle_show(struct seq_file *s, void *data) } DEFINE_SHOW_ATTRIBUTE(clk_duty_cycle); +static int clk_min_rate_show(struct seq_file *s, void *data) +{ + struct clk_core *core = s->private; + unsigned long min_rate, max_rate; + + clk_prepare_lock(); + clk_core_get_boundaries(core, &min_rate, &max_rate); + clk_prepare_unlock(); + seq_printf(s, "%lu\n", min_rate); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(clk_min_rate); + +static int clk_max_rate_show(struct seq_file *s, void *data) +{ + struct clk_core *core = s->private; + unsigned long min_rate, max_rate; + + clk_prepare_lock(); + clk_core_get_boundaries(core, &min_rate, &max_rate); + clk_prepare_unlock(); + seq_printf(s, "%lu\n", max_rate); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(clk_max_rate); + static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry) { struct dentry *root; @@ -3075,6 +3109,8 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry) core->dentry = root; debugfs_create_ulong("clk_rate", 0444, root, &core->rate); + debugfs_create_file("clk_min_rate", 0444, root, core, &clk_min_rate_fops); + debugfs_create_file("clk_max_rate", 0444, root, core, &clk_max_rate_fops); debugfs_create_ulong("clk_accuracy", 0444, root, &core->accuracy); debugfs_create_u32("clk_phase", 0444, root, &core->phase); debugfs_create_file("clk_flags", 0444, root, core, &clk_flags_fops); -- cgit v1.2.3-59-g8ed1b From 9f7767226083d51c0674f1b71ac52daea6778b84 Mon Sep 17 00:00:00 2001 From: Leonard Crestez Date: Tue, 2 Jul 2019 16:27:10 +0300 Subject: clk: Assert prepare_lock in clk_core_get_boundaries This function iterates the clk consumer list on clk_core so it must be called under prepare_lock. This is already done by all callers but add a lockdep assert to check anyway. Signed-off-by: Leonard Crestez Link: https://lkml.kernel.org/r/29453ee8e820457d87a8faf9d496390e59c6826f.1562073871.git.leonard.crestez@nxp.com Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/clk') diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index a7cee0fac071..991fb3a62bda 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -593,6 +593,8 @@ static void clk_core_get_boundaries(struct clk_core *core, { struct clk *clk_user; + lockdep_assert_held(&prepare_lock); + *min_rate = core->min_rate; *max_rate = core->max_rate; -- cgit v1.2.3-59-g8ed1b From 1ccc0ddf046a0197f2f9acca02a64da10aa6112d Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Mon, 1 Jul 2019 22:20:40 +0200 Subject: clk: Use seq_puts() in possible_parent_show() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A string which did not contain a data format specification should be put into a sequence. Thus use the corresponding function “seq_puts”. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/clk') diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 991fb3a62bda..b6f50db759a4 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3021,15 +3021,15 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core, */ parent = clk_core_get_parent_by_index(core, i); if (parent) - seq_printf(s, "%s", parent->name); + seq_puts(s, parent->name); else if (core->parents[i].name) - seq_printf(s, "%s", core->parents[i].name); + seq_puts(s, core->parents[i].name); else if (core->parents[i].fw_name) seq_printf(s, "<%s>(fw)", core->parents[i].fw_name); else if (core->parents[i].index >= 0) - seq_printf(s, "%s", - of_clk_get_parent_name(core->of_node, - core->parents[i].index)); + seq_puts(s, + of_clk_get_parent_name(core->of_node, + core->parents[i].index)); else seq_puts(s, "(missing)"); -- cgit v1.2.3-59-g8ed1b From b0740d71cb56149aae04adad1746c3565ac5b278 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Wed, 14 Aug 2019 21:25:00 -0700 Subject: clk: composite: Drop unused clk.h include This include isn't used. Drop it. Signed-off-by: Stephen Boyd Link: https://lkml.kernel.org/r/20190815042500.9519-1-sboyd@kernel.org --- drivers/clk/clk-composite.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/clk') diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c index b06038b8f658..4f13a681ddfc 100644 --- a/drivers/clk/clk-composite.c +++ b/drivers/clk/clk-composite.c @@ -3,7 +3,6 @@ * Copyright (c) 2013 NVIDIA CORPORATION. All rights reserved. */ -#include #include #include #include -- cgit v1.2.3-59-g8ed1b From e03a47deaff424976fe9f6e1f1550f321a6dda75 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Fri, 16 Aug 2019 21:53:41 +0800 Subject: clk: st: clkgen-fsyn: remove unused variable 'st_quadfs_fs660c32_ops' drivers/clk/st/clkgen-fsyn.c:70:29: warning: st_quadfs_fs660c32_ops defined but not used [-Wunused-const-variable=] It is never used, so can be removed. Reported-by: Hulk Robot Signed-off-by: YueHaibing Link: https://lkml.kernel.org/r/20190816135341.52248-1-yuehaibing@huawei.com Acked-by: Gabriel Fernandez Signed-off-by: Stephen Boyd --- drivers/clk/st/clkgen-fsyn.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/clk') diff --git a/drivers/clk/st/clkgen-fsyn.c b/drivers/clk/st/clkgen-fsyn.c index ca1ccdb8a3b1..a156bd0c6af7 100644 --- a/drivers/clk/st/clkgen-fsyn.c +++ b/drivers/clk/st/clkgen-fsyn.c @@ -67,7 +67,6 @@ struct clkgen_quadfs_data { }; static const struct clk_ops st_quadfs_pll_c32_ops; -static const struct clk_ops st_quadfs_fs660c32_ops; static int clk_fs660c32_dig_get_params(unsigned long input, unsigned long output, struct stm_fs *fs); -- cgit v1.2.3-59-g8ed1b From 8863a5bf689adbf676702cd291f53a86f5a4e1ad Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Fri, 16 Aug 2019 21:55:23 +0800 Subject: clk: st: clkgen-pll: remove unused variable 'st_pll3200c32_407_a0' drivers/clk/st/clkgen-pll.c:64:37: warning: st_pll3200c32_407_a0 defined but not used [-Wunused-const-variable=] It is never used, so can be removed. Reported-by: Hulk Robot Signed-off-by: YueHaibing Link: https://lkml.kernel.org/r/20190816135523.73520-1-yuehaibing@huawei.com Acked-by: Gabriel Fernandez Signed-off-by: Stephen Boyd --- drivers/clk/st/clkgen-pll.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'drivers/clk') diff --git a/drivers/clk/st/clkgen-pll.c b/drivers/clk/st/clkgen-pll.c index d8a688bd45ec..c3952f2c42ba 100644 --- a/drivers/clk/st/clkgen-pll.c +++ b/drivers/clk/st/clkgen-pll.c @@ -61,19 +61,6 @@ static const struct clk_ops stm_pll3200c32_ops; static const struct clk_ops stm_pll3200c32_a9_ops; static const struct clk_ops stm_pll4600c28_ops; -static const struct clkgen_pll_data st_pll3200c32_407_a0 = { - /* 407 A0 */ - .pdn_status = CLKGEN_FIELD(0x2a0, 0x1, 8), - .pdn_ctrl = CLKGEN_FIELD(0x2a0, 0x1, 8), - .locked_status = CLKGEN_FIELD(0x2a0, 0x1, 24), - .ndiv = CLKGEN_FIELD(0x2a4, C32_NDIV_MASK, 16), - .idf = CLKGEN_FIELD(0x2a4, C32_IDF_MASK, 0x0), - .num_odfs = 1, - .odf = { CLKGEN_FIELD(0x2b4, C32_ODF_MASK, 0) }, - .odf_gate = { CLKGEN_FIELD(0x2b4, 0x1, 6) }, - .ops = &stm_pll3200c32_ops, -}; - static const struct clkgen_pll_data st_pll3200c32_cx_0 = { /* 407 C0 PLL0 */ .pdn_status = CLKGEN_FIELD(0x2a0, 0x1, 8), -- cgit v1.2.3-59-g8ed1b From 7f4804665b58ced5d09848785d835af0f7a51b3e Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Mon, 26 Aug 2019 16:47:29 -0700 Subject: clk: Drop !clk checks in debugfs dumping These recursive functions have checks for !clk being passed in, but the callers are always looping through lists and therefore the pointers can't be NULL. Drop the checks to simplify the code. Signed-off-by: Stephen Boyd Link: https://lkml.kernel.org/r/20190826234729.145593-1-sboyd@kernel.org --- drivers/clk/clk.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'drivers/clk') diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b6f50db759a4..7783c25fb407 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2849,9 +2849,6 @@ static struct hlist_head *orphan_list[] = { static void clk_summary_show_one(struct seq_file *s, struct clk_core *c, int level) { - if (!c) - return; - seq_printf(s, "%*s%-*s %7d %8d %8d %11lu %10lu %5d %6d\n", level * 3 + 1, "", 30 - level * 3, c->name, @@ -2866,9 +2863,6 @@ static void clk_summary_show_subtree(struct seq_file *s, struct clk_core *c, { struct clk_core *child; - if (!c) - return; - clk_summary_show_one(s, c, level); hlist_for_each_entry(child, &c->children, child_node) @@ -2900,9 +2894,6 @@ static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level) { unsigned long min_rate, max_rate; - if (!c) - return; - clk_core_get_boundaries(c, &min_rate, &max_rate); /* This should be JSON format, i.e. elements separated with a comma */ @@ -2923,9 +2914,6 @@ static void clk_dump_subtree(struct seq_file *s, struct clk_core *c, int level) { struct clk_core *child; - if (!c) - return; - clk_dump_one(s, c, level); hlist_for_each_entry(child, &c->children, child_node) { -- cgit v1.2.3-59-g8ed1b