aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/clk.txt16
-rw-r--r--drivers/clk/clk.c60
-rw-r--r--drivers/clk/qcom/clk-smd-rpm.c9
-rw-r--r--drivers/clk/qcom/gcc-msm8996.c8
-rw-r--r--drivers/clk/versatile/clk-vexpress-osc.c5
-rw-r--r--include/linux/clk.h16
6 files changed, 36 insertions, 78 deletions
diff --git a/Documentation/clk.txt b/Documentation/clk.txt
index be909ed45970..511628bb3d3a 100644
--- a/Documentation/clk.txt
+++ b/Documentation/clk.txt
@@ -268,9 +268,19 @@ The common clock framework uses two global locks, the prepare lock and the
268enable lock. 268enable lock.
269 269
270The enable lock is a spinlock and is held across calls to the .enable, 270The enable lock is a spinlock and is held across calls to the .enable,
271.disable and .is_enabled operations. Those operations are thus not allowed to 271.disable operations. Those operations are thus not allowed to sleep,
272sleep, and calls to the clk_enable(), clk_disable() and clk_is_enabled() API 272and calls to the clk_enable(), clk_disable() API functions are allowed in
273functions are allowed in atomic context. 273atomic context.
274
275For clk_is_enabled() API, it is also designed to be allowed to be used in
276atomic context. However, it doesn't really make any sense to hold the enable
277lock in core, unless you want to do something else with the information of
278the enable state with that lock held. Otherwise, seeing if a clk is enabled is
279a one-shot read of the enabled state, which could just as easily change after
280the function returns because the lock is released. Thus the user of this API
281needs to handle synchronizing the read of the state with whatever they're
282using it for to make sure that the enable state doesn't change during that
283time.
274 284
275The prepare lock is a mutex and is held across calls to all other operations. 285The prepare lock is a mutex and is held across calls to all other operations.
276All those operations are allowed to sleep, and calls to the corresponding API 286All those operations are allowed to sleep, and calls to the corresponding API
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 9d56be6ead39..037035a46b33 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2488,19 +2488,7 @@ static int clk_summary_show(struct seq_file *s, void *data)
2488 2488
2489 return 0; 2489 return 0;
2490} 2490}
2491 2491DEFINE_SHOW_ATTRIBUTE(clk_summary);
2492
2493static int clk_summary_open(struct inode *inode, struct file *file)
2494{
2495 return single_open(file, clk_summary_show, inode->i_private);
2496}
2497
2498static const struct file_operations clk_summary_fops = {
2499 .open = clk_summary_open,
2500 .read = seq_read,
2501 .llseek = seq_lseek,
2502 .release = single_release,
2503};
2504 2492
2505static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level) 2493static void clk_dump_one(struct seq_file *s, struct clk_core *c, int level)
2506{ 2494{
@@ -2534,7 +2522,7 @@ static void clk_dump_subtree(struct seq_file *s, struct clk_core *c, int level)
2534 seq_putc(s, '}'); 2522 seq_putc(s, '}');
2535} 2523}
2536 2524
2537static int clk_dump(struct seq_file *s, void *data) 2525static int clk_dump_show(struct seq_file *s, void *data)
2538{ 2526{
2539 struct clk_core *c; 2527 struct clk_core *c;
2540 bool first_node = true; 2528 bool first_node = true;
@@ -2557,19 +2545,7 @@ static int clk_dump(struct seq_file *s, void *data)
2557 seq_puts(s, "}\n"); 2545 seq_puts(s, "}\n");
2558 return 0; 2546 return 0;
2559} 2547}
2560 2548DEFINE_SHOW_ATTRIBUTE(clk_dump);
2561
2562static int clk_dump_open(struct inode *inode, struct file *file)
2563{
2564 return single_open(file, clk_dump, inode->i_private);
2565}
2566
2567static const struct file_operations clk_dump_fops = {
2568 .open = clk_dump_open,
2569 .read = seq_read,
2570 .llseek = seq_lseek,
2571 .release = single_release,
2572};
2573 2549
2574static const struct { 2550static const struct {
2575 unsigned long flag; 2551 unsigned long flag;
@@ -2591,7 +2567,7 @@ static const struct {
2591#undef ENTRY 2567#undef ENTRY
2592}; 2568};
2593 2569
2594static int clk_flags_dump(struct seq_file *s, void *data) 2570static int clk_flags_show(struct seq_file *s, void *data)
2595{ 2571{
2596 struct clk_core *core = s->private; 2572 struct clk_core *core = s->private;
2597 unsigned long flags = core->flags; 2573 unsigned long flags = core->flags;
@@ -2610,20 +2586,9 @@ static int clk_flags_dump(struct seq_file *s, void *data)
2610 2586
2611 return 0; 2587 return 0;
2612} 2588}
2589DEFINE_SHOW_ATTRIBUTE(clk_flags);
2613 2590
2614static int clk_flags_open(struct inode *inode, struct file *file) 2591static int possible_parents_show(struct seq_file *s, void *data)
2615{
2616 return single_open(file, clk_flags_dump, inode->i_private);
2617}
2618
2619static const struct file_operations clk_flags_fops = {
2620 .open = clk_flags_open,
2621 .read = seq_read,
2622 .llseek = seq_lseek,
2623 .release = single_release,
2624};
2625
2626static int possible_parents_dump(struct seq_file *s, void *data)
2627{ 2592{
2628 struct clk_core *core = s->private; 2593 struct clk_core *core = s->private;
2629 int i; 2594 int i;
@@ -2635,18 +2600,7 @@ static int possible_parents_dump(struct seq_file *s, void *data)
2635 2600
2636 return 0; 2601 return 0;
2637} 2602}
2638 2603DEFINE_SHOW_ATTRIBUTE(possible_parents);
2639static int possible_parents_open(struct inode *inode, struct file *file)
2640{
2641 return single_open(file, possible_parents_dump, inode->i_private);
2642}
2643
2644static const struct file_operations possible_parents_fops = {
2645 .open = possible_parents_open,
2646 .read = seq_read,
2647 .llseek = seq_lseek,
2648 .release = single_release,
2649};
2650 2604
2651static int clk_debug_create_one(struct clk_core *core, struct dentry *pdentry) 2605static int clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
2652{ 2606{
diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c
index c26d9007bfc4..850c02a52248 100644
--- a/drivers/clk/qcom/clk-smd-rpm.c
+++ b/drivers/clk/qcom/clk-smd-rpm.c
@@ -686,7 +686,7 @@ static int rpm_smd_clk_probe(struct platform_device *pdev)
686 goto err; 686 goto err;
687 } 687 }
688 688
689 ret = of_clk_add_hw_provider(pdev->dev.of_node, qcom_smdrpm_clk_hw_get, 689 ret = devm_of_clk_add_hw_provider(&pdev->dev, qcom_smdrpm_clk_hw_get,
690 rcc); 690 rcc);
691 if (ret) 691 if (ret)
692 goto err; 692 goto err;
@@ -697,19 +697,12 @@ err:
697 return ret; 697 return ret;
698} 698}
699 699
700static int rpm_smd_clk_remove(struct platform_device *pdev)
701{
702 of_clk_del_provider(pdev->dev.of_node);
703 return 0;
704}
705
706static struct platform_driver rpm_smd_clk_driver = { 700static struct platform_driver rpm_smd_clk_driver = {
707 .driver = { 701 .driver = {
708 .name = "qcom-clk-smd-rpm", 702 .name = "qcom-clk-smd-rpm",
709 .of_match_table = rpm_smd_clk_match_table, 703 .of_match_table = rpm_smd_clk_match_table,
710 }, 704 },
711 .probe = rpm_smd_clk_probe, 705 .probe = rpm_smd_clk_probe,
712 .remove = rpm_smd_clk_remove,
713}; 706};
714 707
715static int __init rpm_smd_clk_init(void) 708static int __init rpm_smd_clk_init(void)
diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c
index 5d7451209206..3d6452932797 100644
--- a/drivers/clk/qcom/gcc-msm8996.c
+++ b/drivers/clk/qcom/gcc-msm8996.c
@@ -2895,7 +2895,7 @@ static struct clk_branch gcc_aggre0_snoc_axi_clk = {
2895 .name = "gcc_aggre0_snoc_axi_clk", 2895 .name = "gcc_aggre0_snoc_axi_clk",
2896 .parent_names = (const char *[]){ "system_noc_clk_src" }, 2896 .parent_names = (const char *[]){ "system_noc_clk_src" },
2897 .num_parents = 1, 2897 .num_parents = 1,
2898 .flags = CLK_SET_RATE_PARENT, 2898 .flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
2899 .ops = &clk_branch2_ops, 2899 .ops = &clk_branch2_ops,
2900 }, 2900 },
2901 }, 2901 },
@@ -2910,7 +2910,7 @@ static struct clk_branch gcc_aggre0_cnoc_ahb_clk = {
2910 .name = "gcc_aggre0_cnoc_ahb_clk", 2910 .name = "gcc_aggre0_cnoc_ahb_clk",
2911 .parent_names = (const char *[]){ "config_noc_clk_src" }, 2911 .parent_names = (const char *[]){ "config_noc_clk_src" },
2912 .num_parents = 1, 2912 .num_parents = 1,
2913 .flags = CLK_SET_RATE_PARENT, 2913 .flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
2914 .ops = &clk_branch2_ops, 2914 .ops = &clk_branch2_ops,
2915 }, 2915 },
2916 }, 2916 },
@@ -2925,7 +2925,7 @@ static struct clk_branch gcc_smmu_aggre0_axi_clk = {
2925 .name = "gcc_smmu_aggre0_axi_clk", 2925 .name = "gcc_smmu_aggre0_axi_clk",
2926 .parent_names = (const char *[]){ "system_noc_clk_src" }, 2926 .parent_names = (const char *[]){ "system_noc_clk_src" },
2927 .num_parents = 1, 2927 .num_parents = 1,
2928 .flags = CLK_SET_RATE_PARENT, 2928 .flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
2929 .ops = &clk_branch2_ops, 2929 .ops = &clk_branch2_ops,
2930 }, 2930 },
2931 }, 2931 },
@@ -2940,7 +2940,7 @@ static struct clk_branch gcc_smmu_aggre0_ahb_clk = {
2940 .name = "gcc_smmu_aggre0_ahb_clk", 2940 .name = "gcc_smmu_aggre0_ahb_clk",
2941 .parent_names = (const char *[]){ "config_noc_clk_src" }, 2941 .parent_names = (const char *[]){ "config_noc_clk_src" },
2942 .num_parents = 1, 2942 .num_parents = 1,
2943 .flags = CLK_SET_RATE_PARENT, 2943 .flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL,
2944 .ops = &clk_branch2_ops, 2944 .ops = &clk_branch2_ops,
2945 }, 2945 },
2946 }, 2946 },
diff --git a/drivers/clk/versatile/clk-vexpress-osc.c b/drivers/clk/versatile/clk-vexpress-osc.c
index e7a868b83fe5..dd08ecb498be 100644
--- a/drivers/clk/versatile/clk-vexpress-osc.c
+++ b/drivers/clk/versatile/clk-vexpress-osc.c
@@ -44,10 +44,10 @@ static long vexpress_osc_round_rate(struct clk_hw *hw, unsigned long rate,
44{ 44{
45 struct vexpress_osc *osc = to_vexpress_osc(hw); 45 struct vexpress_osc *osc = to_vexpress_osc(hw);
46 46
47 if (WARN_ON(osc->rate_min && rate < osc->rate_min)) 47 if (osc->rate_min && rate < osc->rate_min)
48 rate = osc->rate_min; 48 rate = osc->rate_min;
49 49
50 if (WARN_ON(osc->rate_max && rate > osc->rate_max)) 50 if (osc->rate_max && rate > osc->rate_max)
51 rate = osc->rate_max; 51 rate = osc->rate_max;
52 52
53 return rate; 53 return rate;
@@ -104,6 +104,7 @@ static int vexpress_osc_probe(struct platform_device *pdev)
104 return PTR_ERR(clk); 104 return PTR_ERR(clk);
105 105
106 of_clk_add_provider(pdev->dev.of_node, of_clk_src_simple_get, clk); 106 of_clk_add_provider(pdev->dev.of_node, of_clk_src_simple_get, clk);
107 clk_hw_set_rate_range(&osc->hw, osc->rate_min, osc->rate_max);
107 108
108 dev_dbg(&pdev->dev, "Registered clock '%s'\n", init.name); 109 dev_dbg(&pdev->dev, "Registered clock '%s'\n", init.name);
109 110
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 4c4ef9f34db3..0dbd0885b2c2 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -209,7 +209,7 @@ static inline int clk_prepare(struct clk *clk)
209 return 0; 209 return 0;
210} 210}
211 211
212static inline int clk_bulk_prepare(int num_clks, struct clk_bulk_data *clks) 212static inline int __must_check clk_bulk_prepare(int num_clks, struct clk_bulk_data *clks)
213{ 213{
214 might_sleep(); 214 might_sleep();
215 return 0; 215 return 0;
@@ -603,8 +603,8 @@ static inline struct clk *clk_get(struct device *dev, const char *id)
603 return NULL; 603 return NULL;
604} 604}
605 605
606static inline int clk_bulk_get(struct device *dev, int num_clks, 606static inline int __must_check clk_bulk_get(struct device *dev, int num_clks,
607 struct clk_bulk_data *clks) 607 struct clk_bulk_data *clks)
608{ 608{
609 return 0; 609 return 0;
610} 610}
@@ -614,8 +614,8 @@ static inline struct clk *devm_clk_get(struct device *dev, const char *id)
614 return NULL; 614 return NULL;
615} 615}
616 616
617static inline int devm_clk_bulk_get(struct device *dev, int num_clks, 617static inline int __must_check devm_clk_bulk_get(struct device *dev, int num_clks,
618 struct clk_bulk_data *clks) 618 struct clk_bulk_data *clks)
619{ 619{
620 return 0; 620 return 0;
621} 621}
@@ -645,7 +645,7 @@ static inline int clk_enable(struct clk *clk)
645 return 0; 645 return 0;
646} 646}
647 647
648static inline int clk_bulk_enable(int num_clks, struct clk_bulk_data *clks) 648static inline int __must_check clk_bulk_enable(int num_clks, struct clk_bulk_data *clks)
649{ 649{
650 return 0; 650 return 0;
651} 651}
@@ -719,8 +719,8 @@ static inline void clk_disable_unprepare(struct clk *clk)
719 clk_unprepare(clk); 719 clk_unprepare(clk);
720} 720}
721 721
722static inline int clk_bulk_prepare_enable(int num_clks, 722static inline int __must_check clk_bulk_prepare_enable(int num_clks,
723 struct clk_bulk_data *clks) 723 struct clk_bulk_data *clks)
724{ 724{
725 int ret; 725 int ret;
726 726