<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/clk/clk.c, branch v3.6.1</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>clk: validate pointer in __clk_disable()</title>
<updated>2012-07-31T00:25:13+00:00</updated>
<author>
<name>Fengguang Wu</name>
<email>fengguang.wu@intel.com</email>
</author>
<published>2012-07-30T21:39:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e47c6a3408ea6bcfc5204f23d5a5b209de6e68b9'/>
<id>e47c6a3408ea6bcfc5204f23d5a5b209de6e68b9</id>
<content type='text'>
clk_get() returns -ENOENT on error and some careless caller might
dereference it without error checking:

In mxc_rnga_remove():

        struct clk *clk = clk_get(&amp;pdev-&gt;dev, "rng");

	// ...

        clk_disable(clk);

Since it's insane to audit the lots of existing and future clk users,
let's add a check in the callee to avoid kernel panic and warn about
any buggy user.

Cc: Russell King &lt;rmk@arm.linux.org.uk&gt;
Cc: Paul Gortmaker &lt;paul.gortmaker@windriver.com&gt;
Cc: Viresh Kumar &lt;viresh.kumar@st.com&gt;
Cc: viresh kumar &lt;viresh.linux@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
clk_get() returns -ENOENT on error and some careless caller might
dereference it without error checking:

In mxc_rnga_remove():

        struct clk *clk = clk_get(&amp;pdev-&gt;dev, "rng");

	// ...

        clk_disable(clk);

Since it's insane to audit the lots of existing and future clk users,
let's add a check in the callee to avoid kernel panic and warn about
any buggy user.

Cc: Russell King &lt;rmk@arm.linux.org.uk&gt;
Cc: Paul Gortmaker &lt;paul.gortmaker@windriver.com&gt;
Cc: Viresh Kumar &lt;viresh.kumar@st.com&gt;
Cc: viresh kumar &lt;viresh.linux@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>clk: add DT clock binding support</title>
<updated>2012-07-12T00:58:45+00:00</updated>
<author>
<name>Grant Likely</name>
<email>grant.likely@secretlab.ca</email>
</author>
<published>2012-04-09T19:50:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=766e6a4ec602d0c107553b91b3434fe9c03474f4'/>
<id>766e6a4ec602d0c107553b91b3434fe9c03474f4</id>
<content type='text'>
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' &amp; '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 &lt;grant.likely@secretlab.ca&gt;
Signed-off-by: Rob Herring &lt;rob.herring@calxeda.com&gt;
Reviewed-by: Shawn Guo &lt;shawn.guo@freescale.com&gt;
Cc: Sascha Hauer &lt;kernel@pengutronix.de&gt;
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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' &amp; '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 &lt;grant.likely@secretlab.ca&gt;
Signed-off-by: Rob Herring &lt;rob.herring@calxeda.com&gt;
Reviewed-by: Shawn Guo &lt;shawn.guo@freescale.com&gt;
Cc: Sascha Hauer &lt;kernel@pengutronix.de&gt;
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>clk: cache parent clocks only for muxes</title>
<updated>2012-07-11T22:36:45+00:00</updated>
<author>
<name>Rajendra Nayak</name>
<email>rnayak@ti.com</email>
</author>
<published>2012-06-06T09:11:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9ca1c5a4bf4105d6f2f2a46892495953dd3e2fec'/>
<id>9ca1c5a4bf4105d6f2f2a46892495953dd3e2fec</id>
<content type='text'>
caching parent clocks makes sense only when a clock has more
than one parent (mux clocks).
Avoid doing this for every other clock.

Signed-off-by: Rajendra Nayak &lt;rnayak@ti.com&gt;
[mturquette@linaro.org: removed extra parentheses]
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
caching parent clocks makes sense only when a clock has more
than one parent (mux clocks).
Avoid doing this for every other clock.

Signed-off-by: Rajendra Nayak &lt;rnayak@ti.com&gt;
[mturquette@linaro.org: removed extra parentheses]
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>clk: fix parent validation in __clk_set_parent()</title>
<updated>2012-07-03T19:05:14+00:00</updated>
<author>
<name>Rajendra Nayak</name>
<email>rnayak@ti.com</email>
</author>
<published>2012-07-03T06:41:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=863b13271f1608ab3af6f7a371047d9a66693e38'/>
<id>863b13271f1608ab3af6f7a371047d9a66693e38</id>
<content type='text'>
The below commit introduced a bug in __clk_set_parent()
which could cause it to *skip* the parent validation
which makes sure the parent passed to the api is a valid
one.

    commit 7975059db572eb47f0fb272a62afeae272a4b209
    Author: Rajendra Nayak &lt;rnayak@ti.com&gt;
    Date:   Wed Jun 6 14:41:31 2012 +0530

        clk: Allow late cache allocation for clk-&gt;parents

This was identified by the following compiler warning..

    drivers/clk/clk.c: In function '__clk_set_parent':
    drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]

.. as reported by Marc Kleine-Budde.

There were various options discussed on how to fix this, one
being initing 'i' to clk-&gt;num_parents, but the below approach
was found to be more appropriate as it also makes the 'parent
validation' code simpler to read.

Reported-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
Signed-off-by: Rajendra Nayak &lt;rnayak@ti.com&gt;
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
Cc: stable@kernel.org
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The below commit introduced a bug in __clk_set_parent()
which could cause it to *skip* the parent validation
which makes sure the parent passed to the api is a valid
one.

    commit 7975059db572eb47f0fb272a62afeae272a4b209
    Author: Rajendra Nayak &lt;rnayak@ti.com&gt;
    Date:   Wed Jun 6 14:41:31 2012 +0530

        clk: Allow late cache allocation for clk-&gt;parents

This was identified by the following compiler warning..

    drivers/clk/clk.c: In function '__clk_set_parent':
    drivers/clk/clk.c:1083:5: warning: 'i' may be used uninitialized in this function [-Wuninitialized]

.. as reported by Marc Kleine-Budde.

There were various options discussed on how to fix this, one
being initing 'i' to clk-&gt;num_parents, but the below approach
was found to be more appropriate as it also makes the 'parent
validation' code simpler to read.

Reported-by: Marc Kleine-Budde &lt;mkl@pengutronix.de&gt;
Signed-off-by: Rajendra Nayak &lt;rnayak@ti.com&gt;
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
Cc: stable@kernel.org
</pre>
</div>
</content>
</entry>
<entry>
<title>clk: Check parent for NULL in clk_change_rate</title>
<updated>2012-06-25T23:51:48+00:00</updated>
<author>
<name>Pawel Moll</name>
<email>pawel.moll@arm.com</email>
</author>
<published>2012-06-08T13:04:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=bf47b4fd8f9f81cd5ce40e1945c6334d088226d1'/>
<id>bf47b4fd8f9f81cd5ce40e1945c6334d088226d1</id>
<content type='text'>
clk_change_rate() is accessing parent's rate without checking
if the parent exists at all. In case of root clocks this will
cause NULL pointer dereference.

This patch follows what clk_calc_new_rates() does in such
situation.

Signed-off-by: Pawel Moll &lt;pawel.moll@arm.com&gt;
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
Cc: stable@kernel.org
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
clk_change_rate() is accessing parent's rate without checking
if the parent exists at all. In case of root clocks this will
cause NULL pointer dereference.

This patch follows what clk_calc_new_rates() does in such
situation.

Signed-off-by: Pawel Moll &lt;pawel.moll@arm.com&gt;
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
Cc: stable@kernel.org
</pre>
</div>
</content>
</entry>
<entry>
<title>clk: Allow late cache allocation for clk-&gt;parents</title>
<updated>2012-06-25T23:51:47+00:00</updated>
<author>
<name>Rajendra Nayak</name>
<email>rnayak@ti.com</email>
</author>
<published>2012-06-06T09:11:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7975059db572eb47f0fb272a62afeae272a4b209'/>
<id>7975059db572eb47f0fb272a62afeae272a4b209</id>
<content type='text'>
Parent clocks for muxes are cached in clk-&gt;parents to
avoid frequent lookups, however the cache allocation happens
only during clock registeration and later clk_set_parent()
assumes a cache space available and allocated.

This is not entirely true for platforms which do early clock
registerations wherein the cache allocation using kzalloc
could fail during clock registeration.

Allow cache allocation to happen later as part of clk_set_parent()
to help such cases and avoid crashes assuming a cache being
available.

While here also replace existing kmalloc() with kzalloc()
in the file.

Signed-off-by: Rajendra Nayak &lt;rnayak@ti.com&gt;
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
Cc: stable@kernel.org
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Parent clocks for muxes are cached in clk-&gt;parents to
avoid frequent lookups, however the cache allocation happens
only during clock registeration and later clk_set_parent()
assumes a cache space available and allocated.

This is not entirely true for platforms which do early clock
registerations wherein the cache allocation using kzalloc
could fail during clock registeration.

Allow cache allocation to happen later as part of clk_set_parent()
to help such cases and avoid crashes assuming a cache being
available.

While here also replace existing kmalloc() with kzalloc()
in the file.

Signed-off-by: Rajendra Nayak &lt;rnayak@ti.com&gt;
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
Cc: stable@kernel.org
</pre>
</div>
</content>
</entry>
<entry>
<title>clk: Fix CLK_SET_RATE_GATE flag validation in clk_set_rate().</title>
<updated>2012-05-16T05:42:10+00:00</updated>
<author>
<name>Saravana Kannan</name>
<email>skannan@codeaurora.org</email>
</author>
<published>2012-05-15T20:43:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7e0fa1b5fa91d9aa456d102c273b2cf0f2e95d39'/>
<id>7e0fa1b5fa91d9aa456d102c273b2cf0f2e95d39</id>
<content type='text'>
The clk_set_rate() code shouldn't check the clock's enable count when
validating CLK_SET_RATE_GATE flag since the enable count could change after
the validation. Similar to clk_set_parent(), it should instead check the
prepare count. The prepare count should go to zero only when the end user
expects the clock to not be enabled in the future. Since the code already
grabs the prepare count before validation, it's not possible for prepare
count to change after validation and by association not possible for a well
behaving end user to enable the clock while the set rate is in progress.

Signed-off-by: Saravana Kannan &lt;skannan@codeaurora.org&gt;
Reviewed-by: Richard Zhao &lt;richard.zhao@freescale.com&gt;
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The clk_set_rate() code shouldn't check the clock's enable count when
validating CLK_SET_RATE_GATE flag since the enable count could change after
the validation. Similar to clk_set_parent(), it should instead check the
prepare count. The prepare count should go to zero only when the end user
expects the clock to not be enabled in the future. Since the code already
grabs the prepare count before validation, it's not possible for prepare
count to change after validation and by association not possible for a well
behaving end user to enable the clock while the set rate is in progress.

Signed-off-by: Saravana Kannan &lt;skannan@codeaurora.org&gt;
Reviewed-by: Richard Zhao &lt;richard.zhao@freescale.com&gt;
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>clk: Provide dummy clk_unregister()</title>
<updated>2012-05-15T19:02:39+00:00</updated>
<author>
<name>Mark Brown</name>
<email>broonie@opensource.wolfsonmicro.com</email>
</author>
<published>2012-04-18T08:07:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=1df5c939f6d9dff7dfbe108d93133b9636baa607'/>
<id>1df5c939f6d9dff7dfbe108d93133b9636baa607</id>
<content type='text'>
While there's no actual implementation behind it having the call to use
in drivers makes them feel neater from a driver author point of view. An
actual implementation can wait for someone who needs to use the function
in a real system.

Signed-off-by: Mark Brown &lt;broonie@opensource.wolfsonmicro.com&gt;
[mturquette@linaro.org: void return type instead of int -EINVAL]
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
While there's no actual implementation behind it having the call to use
in drivers makes them feel neater from a driver author point of view. An
actual implementation can wait for someone who needs to use the function
in a real system.

Signed-off-by: Mark Brown &lt;broonie@opensource.wolfsonmicro.com&gt;
[mturquette@linaro.org: void return type instead of int -EINVAL]
Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>clk: remove COMMON_CLK_DISABLE_UNUSED</title>
<updated>2012-05-08T21:12:42+00:00</updated>
<author>
<name>Mike Turquette</name>
<email>mturquette@linaro.org</email>
</author>
<published>2012-05-02T22:45:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d269b974e32c5dcf043acd07f9ad96e715019ffd'/>
<id>d269b974e32c5dcf043acd07f9ad96e715019ffd</id>
<content type='text'>
Exposing this option generates confusion and incorrect behavior for
single-image builds across platforms.  Enable this behavior permanently.

Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
Acked-by: Saravana Kannan &lt;skannan@codeaurora.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Exposing this option generates confusion and incorrect behavior for
single-image builds across platforms.  Enable this behavior permanently.

Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
Acked-by: Saravana Kannan &lt;skannan@codeaurora.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>clk: prevent spurious parent rate propagation</title>
<updated>2012-05-08T21:11:53+00:00</updated>
<author>
<name>Mike Turquette</name>
<email>mturquette@linaro.org</email>
</author>
<published>2012-05-02T23:23:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=63f5c3b2b18dcaca0fc8983b52a3f5d4d70a0590'/>
<id>63f5c3b2b18dcaca0fc8983b52a3f5d4d70a0590</id>
<content type='text'>
Patch 'clk: always pass parent_rate into .round_rate' made a subtle
change to the semantics of .round_rate.  It is now expected for the
parent's rate to always be passed in, simplifying the implemenation of
various .round_rate callback definitions.

However the patch also introduced a bug in clk_calc_new_rates whereby a
clock without the CLK_SET_RATE_PARENT flag set could still propagate a
rate change up to a parent clock if the the .round_rate callback
modified the &amp;best_parent_rate value in any way.

This patch fixes the issue at the framework level (in
clk_calc_new_rates) by specifically handling the case where the
CLK_SET_RATE_PARENT flag is not set.

Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
Acked-by: Sascha Hauer &lt;s.hauer@pengutronix.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Patch 'clk: always pass parent_rate into .round_rate' made a subtle
change to the semantics of .round_rate.  It is now expected for the
parent's rate to always be passed in, simplifying the implemenation of
various .round_rate callback definitions.

However the patch also introduced a bug in clk_calc_new_rates whereby a
clock without the CLK_SET_RATE_PARENT flag set could still propagate a
rate change up to a parent clock if the the .round_rate callback
modified the &amp;best_parent_rate value in any way.

This patch fixes the issue at the framework level (in
clk_calc_new_rates) by specifically handling the case where the
CLK_SET_RATE_PARENT flag is not set.

Signed-off-by: Mike Turquette &lt;mturquette@linaro.org&gt;
Acked-by: Sascha Hauer &lt;s.hauer@pengutronix.de&gt;
</pre>
</div>
</content>
</entry>
</feed>
