auxdisplay: add home to charlcd_ops
authorLars Poeschel <poeschel@lemonage.de>
Tue, 3 Nov 2020 09:58:13 +0000 (10:58 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Wed, 4 Nov 2020 10:04:03 +0000 (11:04 +0100)
This adds a home function to the charlcd_ops struct and offer an
implementation for hd44780_common. This implementation is used by our
two hd44780 drivers. This is to make charlcd device independent.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
drivers/auxdisplay/charlcd.c
drivers/auxdisplay/charlcd.h
drivers/auxdisplay/hd44780.c
drivers/auxdisplay/hd44780_common.c
drivers/auxdisplay/hd44780_common.h
drivers/auxdisplay/panel.c

index d6f971eea6ae7789659975a1d244ac09de5d439e..44dd6e02eaf9fe71ade171e0ce1d7954ca5cc9b9 100644 (file)
@@ -144,7 +144,7 @@ static void charlcd_home(struct charlcd *lcd)
 {
        lcd->addr.x = 0;
        lcd->addr.y = 0;
-       lcd->ops->gotoxy(lcd);
+       lcd->ops->home(lcd);
 }
 
 static void charlcd_print(struct charlcd *lcd, char c)
index f36cc80ce385a653d494f81d4f01e1d3740b6416..236fd0e9e8ab61fd7ac5988c28af1fbe6e157440 100644 (file)
@@ -41,12 +41,15 @@ struct charlcd {
  * wrap to the next line at the end of a line.
  * @gotoxy: Set cursor to x, y. The x and y values to set the cursor to are
  * previously set in addr.x and addr.y by charlcd.
+ * @home: Set cursor to 0, 0. The values in addr.x and addr.y are set to 0, 0 by
+ * charlcd prior to calling this function.
  */
 struct charlcd_ops {
        void (*clear_fast)(struct charlcd *lcd);
        void (*backlight)(struct charlcd *lcd, enum charlcd_onoff on);
        int (*print)(struct charlcd *lcd, int c);
        int (*gotoxy)(struct charlcd *lcd);
+       int (*home)(struct charlcd *lcd);
 };
 
 struct charlcd *charlcd_alloc(void);
index 4d9478f6e5ffe5a607e522215f6671483f2dcf0a..b0893ea491652d3fd5e9dc329f87910bf838bb2c 100644 (file)
@@ -128,6 +128,7 @@ static const struct charlcd_ops hd44780_ops_gpio8 = {
        .backlight      = hd44780_backlight,
        .print          = hd44780_common_print,
        .gotoxy         = hd44780_common_gotoxy,
+       .home           = hd44780_common_home,
 };
 
 /* Send a command to the LCD panel in 4 bit GPIO mode */
@@ -173,6 +174,7 @@ static const struct charlcd_ops hd44780_ops_gpio4 = {
        .backlight      = hd44780_backlight,
        .print          = hd44780_common_print,
        .gotoxy         = hd44780_common_gotoxy,
+       .home           = hd44780_common_home,
 };
 
 static int hd44780_probe(struct platform_device *pdev)
index f86eb2f27ceec16af7999ac81bfe280012069266..ea62beada9d8552b90525ff09b02b37569304e36 100644 (file)
@@ -41,6 +41,14 @@ int hd44780_common_gotoxy(struct charlcd *lcd)
 }
 EXPORT_SYMBOL_GPL(hd44780_common_gotoxy);
 
+int hd44780_common_home(struct charlcd *lcd)
+{
+       lcd->addr.x = 0;
+       lcd->addr.y = 0;
+       return hd44780_common_gotoxy(lcd);
+}
+EXPORT_SYMBOL_GPL(hd44780_common_home);
+
 struct hd44780_common *hd44780_common_alloc(void)
 {
        struct hd44780_common *hd;
index d8cbea4a865858327ca27c68ddf180dac59bf4e2..c91070ed931bea857e90713eb14e10cc8e994a58 100644 (file)
@@ -16,4 +16,5 @@ struct hd44780_common {
 
 int hd44780_common_print(struct charlcd *lcd, int c);
 int hd44780_common_gotoxy(struct charlcd *lcd);
+int hd44780_common_home(struct charlcd *lcd);
 struct hd44780_common *hd44780_common_alloc(void);
index 75894eacd12ff6a88640bbcd5ac1d5e8511e42d0..b1e874f07456996cb215e754d6bebec894c935f0 100644 (file)
@@ -876,18 +876,21 @@ static const struct charlcd_ops charlcd_serial_ops = {
        .clear_fast     = lcd_clear_fast_s,
        .backlight      = lcd_backlight,
        .gotoxy         = hd44780_common_gotoxy,
+       .home           = hd44780_common_home,
 };
 
 static const struct charlcd_ops charlcd_parallel_ops = {
        .clear_fast     = lcd_clear_fast_p8,
        .backlight      = lcd_backlight,
        .gotoxy         = hd44780_common_gotoxy,
+       .home           = hd44780_common_home,
 };
 
 static const struct charlcd_ops charlcd_tilcd_ops = {
        .clear_fast     = lcd_clear_fast_tilcd,
        .backlight      = lcd_backlight,
        .gotoxy         = hd44780_common_gotoxy,
+       .home           = hd44780_common_home,
 };
 
 /* initialize the LCD driver */