22 Jul, 2017

1 commit

  • Now that we have a custom printf format specifier, convert users of
    full_name to use %pOF instead. This is preparation to remove storing
    of the full path string for each node.

    Signed-off-by: Rob Herring
    Cc: Michael Turquette
    Cc: Stephen Boyd
    Cc: Maxime Coquelin
    Cc: Alexandre Torgue
    Cc: Russell King
    Cc: Matthias Brugger
    Cc: Geert Uytterhoeven
    Cc: Maxime Ripard
    Cc: Chen-Yu Tsai
    Cc: "Emilio López"
    Cc: Peter De Schrijver
    Cc: Prashant Gaikwad
    Cc: Thierry Reding
    Cc: Jonathan Hunter
    Cc: Tero Kristo
    Cc: linux-clk@vger.kernel.org
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-mediatek@lists.infradead.org
    Cc: linux-renesas-soc@vger.kernel.org
    Cc: linux-tegra@vger.kernel.org
    Cc: linux-omap@vger.kernel.org
    Acked-by: Maxime Ripard
    Reviewed-by: Geert Uytterhoeven
    Acked-by: Geert Uytterhoeven
    Acked-by: James Liao
    Acked-by: Alexandre TORGUE
    Reviewed-by: Matthias Brugger
    Signed-off-by: Stephen Boyd

    Rob Herring
     

22 Nov, 2016

1 commit

  • Unlike clk_register_clkdev(), clk_hw_register_clkdev() doesn't check for
    passed error objects from a previous registration call. Hence the caller
    of clk_hw_register_*() has to check for errors before calling
    clk_hw_register_clkdev*().

    Make clk_hw_register_clkdev() more similar to clk_register_clkdev() by
    adding this error check, removing the burden from callers that do mass
    registration.

    Fixes: e4f1b49bda6d6aa2 ("clkdev: Add clk_hw based registration APIs")
    Fixes: 944b9a41e004534f ("clk: ls1x: Migrate to clk_hw based OF and registration APIs")
    Fixes: 44ce9a9ae977736f ("MIPS: TXx9: Convert to Common Clock Framework")
    Fixes: f48d947a162dfa9d ("clk: clps711x: Migrate to clk_hw based OF and registration APIs")
    Fixes: b4626a7f489238a5 ("CLK: Add Loongson1C clock support")
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Russell King

    Geert Uytterhoeven
     

03 Aug, 2016

1 commit

  • There was only one use of __initdata_refok and __exit_refok

    __init_refok was used 46 times against 82 for __ref.

    Those definitions are obsolete since commit 312b1485fb50 ("Introduce new
    section reference annotations tags: __ref, __refdata, __refconst")

    This patch removes the following compatibility definitions and replaces
    them treewide.

    /* compatibility defines */
    #define __init_refok __ref
    #define __initdata_refok __refdata
    #define __exit_refok __ref

    I can also provide separate patches if necessary.
    (One patch per tree and check in 1 month or 2 to remove old definitions)

    [akpm@linux-foundation.org: coding-style fixes]
    Link: http://lkml.kernel.org/r/1466796271-3043-1-git-send-email-fabf@skynet.be
    Signed-off-by: Fabian Frederick
    Cc: Ingo Molnar
    Cc: Sam Ravnborg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Fabian Frederick
     

20 Apr, 2016

2 commits

  • Now that we have a clk registration API that doesn't return
    struct clks, we need to have some way to hand out struct clks via
    the clk_get() APIs that doesn't involve associating struct clk
    pointers with a struct clk_lookup. Luckily, clkdev already
    operates on struct clk_hw pointers, except for the registration
    facing APIs where it converts struct clk pointers into struct
    clk_hw pointers almost immediately.

    Let's add clk_hw based registration APIs so that we can skip the
    conversion step and provide a way for clk provider drivers to
    operate exclusively on clk_hw structs. This way we clearly
    split the API between consumers and providers.

    Cc: Russell King
    Signed-off-by: Stephen Boyd

    Stephen Boyd
     
  • Now that we've converted the only caller over to another clkdev
    API, remove this one.

    Reviewed-by: Andy Shevchenko
    Cc: Russell King
    Signed-off-by: Stephen Boyd

    Stephen Boyd
     

17 Feb, 2016

1 commit

  • Many callers either use NULL or const strings for the third argument of
    clk_register_clkdev. For those that do not and use a non-const string,
    this is a risk for format strings being accidentally processed (for
    example in device names). As this interface is already used as if it
    weren't a format string (prints nothing when NULL), and there are zero
    users of the format strings, remove the format string interface to make
    sure format strings will not leak into the clkdev.

    $ git grep '\bclk_register_clkdev\b' | grep % | wc -l
    0

    Unfortunately, all the internals expect a va_list even though they treat
    a NULL format string as special. To deal with this, we must pass either
    (..., "%s", string) or (..., NULL) so that a the va_list will be created
    correctly (passing the name as an argument, not as a format string).

    Signed-off-by: Kees Cook
    Signed-off-by: Russell King

    Kees Cook
     

21 Oct, 2015

1 commit

  • clk_add_alias() was not correctly handling the case where alias_dev_name
    was NULL: rather than producing an entry with a NULL dev_id pointer,
    it would produce a device name of (null). Fix this.

    Cc:
    Fixes: 2568999835d7 ("clkdev: add clkdev_create() helper")
    Reported-by: Aaro Koskinen
    Tested-by: Aaro Koskinen
    Signed-off-by: Russell King

    Russell King
     

06 May, 2015

4 commits

  • Add a helper to allocate and add a clk_lookup structure. This can not
    only be used in several places in clkdev.c to simplify the code, but
    more importantly, can be used by callers of the clkdev code to simplify
    their clkdev creation and registration.

    Signed-off-by: Russell King

    Russell King
     
  • The connection id is only passed to clk_get() which is already const.
    Const-ify this argument too.

    Signed-off-by: Russell King

    Russell King
     
  • We want to be able to call clkdev_add_table() from non-init code, so we
    need to drop the __init marker from it.

    Signed-off-by: Russell King

    Russell King
     
  • clk_add_alias() calls clk_get() followed by clk_put() but in between
    those two calls it saves away the struct clk pointer to a clk_lookup
    structure. This leaves the 'clk' member of the clk_lookup pointing at
    freed memory on configurations where CONFIG_COMMON_CLK=y. This is a
    problem because clk_get_sys() will eventually try to dereference the
    freed pointer by calling __clk_get_hw() on it. Fix this by saving away
    the struct clk_hw pointer instead of the struct clk pointer so that when
    we try to create a per-user struct clk in clk_get_sys() we don't
    dereference a junk pointer.

    Signed-off-by: Russell King

    Russell King
     

13 Mar, 2015

1 commit

  • of_clk_get_by_clkspec() has the same function signature as
    of_clk_get_from_provider()

    struct clk *of_clk_get_by_clkspec(struct of_phandle_args
    *clkspec)
    struct clk *of_clk_get_from_provider(struct of_phandle_args
    *clkspec)

    except of_clk_get_by_clkspec() checks to make sure clkspec is not
    NULL. Let's remove of_clk_get_by_clkspec() and replace the
    callers of it (clkconf.c) with of_clk_get_from_provider().

    Cc: Sylwester Nawrocki
    Reviewed-by: Tomeu Vizoso
    Signed-off-by: Stephen Boyd

    Stephen Boyd
     

07 Feb, 2015

1 commit

  • of_clk_get_by_clkspec() returns a struct clk pointer but it
    doesn't create a new handle for the consumers when we're using
    the common clock framework. Instead it just returns whatever the
    clk provider hands out. When the consumers go to call clk_put()
    we get an Oops.

    Unable to handle kernel paging request at virtual address 00200200
    pgd = c0004000
    [00200200] *pgd=00000000
    Internal error: Oops: 805 [#1] PREEMPT SMP ARM
    Modules linked in:
    CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.19.0-rc1-00104-ga251361a-dirty #992
    Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
    task: ee00b000 ti: ee088000 task.ti: ee088000
    PC is at __clk_put+0x24/0xd0
    LR is at clk_prepare_lock+0xc/0xec
    pc : [] lr : [] psr: 20000153
    sp : ee089de8 ip : 00000000 fp : 00000000
    r10: ee02f480 r9 : 00000001 r8 : 00000000
    r7 : ee031cc0 r6 : ee089e08 r5 : 00000000 r4 : ee02f480
    r3 : 00100100 r2 : 00200200 r1 : 0000091e r0 : 00000001
    Flags: nzCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment kernel
    Control: 10c5387d Table: 4000404a DAC: 00000015
    Process swapper/0 (pid: 1, stack limit = 0xee088238)
    Stack: (0xee089de8 to 0xee08a000)
    9de0: ee7c8f14 c03f0ec8 ee089e08 00000000 c0718dc8 00000001
    9e00: 00000000 c04ee0f0 ee7e0844 00000001 00000181 c04edb58 ee2bd320 00000000
    9e20: 00000000 c011dc5c ee16a1e0 00000000 00000000 c0718dc8 ee16a1e0 ee2bd1e0
    9e40: c0641740 ee16a1e0 00000000 ee2bd320 c0718dc8 ee1d3e10 ee1d3e10 00000000
    9e60: c0769a88 00000000 c0718dc8 00000000 00000000 c02c3124 c02c310c ee1d3e10
    9e80: c07b4eec 00000000 c0769a88 c02c1d0c ee1d3e10 c0769a88 ee1d3e44 00000000
    9ea0: c07091dc c02c1eb8 00000000 c0769a88 c02c1e2c c02c0544 ee005478 ee1676c0
    9ec0: c0769a88 ee3a4e80 c0760ce8 c02c150c c0669b90 c0769a88 c0746cd8 c0769a88
    9ee0: c0746cd8 ee2bc4c0 c0778c00 c02c24e0 00000000 c0746cd8 c0746cd8 c07091f0
    9f00: 00000000 c0008944 c04f405c 00000025 ee00b000 60000153 c074ab00 00000000
    9f20: 00000000 c074ab90 60000153 00000000 ef7fca5d c050860c 000000b6 c0036b88
    9f40: c065ecc4 c06bc728 00000006 00000006 c074ab30 ef7fca40 c0739bdc 00000006
    9f60: c0718dbc c0778c00 000000b6 c0718dc8 c06ed598 c06edd64 00000006 00000006
    9f80: c06ed598 c003b438 00000000 c04e64f4 00000000 00000000 00000000 00000000
    9fa0: 00000000 c04e64fc 00000000 c000e838 00000000 00000000 00000000 00000000
    9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 c0c0c0c0 c0c0c0c0
    [] (__clk_put) from [] (of_clk_set_defaults+0xe0/0x2c0)
    [] (of_clk_set_defaults) from [] (platform_drv_probe+0x18/0xa4)
    [] (platform_drv_probe) from [] (driver_probe_device+0x10c/0x22c)
    [] (driver_probe_device) from [] (__driver_attach+0x8c/0x90)
    [] (__driver_attach) from [] (bus_for_each_dev+0x54/0x88)
    [] (bus_for_each_dev) from [] (bus_add_driver+0xd4/0x1d0)
    [] (bus_add_driver) from [] (driver_register+0x78/0xf4)
    [] (driver_register) from [] (fimc_md_init+0x14/0x30)
    [] (fimc_md_init) from [] (do_one_initcall+0x80/0x1d0)
    [] (do_one_initcall) from [] (kernel_init_freeable+0x108/0x1d4)
    [] (kernel_init_freeable) from [] (kernel_init+0x8/0xec)
    [] (kernel_init) from [] (ret_from_fork+0x14/0x3c)
    Code: ebfff4ae e5943014 e5942018 e3530000 (e5823000)

    Let's create a per-user handle here so that clk_put() can
    properly unlink it and free the handle. Now that we allocate a
    clk structure here we need to free it if __clk_get() fails so
    bury the __clk_get() call in __of_clk_get_from_provider(). We
    need to handle the same problem in clk_get_sys() so export
    __clk_free_clk() to clkdev.c and do the same thing, except let's
    use a union to make this code #ifdef free.

    This fixes the above crash, properly calls __clk_get() when
    of_clk_get_from_provider() is called, and cleans up the clk
    structure on the error path of clk_get_sys().

    Fixes: 035a61c314eb "clk: Make clk API return per-user struct clk instances"
    Reported-by: Sylwester Nawrocki
    Reported-by: Alban Browaeys
    Tested-by: Sylwester Nawrocki
    Tested-by: Alban Browaeys
    Reviewed-by: Tomeu Vizoso
    Signed-off-by: Stephen Boyd
    Signed-off-by: Michael Turquette

    Stephen Boyd
     

03 Feb, 2015

2 commits

  • So it can be used from modules such as clk-test.ko.

    Signed-off-by: Tomeu Vizoso
    Reviewed-by: Stephen Boyd
    Signed-off-by: Michael Turquette

    Tomeu Vizoso
     
  • Moves clock state to struct clk_core, but takes care to change as little API as
    possible.

    struct clk_hw still has a pointer to a struct clk, which is the
    implementation's per-user clk instance, for backwards compatibility.

    The struct clk that clk_get_parent() returns isn't owned by the caller, but by
    the clock implementation, so the former shouldn't call clk_put() on it.

    Because some boards in mach-omap2 still register clocks statically, their clock
    registration had to be updated to take into account that the clock information
    is stored in struct clk_core now.

    Signed-off-by: Tomeu Vizoso
    Reviewed-by: Stephen Boyd
    Tested-by: Tony Lindgren
    Signed-off-by: Michael Turquette
    [mturquette@linaro.org: adapted clk_has_parent to struct clk_core
    applied OMAP3+ DPLL fix from Tero & Tony]

    Tomeu Vizoso
     

27 Jun, 2014

1 commit

  • This error message can spam the logs if you have lots of probe
    deferals due to missing clocks. Just silence the error in this
    case because the driver should try again later.

    Signed-off-by: Stephen Boyd
    Acked-by: Russell King
    Signed-off-by: Mike Turquette

    Stephen Boyd
     

23 May, 2014

1 commit

  • This patch adds of_clk_get_by_clkspec() helper function, which does only
    a struct clk lookup from the clock providers. It is used in the subsequent
    patch where parsing of a clock from device tree and the lookup from
    providers needed to be split.

    Signed-off-by: Sylwester Nawrocki
    Signed-off-by: Mike Turquette

    Sylwester Nawrocki
     

25 Feb, 2014

1 commit

  • At probe time, a clock device may not be ready when some other device
    wants to use it.

    This patch lets the functions clk_get/devm_clk_get return a probe defer
    when the clock is defined in the DT but not yet available.

    Signed-off-by: Jean-Francois Moine
    Reviewed-by: Sylwester Nawrocki
    Tested-by: Sylwester Nawrocki
    Signed-off-by: Mike Turquette

    Jean-Francois Moine
     

05 Dec, 2013

1 commit

  • There is currently a race condition in the device tree part of clk_get()
    function, since the pointer returned from of_clk_get_by_name() may become
    invalid before __clk_get() call. E.g. due to the clock provider driver
    remove() callback being called in between of_clk_get_by_name() and
    __clk_get().

    Fix this by doing both the look up and __clk_get() operations with the
    clock providers list mutex held. This ensures that the clock pointer
    returned from __of_clk_get_from_provider() call and passed to __clk_get()
    is valid, as long as the clock supplier module first removes its clock
    provider instance and then does clk_unregister() on the corresponding
    clocks.

    Signed-off-by: Sylwester Nawrocki
    Signed-off-by: Kyungmin Park
    Reviewed-by: Mike Turquette
    Acked-by: Russell King

    Sylwester Nawrocki
     

16 Sep, 2012

1 commit

  • The managed clk functions are currently only available when the generic clk
    lookup framework is build. But the managed clk functions are merely wrappers
    around clk_get and clk_put and do not depend on any specifics of the generic
    lookup functions and there are still quite a few custom implementations of the
    clk API. So make the managed functions available whenever the clk API is
    implemented.

    The patch also removes the custom implementation of devm_clk_get for the
    coldfire platform.

    Signed-off-by: Lars-Peter Clausen
    Acked-by: Greg Ungerer
    Signed-off-by: Russell King

    Lars-Peter Clausen
     

20 Jul, 2012

2 commits

  • With commit 766e6a4ec602d0c107 (clk: add DT clock binding support),
    compiling with OF && !COMMON_CLK is broken.

    Reported-by: Alexandre Pereira da Silva
    Reported-by: Prashant Gaikwad
    Signed-off-by: Rob Herring
    Signed-off-by: Mike Turquette

    Rob Herring
     
  • The commit 766e6a4 (clk: add DT clock binding support) plugs device
    tree clk lookup of_clk_get_by_name into clk_get, and fall on non-DT
    lookup clk_get_sys if DT lookup fails.

    The return check on of_clk_get_by_name takes (clk != NULL) as a
    successful DT lookup. But it's not the case. For any system that
    does not define clk lookup in device tree, ERR_PTR(-ENOENT) will be
    returned, and consequently, all the client drivers calling clk_get
    in their probe functions will fail to probe with error code -ENOENT
    returned.

    Fix the issue by checking of_clk_get_by_name return with !IS_ERR(clk),
    and update of_clk_get and of_clk_get_by_name for !CONFIG_OF build
    correspondingly.

    Signed-off-by: Shawn Guo
    Acked-by: Rob Herring
    Tested-by: Marek Vasut
    Tested-by: Lauri Hintsala
    Signed-off-by: Mike Turquette

    Shawn Guo
     

12 Jul, 2012

1 commit

  • Based on work 1st by Ben Herrenschmidt and Jeremy Kerr, then by Grant
    Likely, this patch adds support to clk_get to allow drivers to retrieve
    clock data from the device tree.

    Platforms scan for clocks in DT with of_clk_init and a match table, and
    the register a provider through of_clk_add_provider. The provider's
    clk_src_get function will be called when a device references the
    provider's OF node for a clock reference.

    v6 (Rob Herring):
    - Return error values instead of NULL to match clock framework
    expectations

    v5 (Rob Herring):
    - Move from drivers/of into common clock subsystem
    - Squashed "dt/clock: add a simple provider get function" and
    "dt/clock: add function to get parent clock name"
    - Rebase to 3.4-rc1
    - Drop CONFIG_OF_CLOCK and just use CONFIG_OF
    - Add missing EXPORT_SYMBOL to various functions
    - s/clock-output-name/clock-output-names/
    - Define that fixed-clock binding is a single output

    v4 (Rob Herring):
    - Rework for common clk subsystem
    - Add of_clk_get_parent_name function

    v3: - Clarified documentation

    v2: - fixed errant ';' causing compile error
    - Editorial fixes from Shawn Guo
    - merged in adding lookup to clkdev
    - changed property names to match established convention. After
    working with the binding a bit it really made more sense to follow the
    lead of 'reg', 'gpios' and 'interrupts' by making the input simply
    'clocks' & 'clock-names' instead of 'clock-input-*', and to only use
    clock-output* for the producer nodes. (Sorry Shawn, this will mean
    you need to change some code, but it should be trivial)
    - Add ability to inherit clocks from parent nodes by using an empty
    'clock-ranges' property. Useful for busses. I could use some feedback
    on the new property name, 'clock-ranges' doesn't feel right to me.

    Signed-off-by: Grant Likely
    Signed-off-by: Rob Herring
    Reviewed-by: Shawn Guo
    Cc: Sascha Hauer
    Signed-off-by: Mike Turquette

    Grant Likely
     

02 May, 2012

1 commit


20 Apr, 2012

2 commits

  • clk_find must return as soon as it gets the correct clock. Currently it check
    all clocks until it found a lookup with both dev_id and con_id matching.

    If only one of them is passed, then we don't actually need to wait for both of
    them to match. We can quit as soon as the requested id (dev_id or con_id)
    matches.

    Signed-off-by: Viresh Kumar
    Signed-off-by: Russell King

    viresh kumar
     
  • Allow clk API users to simplify their cleanup paths by providing a
    managed version of clk_get() and clk_put().

    Signed-off-by: Mark Brown
    Signed-off-by: Russell King

    Mark Brown
     

30 Apr, 2011

1 commit


26 Nov, 2010

1 commit