03 Feb, 2016
4 commits
-
This loop can be much simpler. If a new parent is available for
orphan clocks, __clk_init_parent(orphan) can detect it.Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
Signed-off-by: Stephen Boyd -
Currently, clk_register() never checks a circular parent looping,
but clock providers could register such an insane clock topology.
For example, "clk_a" could have "clk_b" as a parent, and vice versa.
In this case, clk_core_reparent() creates a circular parent list
and __clk_recalc_accuracies() calls itself recursively forever.The core infrastructure should be kind enough to bail out, showing
an appropriate error message in such a case. This helps to easily
find a bug in clock providers. (uh, I made such a silly mistake
when I was implementing my clock providers first. I was upset
because the kernel did not respond, without any error message.)This commit adds a new helper function, __clk_is_ancestor(). It
returns true if the second argument is a possible ancestor of the
first one. If a clock core is a possible ancestor of itself, it
would make a loop when it were registered. That should be detected
as an error.Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
Signed-off-by: Stephen Boyd -
The translation from the index into clk_core is done by
clk_core_get_parent_by_index(). The if-block for num_parents == 1
case is duplicating the code in the clk_core_get_parent_by_index().Drop the "if (num_parents == 1)" from the special case. Instead,
set the index to zero if .get_parent() is missing.Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
Signed-off-by: Stephen Boyd -
The .get_parent is mandatory for multi-parent clocks. Move the check
to __clk_core_init(), like other callback checkings.Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
[sboyd@codeaurora.org: Squashed in error path handling, fix typos
in commit message]
Signed-off-by: Stephen Boyd
02 Feb, 2016
9 commits
-
These three cases let clk_register() fail. They should be considered
as error messages.Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
Signed-off-by: Stephen Boyd -
The core->parents is a cache to save expensive clock parent look-ups.
It will be filled as needed later. We do not have to do it here.Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
Signed-off-by: Stephen Boyd -
Drop the "if (!core->parents)" case and refactor the function a bit
because core->parents is always allocated. (Strictly speaking, it is
ZERO_SIZE_PTR if core->num_parents == 0, but such a case is omitted
by the if-conditional above.)Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
Signed-off-by: Stephen Boyd -
Currently, __clk_core_init() allows failure of the kcalloc() for the
core->parents. So, clk_fetch_parent_index() and __clk_init_parent()
also try to allocate core->parents in case it has not been allocated
yet. Scattering memory allocation here and there makes things
complicated.Like other clk_core members, allocate core->parents in clk_register()
and let it fail in case of memory shortage. If we cannot allocate
such a small piece of memory, the system is already insane. There is
no point to postpone the memory allocation.Also, allocate core->parents regardless of core->num_parents. We want
it even if core->num_parents == 1 because clk_fetch_parent_index()
might be called against the clk_core with a single parent.If core->num_parents == 0, core->parents is set to ZERO_SIZE_PTR. It
is harmless because no access happens to core->parents in such a case.Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
Signed-off-by: Stephen Boyd -
Now, the clock parent is not "struct clk *", but "struct clk_core *".
Of course, the size of a pointer is always same, but strictly speaking,
sizeof(struct clk *) should be sizeof(struct clk_core *) here.This mismatch happened when we split the structure into struct clk
and struct clk_core. For the potential possibility of future renaming,
sizeof(*core->parents) would be better.Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
Signed-off-by: Stephen Boyd -
This if-block has been here since the introduction of the common
clock framework. Now no clock drivers are statically initialized.
core->parent is always NULL at this point. Drop the redundant
check and the confusing comment.Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
Signed-off-by: Stephen Boyd -
Now this function takes clk_core as its argument. __clk_core_init()
would be more suitable for the name of this function.Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
Signed-off-by: Stephen Boyd -
The argument clk_user is used only for the clk_user->core. The rest
of this function only takes care of clk_core.Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
Signed-off-by: Stephen Boyd -
The "struct device *dev" is not used at all in this function.
Signed-off-by: Masahiro Yamada
Reviewed-by: Vladimir Zapolskiy
Signed-off-by: Stephen Boyd
30 Jan, 2016
27 commits
-
* clk-fixes:
clk: rockchip: rk3368: fix some clock gates
clk: rockchip: rk3036: rename emac ext source clock
clk: rockchip: rk3036: fix the div offset for emac clock
clk: rockchip: rk3036: fix uarts clock error
clk: rockchip: rk3036: fix the FLAGs for clock mux -
…/git/mmind/linux-rockchip into clk-fixes
Pull rockchip fixes from Heiko Stuebner:
Fixes for wrong register offsets in both rk3036 and rk3368.
Also rename the external input for the emac on rk3036, which
should still be ok to do, as that binding was only introduced
during this merge-window.* tag 'v4.5-rockchip-clkfixes1' of git://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip:
clk: rockchip: rk3368: fix some clock gates
clk: rockchip: rk3036: rename emac ext source clock
clk: rockchip: rk3036: fix the div offset for emac clock
clk: rockchip: rk3036: fix uarts clock error
clk: rockchip: rk3036: fix the FLAGs for clock mux -
My previous patch fixed some warnings about printing a couple
of variables that are always uninitialized in quadfs_pll_fs660c32_set_rate(),
but I now got a warning that only shows up in some configurations (i.e.
without gcc -Os) about the params.ndiv being used uninitialized in the
error case:drivers/clk/st/clkgen-fsyn.c: In function 'quadfs_pll_fs660c32_set_rate':
drivers/clk/st/clkgen-fsyn.c:584:75: warning: 'params.ndiv' may be used uninitialized in this function [-Wmaybe-uninitialized]
drivers/clk/st/clkgen-fsyn.c:574:16: note: 'params.ndiv' was declared hereThis changes the error handling so we bail for invalid arguments rather
than continuing with uninitialized data.Signed-off-by: Arnd Bergmann
Signed-off-by: Stephen Boyd -
The size of unsigned long on 64-bit architectures is equal to the
size of u64, so this check is impossible there. This throws off
static checkers:drivers/clk/clk-axi-clkgen.c:331 axi_clkgen_recalc_rate() warn:
impossible condition '(tmp > (~0)) => (0-u64max > u64max)'Let's change this code to use min_t() instead so that we
get the same effect on architectures where sizeof(unsigned long)
doesn't equal sizeof(u64).Cc: Lars-Peter Clausen
Signed-off-by: Stephen Boyd -
The clock generator has two clock inputs that can be used as the reference
clock. Add support for switching between them at runtime.Signed-off-by: Lars-Peter Clausen
Signed-off-by: Stephen Boyd -
Version 1 of the axi-clkgen core has not been used in new designs for over
two years now. This is a soft peripheral used in FPGAs and anybody who has
updated their kernel to the latest version will also have updated the
bitstream containing the clock generator. So it should be safe to drop
support for this now.Signed-off-by: Lars-Peter Clausen
Signed-off-by: Stephen Boyd -
of_match_device could return NULL, and so cause a NULL pointer
dereference later.
Even if the probability of this case is very low, fixing it made
static analyzers happy.Solving this with of_device_get_match_data made also code simplier.
Reported-by: coverity (CID 1324137)
Signed-off-by: LABBE Corentin
Signed-off-by: Stephen Boyd -
The palmas_clks_of_match_data structures are never modified.
This patch constify them.Signed-off-by: LABBE Corentin
Signed-off-by: Stephen Boyd -
Because _next_div() returns a valid divider, there is no need to
consult _is_valid_div() for the validity of the divider in every
iteration.Signed-off-by: Masahiro Yamada
Signed-off-by: Stephen Boyd -
With unsigned values underflow in loops can occur resulting in
theoretically infinite loops.The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
Signed-off-by: Andrzej Hajda
Signed-off-by: Stephen Boyd -
Allow to unregister fixed rate clock.
Signed-off-by: Masahiro Yamada
Signed-off-by: Stephen Boyd -
Allow to unregister fixed factor clock.
Signed-off-by: Masahiro Yamada
Signed-off-by: Stephen Boyd -
This clock is required for loading the qdsp firmware.
Signed-off-by: Srinivas Kandagatla
Signed-off-by: Stephen Boyd -
* clk-iproc:
clk: iproc: Remove __init from header
clk: iproc: Add support for Cygnus audio clocks
Documentation: dt-bindings: Add DT bindings for Cygnus audio clock -
Remove __init macro from all function prototypes in clk-iproc.h
Signed-off-by: Ray Jui
Signed-off-by: Stephen Boyd -
This patch adds support for Broadcom Cygnus audio PLL and leaf
clocksSigned-off-by: Simran Rai
Reviewed-by: Scott Branden
Signed-off-by: Ray Jui
Signed-off-by: Stephen Boyd -
This patch adds audio clock device tree binding documentation to an
existing Cygnus clock DT bindings document.Signed-off-by: Simran Rai
Reviewed-by: Ray Jui
Reviewed-by: Lori Hikichi
Reviewed-by: Scott Branden
Signed-off-by: Stephen Boyd -
Move all vendor's Kconfig into CCF menu section to prevent
new drivers putting their Kconfig files in a wrong place.Some Kconfigs need to be modified at the same time to avoid build
warnings.Signed-off-by: James Liao
Acked-by: Sylwester Nawrocki
[sboyd@codeaurora.org: Fix typos in commit message]
Acked-by: Arnd Bergmann
Signed-off-by: Stephen Boyd -
mtk_clk_register_composite() may leak memory due to some error
handling path don't free all allocated memory. This patch
free all pointers that may allocate memory before error return.
And it's safe because kfree() can handle NULL pointers.Signed-off-by: James Liao
Reviewed-by: Daniel Kurtz
Signed-off-by: Stephen Boyd -
to_clk_*(_hw) macros have been repeatedly defined in many places.
This patch moves all the to_clk_*(_hw) definitions in the common
clock framework to public header clk-provider.h, and drop the local
definitions.Signed-off-by: Geliang Tang
Signed-off-by: Stephen Boyd -
This function doesn't return anything because it's void. Drop the
return statement.Cc: Loc Ho
Signed-off-by: Stephen Boyd -
Add X-Gene SoC and PMD PLL clocks support for v2 hardware.
X-Gene SoC v2 and above use an slightly different SoC
and PMD PLL hardware logic.Signed-off-by: Loc Ho
Signed-off-by: Stephen Boyd -
Update APM X-Gene clock binding documentation for SoC and
PCP PLL for v2 hardware.Signed-off-by: Loc Ho
Signed-off-by: Stephen Boyd -
The definition of s2mps11_name is meant to resolve the name of a
given clock. Remove it because the clocks have the same name we
can get it directly from the s2mps11_clks_init structure.While in the probe function the s2mps11_clks is used only to
iterate through the s2mps11_clks. The naming itself brings
confusion and the readability does not improve much.Signed-off-by: Andi Shyti
Reviewed-by: Krzysztof Kozlowski
Signed-off-by: Stephen Boyd -
The clk_table and clk_data are declared static. The clk_table
contains the three clock data structures belonging to the s2mps11
driver. In the probe function it gets stored into clk_data.Remove clk_table and refer directly to clk_data.
clk_data, itself, is also declared static. Declare locally it
and allocate it inside the probe function, as it is not used
anywhere else.Signed-off-by: Andi Shyti
Reviewed-by: Krzysztof Kozlowski
Signed-off-by: Stephen Boyd -
The driver allocates three structures, s2mpsxx_clk_init, for
three different clock types (s2mps11, s2mps13 and s2mps14). They
are quite similar but they differ only by the name. Only one of
these structures is used, while the others lie unused in the
memory.The clock's name, though, is not such a meaningful information
and by assigning the same name to the initial data we can avoid
over allocation. The common name chosen will be s2mps11,
coherently with the device driver name, instead of the clock
device.Therefore, remove the structures associated to s2mps13 and
s2mps14 and use only the one referred to s2mps11 for all kind of
clocks.Signed-off-by: Andi Shyti
Suggested-by: Krzysztof Kozlowski
Reviewed-by: Krzysztof Kozlowski
Signed-off-by: Stephen Boyd -
The driver already loops once, there is no reason to loop again
for a different purpose. Merge the second loop into the first.Signed-off-by: Andi Shyti
Reviewed-by: Krzysztof Kozlowski
Signed-off-by: Stephen Boyd