[U-Boot] [PATCH 18/23] tegra: video: Remove the static variables

Simon Glass sjg at chromium.org
Thu Jan 14 19:28:30 CET 2016


We can move the static variables into the driver-private data.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/video/tegra.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/video/tegra.c b/drivers/video/tegra.c
index d3744a2..35eca4d 100644
--- a/drivers/video/tegra.c
+++ b/drivers/video/tegra.c
@@ -2,7 +2,7 @@
  * Copyright (c) 2011 The Chromium OS Authors.
  * SPDX-License-Identifier:	GPL-2.0+
  */
-#define DEBUG
+
 #include <common.h>
 #include <dm.h>
 #include <fdtdec.h>
@@ -31,11 +31,10 @@ enum stage_t {
 	STAGE_DONE,
 };
 
-static enum stage_t stage;	/* Current stage we are at */
-static unsigned long timer_next; /* Time we can move onto next stage */
-
 /* Information about the display controller */
 struct tegra_lcd_priv {
+	enum stage_t stage;	/* Current stage we are at */
+	unsigned long timer_next; /* Time we can move onto next stage */
 	int width;			/* width in pixels */
 	int height;			/* height in pixels */
 	int bpp;			/* number of bits per pixel */
@@ -498,10 +497,10 @@ static int fdt_decode_lcd(const void *blob, struct tegra_lcd_priv *priv)
  */
 static int handle_stage(const void *blob, struct tegra_lcd_priv *priv)
 {
-	debug("%s: stage %d\n", __func__, stage);
+	debug("%s: stage %d\n", __func__, priv->stage);
 
 	/* do the things for this stage */
-	switch (stage) {
+	switch (priv->stage) {
 	case STAGE_START:
 		/*
 		 * It is possible that the FDT has requested that the LCD be
@@ -543,12 +542,12 @@ static int handle_stage(const void *blob, struct tegra_lcd_priv *priv)
 	}
 
 	/* set up timer for next stage */
-	timer_next = timer_get_us();
-	if (stage < FDT_LCD_TIMINGS)
-		timer_next += priv->panel_timings[stage] * 1000;
+	priv->timer_next = timer_get_us();
+	if (priv->stage < FDT_LCD_TIMINGS)
+		priv->timer_next += priv->panel_timings[priv->stage] * 1000;
 
 	/* move to next stage */
-	stage++;
+	priv->stage++;
 	return 0;
 }
 
@@ -572,14 +571,14 @@ static int handle_stage(const void *blob, struct tegra_lcd_priv *priv)
 static int tegra_lcd_check_next_stage(const void *blob,
 				      struct tegra_lcd_priv *priv, int wait)
 {
-	if (stage == STAGE_DONE)
+	if (priv->stage == STAGE_DONE)
 		return 0;
 
 	do {
 		/* wait if we need to */
-		debug("%s: stage %d\n", __func__, stage);
-		if (stage != STAGE_START) {
-			int delay = timer_next - timer_get_us();
+		debug("%s: stage %d\n", __func__, priv->stage);
+		if (priv->stage != STAGE_START) {
+			int delay = priv->timer_next - timer_get_us();
 
 			if (delay > 0) {
 				if (wait)
@@ -591,8 +590,8 @@ static int tegra_lcd_check_next_stage(const void *blob,
 
 		if (handle_stage(blob, priv))
 			return -1;
-	} while (wait && stage != STAGE_DONE);
-	if (stage == STAGE_DONE)
+	} while (wait && priv->stage != STAGE_DONE);
+	if (priv->stage == STAGE_DONE)
 		debug("%s: LCD init complete\n", __func__);
 
 	return 0;
-- 
2.6.0.rc2.230.g3dd15c0



More information about the U-Boot mailing list