aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 687b00d67c8a..df89cbfc1bd0 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -999,7 +999,7 @@ static struct clk *__clk_init_parent(struct clk *clk)
999 999
1000 if (!clk->parents) 1000 if (!clk->parents)
1001 clk->parents = 1001 clk->parents =
1002 kmalloc((sizeof(struct clk*) * clk->num_parents), 1002 kzalloc((sizeof(struct clk*) * clk->num_parents),
1003 GFP_KERNEL); 1003 GFP_KERNEL);
1004 1004
1005 if (!clk->parents) 1005 if (!clk->parents)
@@ -1065,9 +1065,13 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent)
1065 old_parent = clk->parent; 1065 old_parent = clk->parent;
1066 1066
1067 /* find index of new parent clock using cached parent ptrs */ 1067 /* find index of new parent clock using cached parent ptrs */
1068 for (i = 0; i < clk->num_parents; i++) 1068 if (clk->parents)
1069 if (clk->parents[i] == parent) 1069 for (i = 0; i < clk->num_parents; i++)
1070 break; 1070 if (clk->parents[i] == parent)
1071 break;
1072 else
1073 clk->parents = kzalloc((sizeof(struct clk*) * clk->num_parents),
1074 GFP_KERNEL);
1071 1075
1072 /* 1076 /*
1073 * find index of new parent clock using string name comparison 1077 * find index of new parent clock using string name comparison
@@ -1076,7 +1080,8 @@ static int __clk_set_parent(struct clk *clk, struct clk *parent)
1076 if (i == clk->num_parents) 1080 if (i == clk->num_parents)
1077 for (i = 0; i < clk->num_parents; i++) 1081 for (i = 0; i < clk->num_parents; i++)
1078 if (!strcmp(clk->parent_names[i], parent->name)) { 1082 if (!strcmp(clk->parent_names[i], parent->name)) {
1079 clk->parents[i] = __clk_lookup(parent->name); 1083 if (clk->parents)
1084 clk->parents[i] = __clk_lookup(parent->name);
1080 break; 1085 break;
1081 } 1086 }
1082 1087