Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3259761pxk; Mon, 5 Oct 2020 05:32:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwp3dsjtgqfH5RCxMenHzjlO74duOgMYam9KDNjwd+sZBHz4T+cHVU6/E3NGmhiPnL2OxK9 X-Received: by 2002:a17:906:31d4:: with SMTP id f20mr14991687ejf.38.1601901142334; Mon, 05 Oct 2020 05:32:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601901142; cv=none; d=google.com; s=arc-20160816; b=CFHdOA3NIL/giXr0BaJ/JfZS6w9v2Gf+LqGRV4sYHNxBfKuKEXxQ4sijNG84WH/bDS nQ44/RrAmvWdnBe9klmA1gUtRJTYjvWtwE4kEkVC1seqfyPv85QWcvdzi3iur4AsGxAz cO98iDSPGTGOsFXNlboqIGwY6/E9zTLaMHzLnCb+hl8eTDTsM3fyH6QSR+CIu52G+t5v XgEbcavuBE2SnQuDoCSY/RIvUhiXFjIiI4LXn7N8qp59ZRQ/9LcIaGyA9p8ydyJoK4TY 7bHUHikYNW8sM28wGjVTZmvN/OI9NOfZYXCSU2etNZ/lvsGnfVtfjnYBDJQ8t/CWgv2k X1NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=MyXbpuE/r6hjSZbFk+HdhoIhGJ5IA4PeZWqS3Lq3Qsg=; b=f/MwDbTjq6sorC66JG4SZP49xNMaX+kHIRG67Y8aIPRBbUPr9RmrdGGF5rYrBvXEoV b6/ngI3QcLKIZU02zINZD9QWWjKmtielH35qLFqkjcsou8RX8dhOYbYMYe9Y5Zsm9oYX oRAluZmU9CfFityH8YAaqzoco832KY0is4XWtIg1fa4WusJTIHBc1J3Mj1tNwewGdNYG xT52ahNzMCkHzUj9K3Gt1ePODvJ6JGSOCIfmN/zatHaU1QolqllF/BNkCJYyx3JJLXXg 6EdkcLdp5hMBroCS9ISzjCmPGiAl7Nhl+ArFnJV5njRzwPPkgjVbZI4HJJBhsWOUcIum gUpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu15si6261338edb.481.2020.10.05.05.31.59; Mon, 05 Oct 2020 05:32:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725994AbgJEM2n (ORCPT + 99 others); Mon, 5 Oct 2020 08:28:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726320AbgJEM1u (ORCPT ); Mon, 5 Oct 2020 08:27:50 -0400 Received: from smtp2-2.goneo.de (smtp2.goneo.de [IPv6:2001:1640:5::8:33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21AB5C0613B0 for ; Mon, 5 Oct 2020 05:27:49 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.goneo.de (Postfix) with ESMTP id 0822E23FD1A; Mon, 5 Oct 2020 14:27:48 +0200 (CEST) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -2.978 X-Spam-Level: X-Spam-Status: No, score=-2.978 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.078, BAYES_00=-1.9] autolearn=ham Received: from smtp2.goneo.de ([127.0.0.1]) by localhost (smtp2.goneo.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H2Qga0OoXzeq; Mon, 5 Oct 2020 14:27:46 +0200 (CEST) Received: from lem-wkst-02.lemonage.de. (hq.lemonage.de [87.138.178.34]) by smtp2.goneo.de (Postfix) with ESMTPA id 692EA240002; Mon, 5 Oct 2020 14:27:46 +0200 (CEST) From: poeschel@lemonage.de To: Miguel Ojeda Sandonis , Willy Tarreau , Ksenija Stanojevic , linux-kernel@vger.kernel.org (open list) Cc: Lars Poeschel , Willy Tarreau Subject: [PATCH v4 05/32] auxdisplay: Move write_data pointer to hd44780_common Date: Mon, 5 Oct 2020 14:27:05 +0200 Message-Id: <20201005122732.3429347-6-poeschel@lemonage.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005122732.3429347-1-poeschel@lemonage.de> References: <20201005122732.3429347-1-poeschel@lemonage.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lars Poeschel This moves the write_data function pointer from struct charlcd_ops to struct hd44780_common. This is the function that actually writes the character to the display. This hd44780 hardware specific function is used by two drivers at the moment. Reviewed-by: Willy Tarreau Signed-off-by: Lars Poeschel --- drivers/auxdisplay/charlcd.c | 12 ++++++------ drivers/auxdisplay/charlcd.h | 1 - drivers/auxdisplay/hd44780.c | 16 +++++++++------- drivers/auxdisplay/hd44780_common.h | 1 + drivers/auxdisplay/panel.c | 12 ++++++------ 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c index 59e0a815bf3d..df54078656c1 100644 --- a/drivers/auxdisplay/charlcd.c +++ b/drivers/auxdisplay/charlcd.c @@ -182,7 +182,7 @@ static void charlcd_print(struct charlcd *lcd, char c) if (priv->addr.x < hdc->bwidth) { if (lcd->char_conv) c = lcd->char_conv[(unsigned char)c]; - lcd->ops->write_data(lcd, c); + hdc->write_data(hdc, c); priv->addr.x++; /* prevents the cursor from wrapping onto the next line */ @@ -202,7 +202,7 @@ static void charlcd_clear_fast(struct charlcd *lcd) lcd->ops->clear_fast(lcd); else for (pos = 0; pos < min(2, lcd->height) * hdc->hwidth; pos++) - lcd->ops->write_data(lcd, ' '); + hdc->write_data(hdc, ' '); charlcd_home(lcd); } @@ -446,7 +446,7 @@ static inline int handle_lcd_special_code(struct charlcd *lcd) int x; for (x = priv->addr.x; x < hdc->bwidth; x++) - lcd->ops->write_data(lcd, ' '); + hdc->write_data(hdc, ' '); /* restore cursor position */ charlcd_gotoxy(lcd); @@ -505,7 +505,7 @@ static inline int handle_lcd_special_code(struct charlcd *lcd) lcd->ops->write_cmd(lcd, LCD_CMD_SET_CGRAM_ADDR | (cgaddr * 8)); for (addr = 0; addr < cgoffset; addr++) - lcd->ops->write_data(lcd, cgbytes[addr]); + hdc->write_data(hdc, cgbytes[addr]); /* ensures that we stop writing to CGRAM */ charlcd_gotoxy(lcd); @@ -587,7 +587,7 @@ static void charlcd_write_char(struct charlcd *lcd, char c) priv->addr.x--; } /* replace with a space */ - lcd->ops->write_data(lcd, ' '); + hdc->write_data(hdc, ' '); /* back one char again */ lcd->ops->write_cmd(lcd, LCD_CMD_SHIFT); break; @@ -601,7 +601,7 @@ static void charlcd_write_char(struct charlcd *lcd, char c) * go to the beginning of the next line */ for (; priv->addr.x < hdc->bwidth; priv->addr.x++) - lcd->ops->write_data(lcd, ' '); + hdc->write_data(hdc, ' '); priv->addr.x = 0; priv->addr.y = (priv->addr.y + 1) % lcd->height; charlcd_gotoxy(lcd); diff --git a/drivers/auxdisplay/charlcd.h b/drivers/auxdisplay/charlcd.h index 5dce9dd36562..fba4f2cd42c4 100644 --- a/drivers/auxdisplay/charlcd.h +++ b/drivers/auxdisplay/charlcd.h @@ -27,7 +27,6 @@ struct charlcd { struct charlcd_ops { /* Required */ void (*write_cmd)(struct charlcd *lcd, int cmd); - void (*write_data)(struct charlcd *lcd, int data); /* Optional */ void (*write_cmd_raw4)(struct charlcd *lcd, int cmd); /* 4-bit only */ diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c index f6786239c36f..922f0e0d2e6d 100644 --- a/drivers/auxdisplay/hd44780.c +++ b/drivers/auxdisplay/hd44780.c @@ -115,9 +115,8 @@ 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_common *hdc = lcd->drvdata; struct hd44780 *hd = hdc->hd44780; hd44780_write_gpio8(hd, data, 1); @@ -128,7 +127,6 @@ 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, }; @@ -163,9 +161,8 @@ 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_common *hdc = lcd->drvdata; struct hd44780 *hd = hdc->hd44780; hd44780_write_gpio4(hd, data, 1); @@ -177,7 +174,6 @@ 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, }; @@ -276,7 +272,13 @@ static int hd44780_probe(struct platform_device *pdev) device_property_read_u32(dev, "internal-buffer-width", &hdc->bwidth); hdc->ifwidth = ifwidth; - lcd->ops = ifwidth == 8 ? &hd44780_ops_gpio8 : &hd44780_ops_gpio4; + if (ifwidth == 8) { + lcd->ops = &hd44780_ops_gpio8; + hdc->write_data = hd44780_write_data_gpio8; + } else { + lcd->ops = &hd44780_ops_gpio4; + hdc->write_data = hd44780_write_data_gpio4; + } ret = charlcd_register(lcd); if (ret) diff --git a/drivers/auxdisplay/hd44780_common.h b/drivers/auxdisplay/hd44780_common.h index 1100e0a32394..1d686c99b2c1 100644 --- a/drivers/auxdisplay/hd44780_common.h +++ b/drivers/auxdisplay/hd44780_common.h @@ -7,6 +7,7 @@ struct hd44780_common { int ifwidth; /* 4-bit or 8-bit (default) */ int bwidth; /* Default set by hd44780_alloc() */ int hwidth; /* Default set by hd44780_alloc() */ + void (*write_data)(struct hd44780_common *hdc, int data); void *hd44780; }; diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c index cec6b729d668..15100d21a6e9 100644 --- a/drivers/auxdisplay/panel.c +++ b/drivers/auxdisplay/panel.c @@ -734,7 +734,7 @@ static void lcd_write_cmd_s(struct charlcd *charlcd, int cmd) } /* send data to the LCD panel in serial mode */ -static void lcd_write_data_s(struct charlcd *charlcd, int data) +static void lcd_write_data_s(struct hd44780_common *hdc, int data) { spin_lock_irq(&pprt_lock); lcd_send_serial(0x5F); /* R/W=W, RS=1 */ @@ -767,7 +767,7 @@ static void lcd_write_cmd_p8(struct charlcd *charlcd, int cmd) } /* send data to the LCD panel in 8 bits parallel mode */ -static void lcd_write_data_p8(struct charlcd *charlcd, int data) +static void lcd_write_data_p8(struct hd44780_common *hdc, int data) { spin_lock_irq(&pprt_lock); /* present the data to the data port */ @@ -799,7 +799,7 @@ static void lcd_write_cmd_tilcd(struct charlcd *charlcd, int cmd) } /* send data to the TI LCD panel */ -static void lcd_write_data_tilcd(struct charlcd *charlcd, int data) +static void lcd_write_data_tilcd(struct hd44780_common *hdc, int data) { spin_lock_irq(&pprt_lock); /* present the data to the data port */ @@ -874,21 +874,18 @@ static void lcd_clear_fast_tilcd(struct charlcd *charlcd) static const struct charlcd_ops charlcd_serial_ops = { .write_cmd = lcd_write_cmd_s, - .write_data = lcd_write_data_s, .clear_fast = lcd_clear_fast_s, .backlight = lcd_backlight, }; static const struct charlcd_ops charlcd_parallel_ops = { .write_cmd = lcd_write_cmd_p8, - .write_data = lcd_write_data_p8, .clear_fast = lcd_clear_fast_p8, .backlight = lcd_backlight, }; static const struct charlcd_ops charlcd_tilcd_ops = { .write_cmd = lcd_write_cmd_tilcd, - .write_data = lcd_write_data_tilcd, .clear_fast = lcd_clear_fast_tilcd, .backlight = lcd_backlight, }; @@ -1019,6 +1016,7 @@ static void lcd_init(void) if (lcd.proto == LCD_PROTO_SERIAL) { /* SERIAL */ charlcd->ops = &charlcd_serial_ops; + hdc->write_data = lcd_write_data_s; if (lcd.pins.cl == PIN_NOT_SET) lcd.pins.cl = DEFAULT_LCD_PIN_SCL; @@ -1027,6 +1025,7 @@ static void lcd_init(void) } else if (lcd.proto == LCD_PROTO_PARALLEL) { /* PARALLEL */ charlcd->ops = &charlcd_parallel_ops; + hdc->write_data = lcd_write_data_p8; if (lcd.pins.e == PIN_NOT_SET) lcd.pins.e = DEFAULT_LCD_PIN_E; @@ -1036,6 +1035,7 @@ static void lcd_init(void) lcd.pins.rw = DEFAULT_LCD_PIN_RW; } else { charlcd->ops = &charlcd_tilcd_ops; + hdc->write_data = lcd_write_data_tilcd; } if (lcd.pins.bl == PIN_NOT_SET) -- 2.28.0