Show parents for a given clock in ncurses mode too
diff --git a/clocks.c b/clocks.c
index 5cdc8d5..81da6c3 100644
--- a/clocks.c
+++ b/clocks.c
@@ -81,8 +81,27 @@
 	return atoi(result);
 }
 
+void find_parents_for_clock(char *clkname, int complete)
+{
+	char name[256];
+
+	name[0] = '\0';
+	if (!complete) {
+		char str[256];
+
+		strcat(name, clkname);
+		sprintf(str, "Enter Clock Name : %s\n", name);
+		print_one_clock(2, str, 1, 0);
+		return;
+	}
+	sprintf(name, "Parents for \"%s\" Clock : \n", clkname);
+	print_one_clock(0, name, 1, 1);
+	dump_all_parents(clkname);
+} 
+
 int read_and_print_clock_info(int verbose, int hrow, int selected)
 {
+	print_one_clock(0, "Reading Clock Tree ...", 1, 1);
 	if (!old_clock_line_no)
 		read_clock_info(clk_dir_path);
 
@@ -234,8 +253,7 @@
 
 void read_and_dump_clock_info_one(char *clk)
 {
-	printf("Clock Tree : (clock name = %s)\n", clk);
-	printf("**********\n");
+	printf("\nParents for \"%s\" Clock :\n\n", clk);
 	read_clock_info(clk_dir_path);
 	dump_all_parents(clk);
 }
@@ -365,14 +383,19 @@
 	(*parent)->num_children++;
 }
 
-void dump_parent(struct clock_info *clk)
+void dump_parent(struct clock_info *clk, int line)
 {
 	char *unit = "Hz";
 	double drate;
-	static char spaces[256];
+	static char spaces[64];
+	char str[256];
+	static int maxline;
+
+	if (maxline < line)
+		maxline = line;
 		
 	if (clk && clk->parent)
-		dump_parent(clk->parent);
+		dump_parent(clk->parent, ++line);
 
  	drate = (double)clk->rate;
 	if (drate > 1000 && drate < 1000000) {
@@ -384,15 +407,23 @@
 		drate /= 1000000;
 	}
 	if (clk == clocks_info) {
+		line++;
 		strcpy(spaces, "");
-		printf("%s%s (flags:%d,usecount:%d,rate:%5.2f %s)\n", spaces,
-			clk->name, clk->flags, clk->usecount, drate, unit);
+		sprintf(str, "%s%s (flags:%d,usecount:%d,rate:%5.2f %s)\n",
+			spaces, clk->name, clk->flags, clk->usecount, drate,
+			unit);
 	} else {
 		if (!(clk->parent == clocks_info))
 			strcat(spaces, "  ");
-		printf("%s`- %s (flags:%d,usecount:%d,rate:%5.2f %s)\n", spaces,
-			clk->name, clk->flags, clk->usecount, drate, unit);
+		sprintf(str, "%s`- %s (flags:%d,usecount:%d,rate:%5.2f %s)\n",
+			spaces, clk->name, clk->flags, clk->usecount, drate,
+			unit);
 	}
+	if (dump)
+		//printf("line=%d:m%d:l%d %s", maxline - line + 2, maxline, line, str);
+		printf("%s", str);
+	else
+		print_one_clock(maxline - line + 2, str, 1, 0);
 }
 
 void dump_all_parents(char *clkarg)
@@ -414,7 +445,7 @@
 //			printf("%s <-- ", spaces);
 //		}
 //		printf("  /\n");
-		dump_parent(clk);
+		dump_parent(clk, 1);
 	}
 }
 
diff --git a/powerdebug.c b/powerdebug.c
index 439f8f2..14748c5 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -216,9 +216,9 @@
 {
 	int c, i;
 	int firsttime[TOTAL_FEATURE_WINS];
-	int enter_hit = 0, verbose = 0;
+	int enter_hit = 0, verbose = 0, findparent_ncurses = 0;
 	int regulators = 0, sensors = 0, clocks = 0, findparent = 0;
-	char clkarg[64];
+	char clkarg[64], clkname_str[64];
 
 	for (i = 0; i < TOTAL_FEATURE_WINS; i++)
 		firsttime[i] = 1;
@@ -343,16 +343,22 @@
 				ret = init_clock_details();
 				if (!ret)
 					firsttime[CLOCK] = 0;
+				strcpy(clkname_str, "");
 			}
 			if (!ret && !dump) {
 				int hrow;
 
 				create_selectedwindow();
-				hrow = read_and_print_clock_info(verbose,
+				if (!findparent_ncurses) {
+					hrow = read_and_print_clock_info(
+								verbose,
 								highlighted_row,
 								enter_hit);
-				highlighted_row = hrow;
-				enter_hit = 0;
+					highlighted_row = hrow;
+					enter_hit = 0;
+				} else
+					find_parents_for_clock(clkname_str,
+								enter_hit);
 			}
 			if (!ret && dump) {
 				if (findparent)
@@ -383,6 +389,7 @@
 		if (key)  {
 			char keychar;
 			int keystroke = getch();
+			int oldselectedwin = selectedwindow;
 
 			if (keystroke == EOF)
 				exit(0);
@@ -404,18 +411,49 @@
 					highlighted_row++;
 				if (keystroke == KEY_UP && highlighted_row > 0)
 					highlighted_row--;
+				if (keystroke == 47)
+					findparent_ncurses = 1;
+
+				if ((keystroke == 27 || oldselectedwin !=
+					selectedwindow) && findparent_ncurses) {
+					findparent_ncurses = 0;
+					clkname_str[0] = '\0';
+				}
+
+				if (findparent_ncurses && keystroke != 13) {
+					int len = strlen(clkname_str);
+					char str[2];
+
+					if (keystroke == 263) {
+						if (len > 0)
+							len--;
+
+						clkname_str[len] = '\0';
+					} else {
+						if (strlen(clkname_str) ||
+							keystroke != '/') {
+						str[0] = keystroke;
+						str[1] = '\0';
+						if (len < 63)
+							strcat(clkname_str,
+								str);
+						}
+					}
+				}
 			}
 
 			keychar = toupper(keystroke);
-
-			//killall_windows(1); fini_curses();
-			//printf("key entered %d:%c\n", keystroke, keychar);
-			//exit(1);
+//#define DEBUG
+#ifdef DEBUG
+			killall_windows(1); fini_curses();
+			printf("key entered %d:%c\n", keystroke, keychar);
+			exit(1);
+#endif
 
 			if (keystroke == 13)
 				enter_hit = 1;
 
-			if (keychar == 'Q')
+			if (keychar == 'Q' && !findparent_ncurses)
 				exit(0);
 			if (keychar == 'R')
 				ticktime = 3;
diff --git a/powerdebug.h b/powerdebug.h
index d07849d..4799118 100644
--- a/powerdebug.h
+++ b/powerdebug.h
@@ -62,6 +62,7 @@
 						struct clock_info *parent);
 extern void dump_clock_info(struct clock_info *clk, int level, int bmp);
 extern void insert_children(struct clock_info **parent, struct clock_info *clk);
+extern void find_parents_for_clock(char *clkname, int complete);
 extern int  read_and_print_clock_info(int verbose, int hrow, int selected);
 extern void print_clock_info(int verbose, int hrow, int selected);
 extern void get_sensor_info(char *path, char *name, char *sensor, int verbose);