bcm27xx: add support for linux v5.15
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0845-clk-Fix-clk_get_parent-documentation.patch
1 From daba7e69a412a6b55b77818904ae53e2a9a6d91c Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Fri, 1 Apr 2022 11:09:29 +0200
4 Subject: [PATCH] clk: Fix clk_get_parent() documentation
5
6 The clk_get_parent() documentation in the header states that it will
7 return a valid pointer, or an error pointer on failure.
8
9 However, the documentation in the source file, and the code itself, will
10 return also return NULL if there isn't any parent for that clock. Let's
11 mention it.
12
13 An orphan clock should return NULL too, so let's add a test for it.
14
15 Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com> # imx8mp
16 Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> # exynos4210, meson g12b
17 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
18 ---
19 drivers/clk/clk_test.c | 17 +++++++++++++++++
20 include/linux/clk.h | 5 +++--
21 2 files changed, 20 insertions(+), 2 deletions(-)
22
23 --- a/drivers/clk/clk_test.c
24 +++ b/drivers/clk/clk_test.c
25 @@ -534,6 +534,22 @@ clk_orphan_transparent_multiple_parent_m
26
27 /*
28 * Test that, for a mux whose current parent hasn't been registered yet,
29 + * clk_get_parent() will return NULL.
30 + */
31 +static void
32 +clk_test_orphan_transparent_multiple_parent_mux_get_parent(struct kunit *test)
33 +{
34 + struct clk_multiple_parent_ctx *ctx = test->priv;
35 + struct clk_hw *hw = &ctx->hw;
36 + struct clk *clk = hw->clk;
37 + struct clk *parent;
38 +
39 + parent = clk_get_parent(clk);
40 + KUNIT_EXPECT_PTR_EQ(test, parent, NULL);
41 +}
42 +
43 +/*
44 + * Test that, for a mux whose current parent hasn't been registered yet,
45 * calling clk_set_parent() to a valid parent will properly update the
46 * mux parent and its orphan status.
47 */
48 @@ -642,6 +658,7 @@ clk_test_orphan_transparent_multiple_par
49 }
50
51 static struct kunit_case clk_orphan_transparent_multiple_parent_mux_test_cases[] = {
52 + KUNIT_CASE(clk_test_orphan_transparent_multiple_parent_mux_get_parent),
53 KUNIT_CASE(clk_test_orphan_transparent_multiple_parent_mux_set_parent),
54 KUNIT_CASE(clk_test_orphan_transparent_multiple_parent_mux_set_parent_get_rate),
55 KUNIT_CASE(clk_test_orphan_transparent_multiple_parent_mux_set_parent_set_range_modified),
56 --- a/include/linux/clk.h
57 +++ b/include/linux/clk.h
58 @@ -744,8 +744,9 @@ int clk_set_parent(struct clk *clk, stru
59 * clk_get_parent - get the parent clock source for this clock
60 * @clk: clock source
61 *
62 - * Returns struct clk corresponding to parent clock source, or
63 - * valid IS_ERR() condition containing errno.
64 + * Returns struct clk corresponding to parent clock source, a NULL
65 + * pointer if it doesn't have a parent, or a valid IS_ERR() condition
66 + * containing errno.
67 */
68 struct clk *clk_get_parent(struct clk *clk);
69