From: Lars Poeschel <poesc...@lemonage.de> Move device specific clear_fast to hd44780. The other hd44780 driver is panel and it provides it's own implementations of clear_fast, so we do not move to hd44780_common in this case. This also provides a standard naive fallback implementation in charlcd if a driver does not provide clear_fast.
Signed-off-by: Lars Poeschel <poesc...@lemonage.de> --- drivers/auxdisplay/charlcd.c | 19 +++++++++++-------- drivers/auxdisplay/hd44780.c | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c index 0f0568a4bd35..ef448c42abbd 100644 --- a/drivers/auxdisplay/charlcd.c +++ b/drivers/auxdisplay/charlcd.c @@ -127,18 +127,21 @@ static void charlcd_print(struct charlcd *lcd, char c) static void charlcd_clear_fast(struct charlcd *lcd) { - struct hd44780_common *hdc = lcd->drvdata; - int pos; - - charlcd_home(lcd); + int x, y; if (lcd->ops->clear_fast) lcd->ops->clear_fast(lcd); - else - for (pos = 0; pos < min(2, lcd->height) * hdc->hwidth; pos++) - lcd->ops->print(lcd, ' '); + else { + for (y = 0; y < lcd->height; y++) { + lcd->addr.x = 0; + lcd->addr.y = y; + lcd->ops->gotoxy(lcd); + for (x = 0; x < lcd->width; x++) + lcd->ops->print(lcd, ' '); + } - charlcd_home(lcd); + lcd->ops->home(lcd); + } } /* diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c index 2e5e7c993933..207ed23e02ce 100644 --- a/drivers/auxdisplay/hd44780.c +++ b/drivers/auxdisplay/hd44780.c @@ -38,6 +38,18 @@ struct hd44780 { struct gpio_desc *pins[PIN_NUM]; }; +static void hd44780_clear_fast(struct charlcd *lcd) +{ + struct hd44780_common *hdc = lcd->drvdata; + int pos; + + hd44780_common_home(lcd); + for (pos = 0; pos < min(2, lcd->height) * hdc->hwidth; pos++) + hd44780_common_print(lcd, ' '); + + hd44780_common_home(lcd); +} + static void hd44780_backlight(struct charlcd *lcd, enum charlcd_onoff on) { struct hd44780_common *hdc = lcd->drvdata; @@ -125,6 +137,7 @@ static void hd44780_write_data_gpio8(struct hd44780_common *hdc, int data) } static const struct charlcd_ops hd44780_ops_gpio8 = { + .clear_fast = hd44780_clear_fast, .backlight = hd44780_backlight, .print = hd44780_common_print, .gotoxy = hd44780_common_gotoxy, @@ -181,6 +194,7 @@ static void hd44780_write_data_gpio4(struct hd44780_common *hdc, int data) } static const struct charlcd_ops hd44780_ops_gpio4 = { + .clear_fast = hd44780_clear_fast, .backlight = hd44780_backlight, .print = hd44780_common_print, .gotoxy = hd44780_common_gotoxy, -- 2.28.0