Merge tag 'seccomp-v5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees...
[linux-2.6-microblaze.git] / drivers / auxdisplay / hd44780.c
index 271dba9..2e5e7c9 100644 (file)
@@ -40,7 +40,8 @@ struct hd44780 {
 
 static void hd44780_backlight(struct charlcd *lcd, enum charlcd_onoff on)
 {
-       struct hd44780 *hd = lcd->drvdata;
+       struct hd44780_common *hdc = lcd->drvdata;
+       struct hd44780 *hd = hdc->hd44780;
 
        if (hd->pins[PIN_CTRL_BL])
                gpiod_set_value_cansleep(hd->pins[PIN_CTRL_BL], on);
@@ -102,9 +103,9 @@ static void hd44780_write_gpio4(struct hd44780 *hd, u8 val, unsigned int rs)
 }
 
 /* Send a command to the LCD panel in 8 bit GPIO mode */
-static void hd44780_write_cmd_gpio8(struct charlcd *lcd, int cmd)
+static void hd44780_write_cmd_gpio8(struct hd44780_common *hdc, int cmd)
 {
-       struct hd44780 *hd = lcd->drvdata;
+       struct hd44780 *hd = hdc->hd44780;
 
        hd44780_write_gpio8(hd, cmd, 0);
 
@@ -113,9 +114,9 @@ static void hd44780_write_cmd_gpio8(struct charlcd *lcd, int cmd)
 }
 
 /* Send data to the LCD panel in 8 bit GPIO mode */
-static void hd44780_write_data_gpio8(struct charlcd *lcd, int data)
+static void hd44780_write_data_gpio8(struct hd44780_common *hdc, int data)
 {
-       struct hd44780 *hd = lcd->drvdata;
+       struct hd44780 *hd = hdc->hd44780;
 
        hd44780_write_gpio8(hd, data, 1);
 
@@ -124,15 +125,26 @@ static void hd44780_write_data_gpio8(struct charlcd *lcd, int data)
 }
 
 static const struct charlcd_ops hd44780_ops_gpio8 = {
-       .write_cmd      = hd44780_write_cmd_gpio8,
-       .write_data     = hd44780_write_data_gpio8,
        .backlight      = hd44780_backlight,
+       .print          = hd44780_common_print,
+       .gotoxy         = hd44780_common_gotoxy,
+       .home           = hd44780_common_home,
+       .clear_display  = hd44780_common_clear_display,
+       .init_display   = hd44780_common_init_display,
+       .shift_cursor   = hd44780_common_shift_cursor,
+       .shift_display  = hd44780_common_shift_display,
+       .display        = hd44780_common_display,
+       .cursor         = hd44780_common_cursor,
+       .blink          = hd44780_common_blink,
+       .fontsize       = hd44780_common_fontsize,
+       .lines          = hd44780_common_lines,
+       .redefine_char  = hd44780_common_redefine_char,
 };
 
 /* Send a command to the LCD panel in 4 bit GPIO mode */
-static void hd44780_write_cmd_gpio4(struct charlcd *lcd, int cmd)
+static void hd44780_write_cmd_gpio4(struct hd44780_common *hdc, int cmd)
 {
-       struct hd44780 *hd = lcd->drvdata;
+       struct hd44780 *hd = hdc->hd44780;
 
        hd44780_write_gpio4(hd, cmd, 0);
 
@@ -141,10 +153,10 @@ static void hd44780_write_cmd_gpio4(struct charlcd *lcd, int cmd)
 }
 
 /* Send 4-bits of a command to the LCD panel in raw 4 bit GPIO mode */
-static void hd44780_write_cmd_raw_gpio4(struct charlcd *lcd, int cmd)
+static void hd44780_write_cmd_raw_gpio4(struct hd44780_common *hdc, int cmd)
 {
        DECLARE_BITMAP(values, 6); /* for DATA[4-7], RS, RW */
-       struct hd44780 *hd = lcd->drvdata;
+       struct hd44780 *hd = hdc->hd44780;
        unsigned int n;
 
        /* Command nibble + RS, RW */
@@ -158,9 +170,9 @@ static void hd44780_write_cmd_raw_gpio4(struct charlcd *lcd, int cmd)
 }
 
 /* Send data to the LCD panel in 4 bit GPIO mode */
-static void hd44780_write_data_gpio4(struct charlcd *lcd, int data)
+static void hd44780_write_data_gpio4(struct hd44780_common *hdc, int data)
 {
-       struct hd44780 *hd = lcd->drvdata;
+       struct hd44780 *hd = hdc->hd44780;
 
        hd44780_write_gpio4(hd, data, 1);
 
@@ -169,10 +181,20 @@ static void hd44780_write_data_gpio4(struct charlcd *lcd, int data)
 }
 
 static const struct charlcd_ops hd44780_ops_gpio4 = {
-       .write_cmd      = hd44780_write_cmd_gpio4,
-       .write_cmd_raw4 = hd44780_write_cmd_raw_gpio4,
-       .write_data     = hd44780_write_data_gpio4,
        .backlight      = hd44780_backlight,
+       .print          = hd44780_common_print,
+       .gotoxy         = hd44780_common_gotoxy,
+       .home           = hd44780_common_home,
+       .clear_display  = hd44780_common_clear_display,
+       .init_display   = hd44780_common_init_display,
+       .shift_cursor   = hd44780_common_shift_cursor,
+       .shift_display  = hd44780_common_shift_display,
+       .display        = hd44780_common_display,
+       .cursor         = hd44780_common_cursor,
+       .blink          = hd44780_common_blink,
+       .fontsize       = hd44780_common_fontsize,
+       .lines          = hd44780_common_lines,
+       .redefine_char  = hd44780_common_redefine_char,
 };
 
 static int hd44780_probe(struct platform_device *pdev)
@@ -204,7 +226,7 @@ static int hd44780_probe(struct platform_device *pdev)
        if (!hdc)
                return -ENOMEM;
 
-       lcd = charlcd_alloc(sizeof(struct hd44780));
+       lcd = charlcd_alloc();
        if (!lcd)
                goto fail1;
 
@@ -264,13 +286,22 @@ static int hd44780_probe(struct platform_device *pdev)
         * usually equal to the display width
         */
        if (lcd->height > 2)
-               lcd->bwidth = lcd->width;
+               hdc->bwidth = lcd->width;
 
        /* Optional properties */
-       device_property_read_u32(dev, "internal-buffer-width", &lcd->bwidth);
-
-       lcd->ifwidth = ifwidth;
-       lcd->ops = ifwidth == 8 ? &hd44780_ops_gpio8 : &hd44780_ops_gpio4;
+       device_property_read_u32(dev, "internal-buffer-width", &hdc->bwidth);
+
+       hdc->ifwidth = ifwidth;
+       if (ifwidth == 8) {
+               lcd->ops = &hd44780_ops_gpio8;
+               hdc->write_data = hd44780_write_data_gpio8;
+               hdc->write_cmd = hd44780_write_cmd_gpio8;
+       } else {
+               lcd->ops = &hd44780_ops_gpio4;
+               hdc->write_data = hd44780_write_data_gpio4;
+               hdc->write_cmd = hd44780_write_cmd_gpio4;
+               hdc->write_cmd_raw4 = hd44780_write_cmd_raw_gpio4;
+       }
 
        ret = charlcd_register(lcd);
        if (ret)