Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp302568pxx; Thu, 29 Oct 2020 03:04:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJis6HvT5755T7XRHTC7OrCkD+Z0/34hqgsU3mGS/uFiSzZL59xWl7ToDXaz1HwmRMUOvp X-Received: by 2002:a17:906:714b:: with SMTP id z11mr3184458ejj.139.1603965885404; Thu, 29 Oct 2020 03:04:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603965885; cv=none; d=google.com; s=arc-20160816; b=vOShJUcM8nSgRFNwsNYyCrxtCIf4THmbjv+B+SeNyZLMAsssChdzvi3KvhPIcISRg9 /rNmQn28M+VhKdxJsUMJdhU7zbe9WRRJK9C7TY+efnIe4s2Rg4htd85z9XiuExPnqUE3 SDYGqSgfxqnqkkYfYzkiHnIOGLWM3yiaJYaRC5YkjvJq9P+ezU6+mRvpds5LFt9tah3u aG4JqUHYd1J1YSmyGvxt/P3VFl5wI13sIZu5fhFI2yzqK768oktz3lBDYQXO2LQslOVe Uy2g5NsMgYa9r1WukGq/7YWEiDj6zkZnhX9wdi/YGF//CG5foYwFGmtffD+NNzFP4P5Y t1Mw== 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=bdNamDy4xnPxDZ+PMqNLYPImLmrTzlWvulRTOe8Z0wQ=; b=L2B9StXAMKcW5JmV4fKpKEV8+LJ/Q01qb7C5YPpFByQ5U6pVupacfcIFuEyuh07cva eaEABhD7SWkyj1faODwNtdMwq1bb2ZInRRXpZKbL/6r7q8+97ky6Y/+sEsJ6Wjb9mXsO ZGFRXGrN+KircptNwADKLaZds9K01Aw30NntIWnSJAkLbIzrLmFP1YTZcazo7tgw+Kuk uyMfOx8QpMhTSVK2kUIgbB7qXCMToc7j70pskkZoapEQJvZcTceqwkBwQ0gictuXIhsc 7Z7ws50zWwOsvQBYgfNigc7PTlNwAo7S9JpQg8SYNEYOtvZjpI8JSYyJ8/C4Rjel+8CD a7Cg== 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 h90si1628685edd.326.2020.10.29.03.04.22; Thu, 29 Oct 2020 03:04:45 -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 S1727155AbgJ2J6S (ORCPT + 99 others); Thu, 29 Oct 2020 05:58:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727091AbgJ2J6M (ORCPT ); Thu, 29 Oct 2020 05:58:12 -0400 Received: from smtp3-1.goneo.de (smtp3.goneo.de [IPv6:2001:1640:5::8:37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93C6CC0613DC for ; Thu, 29 Oct 2020 02:58:10 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.goneo.de (Postfix) with ESMTP id 79EBC23F8AF; Thu, 29 Oct 2020 10:58:09 +0100 (CET) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -2.945 X-Spam-Level: X-Spam-Status: No, score=-2.945 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.045, BAYES_00=-1.9] autolearn=ham Received: from smtp3.goneo.de ([127.0.0.1]) by localhost (smtp3.goneo.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8-0TgxJIT4EC; Thu, 29 Oct 2020 10:58:07 +0100 (CET) Received: from lem-wkst-02.lemonage.de. (hq.lemonage.de [87.138.178.34]) by smtp3.goneo.de (Postfix) with ESMTPA id B483F240297; Thu, 29 Oct 2020 10:58:07 +0100 (CET) From: poeschel@lemonage.de To: Miguel Ojeda Sandonis , linux-kernel@vger.kernel.org (open list) Cc: Lars Poeschel , Willy Tarreau Subject: [PATCH v5 22/25] auxdisplay: Change gotoxy calling interface Date: Thu, 29 Oct 2020 10:57:26 +0100 Message-Id: <20201029095731.311528-21-poeschel@lemonage.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201029095731.311528-1-poeschel@lemonage.de> References: <20201029095231.311083-1-poeschel@lemonage.de> <20201029095731.311528-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 Change the calling interface for gotoxy from supplying the x and y coordinates in the charlcd struct to explicitly supplying x and y in the function arguments. This is more intuitive and allows for moving the cursor to positions independent from the position saved in the charlcd struct. Reviewed-by: Willy Tarreau Signed-off-by: Lars Poeschel --- drivers/auxdisplay/charlcd.c | 10 +++++----- drivers/auxdisplay/charlcd.h | 2 +- drivers/auxdisplay/hd44780_common.c | 15 ++++++--------- drivers/auxdisplay/hd44780_common.h | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c index 59f21401d6a9..ef10b5ca0e16 100644 --- a/drivers/auxdisplay/charlcd.c +++ b/drivers/auxdisplay/charlcd.c @@ -119,7 +119,7 @@ static void charlcd_print(struct charlcd *lcd, char c) /* prevents the cursor from wrapping onto the next line */ if (lcd->addr.x == lcd->width) - lcd->ops->gotoxy(lcd); + lcd->ops->gotoxy(lcd, lcd->addr.x - 1, lcd->addr.y); } static void charlcd_clear_display(struct charlcd *lcd) @@ -325,7 +325,7 @@ static inline int handle_lcd_special_code(struct charlcd *lcd) /* restore cursor position */ lcd->addr.x = xs; lcd->addr.y = ys; - lcd->ops->gotoxy(lcd); + lcd->ops->gotoxy(lcd, lcd->addr.x, lcd->addr.y); processed = 1; break; } @@ -349,7 +349,7 @@ static inline int handle_lcd_special_code(struct charlcd *lcd) /* If the command is valid, move to the new address */ if (parse_xy(esc, &lcd->addr.x, &lcd->addr.y)) - lcd->ops->gotoxy(lcd); + lcd->ops->gotoxy(lcd, lcd->addr.x, lcd->addr.y); /* Regardless of its validity, mark as processed */ processed = 1; @@ -407,12 +407,12 @@ static void charlcd_write_char(struct charlcd *lcd, char c) lcd->addr.x = 0; lcd->addr.y = (lcd->addr.y + 1) % lcd->height; - lcd->ops->gotoxy(lcd); + lcd->ops->gotoxy(lcd, lcd->addr.x, lcd->addr.y); break; case '\r': /* go to the beginning of the same line */ lcd->addr.x = 0; - lcd->ops->gotoxy(lcd); + lcd->ops->gotoxy(lcd, lcd->addr.x, lcd->addr.y); break; case '\t': /* print a space instead of the tab */ diff --git a/drivers/auxdisplay/charlcd.h b/drivers/auxdisplay/charlcd.h index e7e9b12b1e99..eed80063a6d2 100644 --- a/drivers/auxdisplay/charlcd.h +++ b/drivers/auxdisplay/charlcd.h @@ -78,7 +78,7 @@ struct charlcd { struct charlcd_ops { void (*backlight)(struct charlcd *lcd, enum charlcd_onoff on); int (*print)(struct charlcd *lcd, int c); - int (*gotoxy)(struct charlcd *lcd); + int (*gotoxy)(struct charlcd *lcd, unsigned int x, unsigned int y); int (*home)(struct charlcd *lcd); int (*clear_display)(struct charlcd *lcd); int (*init_display)(struct charlcd *lcd); diff --git a/drivers/auxdisplay/hd44780_common.c b/drivers/auxdisplay/hd44780_common.c index bd93a4d3367e..3934c2eebf33 100644 --- a/drivers/auxdisplay/hd44780_common.c +++ b/drivers/auxdisplay/hd44780_common.c @@ -49,7 +49,7 @@ int hd44780_common_print(struct charlcd *lcd, int c) } EXPORT_SYMBOL_GPL(hd44780_common_print); -int hd44780_common_gotoxy(struct charlcd *lcd) +int hd44780_common_gotoxy(struct charlcd *lcd, unsigned int x, unsigned int y) { struct hd44780_common *hdc = lcd->drvdata; unsigned int addr; @@ -58,11 +58,10 @@ int hd44780_common_gotoxy(struct charlcd *lcd) * we force the cursor to stay at the end of the * line if it wants to go farther */ - addr = lcd->addr.x < hdc->bwidth ? lcd->addr.x & (hdc->hwidth - 1) - : hdc->bwidth - 1; - if (lcd->addr.y & 1) + addr = x < hdc->bwidth ? x & (hdc->hwidth - 1) : hdc->bwidth - 1; + if (y & 1) addr += hdc->hwidth; - if (lcd->addr.y & 2) + if (y & 2) addr += hdc->bwidth; hdc->write_cmd(hdc, LCD_CMD_SET_DDRAM_ADDR | addr); return 0; @@ -71,9 +70,7 @@ 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); + return hd44780_common_gotoxy(lcd, 0, 0); } EXPORT_SYMBOL_GPL(hd44780_common_home); @@ -341,7 +338,7 @@ int hd44780_common_redefine_char(struct charlcd *lcd, char *esc) hdc->write_data(hdc, cgbytes[addr]); /* ensures that we stop writing to CGRAM */ - lcd->ops->gotoxy(lcd); + lcd->ops->gotoxy(lcd, lcd->addr.x, lcd->addr.y); return 1; } EXPORT_SYMBOL_GPL(hd44780_common_redefine_char); diff --git a/drivers/auxdisplay/hd44780_common.h b/drivers/auxdisplay/hd44780_common.h index bc817d1610d4..a16aa8c29c99 100644 --- a/drivers/auxdisplay/hd44780_common.h +++ b/drivers/auxdisplay/hd44780_common.h @@ -16,7 +16,7 @@ struct hd44780_common { }; int hd44780_common_print(struct charlcd *lcd, int c); -int hd44780_common_gotoxy(struct charlcd *lcd); +int hd44780_common_gotoxy(struct charlcd *lcd, unsigned int x, unsigned int y); int hd44780_common_home(struct charlcd *lcd); int hd44780_common_clear_display(struct charlcd *lcd); int hd44780_common_init_display(struct charlcd *lcd); -- 2.28.0