[ARM] 4777/1: S3C24XX: Ensure clk_set_rate() checks the set_rate method for the clk
Add checks for clk_set_rate() and ensure that we do not allow set_rate to be called for a clock that does not have it defined. Add default methods for fclk, hclk, pclk and mpll. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
parent
f7275dac55
commit
57c1b0f8db
1 changed files with 19 additions and 0 deletions
|
@ -172,6 +172,15 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(clk))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
/* We do not default just do a clk->rate = rate as
|
||||||
|
* the clock may have been made this way by choice.
|
||||||
|
*/
|
||||||
|
|
||||||
|
WARN_ON(clk->set_rate == NULL);
|
||||||
|
|
||||||
|
if (clk->set_rate == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&clocks_mutex);
|
mutex_lock(&clocks_mutex);
|
||||||
ret = (clk->set_rate)(clk, rate);
|
ret = (clk->set_rate)(clk, rate);
|
||||||
mutex_unlock(&clocks_mutex);
|
mutex_unlock(&clocks_mutex);
|
||||||
|
@ -213,6 +222,12 @@ EXPORT_SYMBOL(clk_set_parent);
|
||||||
|
|
||||||
/* base clocks */
|
/* base clocks */
|
||||||
|
|
||||||
|
static int clk_default_setrate(struct clk *clk, unsigned long rate)
|
||||||
|
{
|
||||||
|
clk->rate = rate;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct clk clk_xtal = {
|
struct clk clk_xtal = {
|
||||||
.name = "xtal",
|
.name = "xtal",
|
||||||
.id = -1,
|
.id = -1,
|
||||||
|
@ -224,6 +239,7 @@ struct clk clk_xtal = {
|
||||||
struct clk clk_mpll = {
|
struct clk clk_mpll = {
|
||||||
.name = "mpll",
|
.name = "mpll",
|
||||||
.id = -1,
|
.id = -1,
|
||||||
|
.set_rate = clk_default_setrate,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct clk clk_upll = {
|
struct clk clk_upll = {
|
||||||
|
@ -239,6 +255,7 @@ struct clk clk_f = {
|
||||||
.rate = 0,
|
.rate = 0,
|
||||||
.parent = &clk_mpll,
|
.parent = &clk_mpll,
|
||||||
.ctrlbit = 0,
|
.ctrlbit = 0,
|
||||||
|
.set_rate = clk_default_setrate,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct clk clk_h = {
|
struct clk clk_h = {
|
||||||
|
@ -247,6 +264,7 @@ struct clk clk_h = {
|
||||||
.rate = 0,
|
.rate = 0,
|
||||||
.parent = NULL,
|
.parent = NULL,
|
||||||
.ctrlbit = 0,
|
.ctrlbit = 0,
|
||||||
|
.set_rate = clk_default_setrate,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct clk clk_p = {
|
struct clk clk_p = {
|
||||||
|
@ -255,6 +273,7 @@ struct clk clk_p = {
|
||||||
.rate = 0,
|
.rate = 0,
|
||||||
.parent = NULL,
|
.parent = NULL,
|
||||||
.ctrlbit = 0,
|
.ctrlbit = 0,
|
||||||
|
.set_rate = clk_default_setrate,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct clk clk_usb_bus = {
|
struct clk clk_usb_bus = {
|
||||||
|
|
Loading…
Reference in a new issue