msm: clock-local: Fix list_rate for branch clocks

Change branch clocks to only print out the valid frequency table
entries of their parent clocks, rather than all entries.

Change-Id: Ic8f75064132acd30c9da18292d5ac80e1b6cf1f9
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
diff --git a/arch/arm/mach-msm/clock-local2.c b/arch/arm/mach-msm/clock-local2.c
index 5923951..cf42355 100644
--- a/arch/arm/mach-msm/clock-local2.c
+++ b/arch/arm/mach-msm/clock-local2.c
@@ -461,13 +461,28 @@
 
 static int branch_clk_list_rate(struct clk *c, unsigned n)
 {
+	int level, fmax = 0, rate;
 	struct branch_clk *branch = to_branch_clk(c);
+	struct clk *parent = c->parent;
 
 	if (branch->has_sibling == 1)
 		return -ENXIO;
 
-	if (c->parent && c->parent->ops->list_rate)
-		return c->parent->ops->list_rate(c->parent, n);
+	if (!parent || !parent->ops->list_rate)
+		return -ENXIO;
+
+	/* Find max frequency supported within voltage constraints. */
+	if (!parent->vdd_class) {
+		fmax = INT_MAX;
+	} else {
+		for (level = 0; level < parent->num_fmax; level++)
+			if (parent->fmax[level])
+				fmax = parent->fmax[level];
+	}
+
+	rate = parent->ops->list_rate(parent, n);
+	if (rate <= fmax)
+		return rate;
 	else
 		return -ENXIO;
 }