Skip to content

Commit

Permalink
misc: panel: Add lcd_home() helper
Browse files Browse the repository at this point in the history
Add a helper function to move the cursor to the home position, so
callers no longer need access to internal state.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Geert Uytterhoeven authored and Greg Kroah-Hartman committed Feb 10, 2017
1 parent 3f77b43 commit 204a4f6
Showing 1 changed file with 15 additions and 24 deletions.
39 changes: 15 additions & 24 deletions drivers/misc/panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,13 @@ static void lcd_gotoxy(void)
(lcd.hwidth - 1) : lcd.bwidth - 1));
}

static void lcd_home(void)
{
lcd.addr.x = 0;
lcd.addr.y = 0;
lcd_gotoxy();
}

static void lcd_print(char c)
{
if (lcd.addr.x < lcd.bwidth) {
Expand All @@ -921,9 +928,7 @@ static void lcd_clear_fast_s(void)
{
int pos;

lcd.addr.x = 0;
lcd.addr.y = 0;
lcd_gotoxy();
lcd_home();

spin_lock_irq(&pprt_lock);
for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) {
Expand All @@ -935,19 +940,15 @@ static void lcd_clear_fast_s(void)
}
spin_unlock_irq(&pprt_lock);

lcd.addr.x = 0;
lcd.addr.y = 0;
lcd_gotoxy();
lcd_home();
}

/* fills the display with spaces and resets X/Y */
static void lcd_clear_fast_p8(void)
{
int pos;

lcd.addr.x = 0;
lcd.addr.y = 0;
lcd_gotoxy();
lcd_home();

spin_lock_irq(&pprt_lock);
for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) {
Expand All @@ -973,19 +974,15 @@ static void lcd_clear_fast_p8(void)
}
spin_unlock_irq(&pprt_lock);

lcd.addr.x = 0;
lcd.addr.y = 0;
lcd_gotoxy();
lcd_home();
}

/* fills the display with spaces and resets X/Y */
static void lcd_clear_fast_tilcd(void)
{
int pos;

lcd.addr.x = 0;
lcd.addr.y = 0;
lcd_gotoxy();
lcd_home();

spin_lock_irq(&pprt_lock);
for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) {
Expand All @@ -996,9 +993,7 @@ static void lcd_clear_fast_tilcd(void)

spin_unlock_irq(&pprt_lock);

lcd.addr.x = 0;
lcd.addr.y = 0;
lcd_gotoxy();
lcd_home();
}

/* clears the display and resets X/Y */
Expand Down Expand Up @@ -1373,9 +1368,7 @@ static void lcd_write_char(char c)
processed = 1;
} else if (!strcmp(lcd.esc_seq.buf, "[H")) {
/* cursor to home */
lcd.addr.x = 0;
lcd.addr.y = 0;
lcd_gotoxy();
lcd_home();
processed = 1;
}
/* codes starting with ^[[L */
Expand Down Expand Up @@ -1654,11 +1647,9 @@ static void lcd_init(void)
#else
panel_lcd_print("\x1b[Lc\x1b[Lb\x1b[L*Linux-" UTS_RELEASE);
#endif
lcd.addr.x = 0;
lcd.addr.y = 0;
/* clear the display on the next device opening */
lcd.must_clear = true;
lcd_gotoxy();
lcd_home();
}

/*
Expand Down

0 comments on commit 204a4f6

Please sign in to comment.