History log of /linux-master/drivers/auxdisplay/charlcd.c
Revision Date Author Comments
# 4daa9ff8 09-Nov-2021 Luiz Sampaio <sampaio.ime@gmail.com>

auxdisplay: charlcd: checking for pointer reference before dereferencing

Check if the pointer lcd->ops->init_display exists before dereferencing it.
If a driver called charlcd_init() without defining the ops, this would
return segmentation fault, as happened to me when implementing a charlcd
driver. Checking the pointer before dereferencing protects from
segmentation fault.

Signed-off-by: Luiz Sampaio <sampaio.ime@gmail.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 94047df1 09-Nov-2021 Luiz Sampaio <sampaio.ime@gmail.com>

auxdisplay: charlcd: fixing coding style issue

Removing 'int' from 'unsigned long int' declaration, which is unnecessary.

Signed-off-by: Luiz Sampaio <sampaio.ime@gmail.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# ac8c8fa0 15-Jul-2021 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

auxdisplay: charlcd: Drop unneeded initializers and switch to C99 style

For structure initializers the fields are 0 (or NULL) by default, so
there is no need to fill them explicitly. Besides that, much easier
to read when initializers use C99 style. Hence, convert to C99 style
as well.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 701454bc 16-Feb-2021 Sebastian Andrzej Siewior <bigeasy@linutronix.de>

auxdisplay: Remove in_interrupt() usage.

charlcd_write() is invoked as a VFS->write() callback and as such it is
always invoked from preemptible context and may sleep.

charlcd_puts() is invoked from register/unregister callback which is
preemptible. The reboot notifier callback is also invoked from
preemptible context.

Therefore there is no need to use in_interrupt() to figure out if it
is safe to sleep because it always is. in_interrupt() and related
context checks are being removed from non-core code.
Using schedule() to schedule (and be friendly to others) is
discouraged and cond_resched() should be used instead.

Remove in_interrupt() and use cond_resched() to schedule every 32
iterations if needed.

Link: https://lkml.kernel.org/r/20200914204209.256266093@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
[mo: fixed a couple typos in comment and commit message]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# af9470b2 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: charlcd: Do not print chars at end of line

Skip printing characters at the end of a display line. This fits to the
behaviour we already had, that the cursor is nailed to the last position
of a line.
This might slightly change behaviour.
On hd44780 displays with one or two lines the previous implementation
did still write characters to the buffer of the display even if they are
currently not visible. The shift_display command could be used to set
the "viewing window" to a new position in the buffer and then you could
see the characters previously written.
This described behaviour does not work for hd44780 displays with more
than two display lines. There simply is not enough buffer.
So the behaviour was a bit inconsistent across different displays.
The new behaviour is to stop writing characters at the end of a visible
line, even if there would be room in the buffer. This allows us to have
an easy implementation, that should behave equal on all supported
displays. This is not hd44780 hardware dependent anymore.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 40c2b72e 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: Change gotoxy calling interface

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 <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 6e49eea3 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: charlcd: replace last device specific stuff

These are the last bits left in charlcd.c that are device specific and
they are removed now.
In detail this is:
* bwidth, which is the width of the display buffer per line. This is
replaced by width of the display.
* hwidth, which is the size of the display buffer as a whole. This is
replaced by looping all chars of a line by all lines.
* the hd44780_common header include can go away.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 377cf2cb 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: hd44780: Remove clear_fast

We remove the hd44780_clear_fast (display) clear implementation. With
the new timeout the normal clear_display is reasonably fast. So there is
no need for a clear_fast anymore.

Link: https://lore.kernel.org/lkml/20200922092121.GG16421@1wt.eu/

Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# a2060f28 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: Call charlcd_backlight in place

This moves the call to charlcd_backlight from the end of the switch
into the actual case statement that originates the change of the
backlight. This is more consistent to what is now found in this switch.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 339acb08 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: Move char redefine code to hd44780_common

Take the code to redefine characters out of charlcd and move it to
hd44780_common, as this is hd44780 specific.
There is now a function hd44780_common_redefine_char that drivers use
and charlcd calls it through its ops function pointer.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 8a86270e 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: cleanup unnecessary hd44780 code in charlcd

This cleans up now unnecessary hd44780 specific code from charlcd. We
obsoleted this with the last patch. So another chunk of hd44780 specific
code can be dropped from charlcd.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# d2f2187e 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: implement various hd44780_common_ functions

This implements various hd44780_common_ functions for hd44780 compatible
display drivers to use. charlcd then calls these functions through its
ops function pointer.
The functions namely are:
- hd44780_common_shift_cursor
- hd44780_common_display_shift
- hd44780_common_display
- hd44780_common_cursor
- hd44780_common_blink
- hd44780_common_fontsize
- hd44780_common_lines

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 01ec46df 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: Move init_display to hd44780_common

The init_display function is moved over to hd44780_common. charlcd uses
it via its ops function pointer and drivers initialize the ops with the
common hd44780_common_init_display function.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# bd26b181 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: Make use of enum for backlight on / off

To turn the backlight on or off use our new enum CHARLCD_ON /
CHARLCD_OFF.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 2bf82b5a 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: make charlcd_backlight visible to hd44780_common

hd44780_common wants to use the charlcd_backlight function, so make it
visible.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 45421ffe 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: Move clear_display to hd44780_common

This moves the clear_display function from charlcd to hd44780_common.
This is one more step to make charlcd independent from device specific
code. The two hd44780 drivers use the new function from hd44780_common
and charlcd calls this function through its function pointer in its ops
structure.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 88645a86 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: add home to charlcd_ops

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>


# d3a2fb81 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: provide hd44780_common_gotoxy

Provide a hd44780_common_gotoxy function and a pointer in the ops for
charlcd to use to move the cursor.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# b26deabb 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: hd44780_common_print

We create a hd44780_common_print function. It is derived from the
original charlcd_print. charlcd_print becomes a device independent print
function, that then only calls via its ops function pointers, into the
print function offered by drivers.

Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 11588b59 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: Move addr out of charlcd_priv

Move out the struct addr from struct charlcd_priv into the less private
struct charlcd. This member is used to pass position information. The
individual drivers need to be able to read this information, so we move
this out of charlcd_priv to charlcd structure.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 2c6a82f2 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: Move write_cmd pointers to hd44780 drivers

The write_cmd function is used to send commands to hd44780 displays.
The individual hd44780 drivers then implement their appropriate way of
doing this with their supported displays. So we move this pointer so
hd44780_common.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 71ff701b 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: Move write_data pointer to hd44780_common

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 <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 3fc04dd7 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: Move ifwidth to struct hd44780_common

Move struct charlcd member ifwidth to our new struct hd44780_common.
ifwidth is hd44780 device specific and is used by two drivers at the
moment, so we move it to a common place, where both can use this.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 2545c1c9 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: Move hwidth and bwidth to struct hd44780_common

hwidth is for the hardware buffer size and bwidth is for the buffer
width of one single line. This is specific to the hd44780 displays and
so it is moved out from charlcd to struct hd44780_common.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 66ce7d5c 03-Nov-2020 Lars Poeschel <poeschel@lemonage.de>

auxdisplay: Use an enum for charlcd backlight on/off ops

We use an enum for calling the functions in charlcd, that turn the
backlight on or off. This enum is generic and can be used for other
charlcd turn on / turn off operations as well.

Reviewed-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# 3f03b649 18-May-2020 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code

hex_to_bin() may be used to convert hexdecimal digit to its binary
representation.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# 6ce6ae7c 11-Mar-2020 Zhenzhong Duan <zhenzhong.duan@gmail.com>

misc: cleanup minor number definitions in c file into miscdevice.h

HWRNG_MINOR and RNG_MISCDEV_MINOR are duplicate definitions, use
unified HWRNG_MINOR instead and moved into miscdevice.h

ANSLCD_MINOR and LCD_MINOR are duplicate definitions, use unified
LCD_MINOR instead and moved into miscdevice.h

MISCDEV_MINOR is renamed to PXA3XX_GCU_MINOR and moved into
miscdevice.h

Other definitions are just moved without any change.

Link: https://lore.kernel.org/lkml/20200120221323.GJ15860@mit.edu/t/
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Build-tested-by: Willy TARREAU <wtarreau@haproxy.com>
Build-tested-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@gmail.com>
Acked-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Link: https://lore.kernel.org/r/20200311071654.335-2-zhenzhong.duan@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2f920c0f 12-Feb-2020 Gustavo A. R. Silva <gustavo@embeddedor.com>

auxdisplay: charlcd: replace zero-length array with flexible-array member

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
int stuff;
struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# d717e7da 04-Dec-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

auxdisplay: charlcd: deduplicate simple_strtoul()

Like in commit 8b2303de399f ("serial: core: Fix handling of options
after MMIO address") we may use simple_strtoul() which in comparison to
kstrtoul() can do conversion in-place without additional and unnecessary
code to be written.

Link: http://lkml.kernel.org/r/20190801192904.41087-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Mans Rullgard <mans@mansr.com>
Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 75354284 06-Aug-2019 Masahiro Yamada <yamada.masahiro@socionext.com>

auxdisplay: charlcd: move charlcd.h to drivers/auxdisplay

This header is included in drivers/auxdisplay/. Make it a local header.

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# cc5d04d8 01-Mar-2019 Mans Rullgard <mans@mansr.com>

auxdisplay: charlcd: make backlight initial state configurable

The charlcd driver currently flashes the backlight once on init.
This may not be desirable. Thus, add options for turning the
backlight off or on as well.

Signed-off-by: Mans Rullgard <mans@mansr.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# c9171722 01-Mar-2019 Mans Rullgard <mans@mansr.com>

auxdisplay: charlcd: simplify init message display

If CONFIG_PANEL_CHANGE_MESSAGE is set, CONFIG_PANEL_BOOT_MESSAGE will
also be defined, so the double ifdef is pointless. Simplify the code
further by using an intermediate macro rather duplicating most of the
line.

Signed-off-by: Mans Rullgard <mans@mansr.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# 8e44fc85 12-Mar-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

auxdisplay: charlcd: Introduce charlcd_free() helper

The charlcd_free() is a counterpart to charlcd_alloc()
and should be called symmetrically on tear down.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# b658a211 12-Mar-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

auxdisplay: charlcd: Move to_priv() to charlcd namespace

In order to be more particular in names, rename to_priv() macro
to charlcd_to_priv().

No functional change intended.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# 9bc30ab8 05-Dec-2018 Mans Rullgard <mans@mansr.com>

auxdisplay: charlcd: fix x/y command parsing

The x/y command parsing has been broken since commit 129957069e6a
("staging: panel: Fixed checkpatch warning about simple_strtoul()").

Commit b34050fadb86 ("auxdisplay: charlcd: Fix and clean up handling of
x/y commands") fixed some problems by rewriting the parsing code,
but also broke things further by removing the check for a complete
command before attempting to parse it. As a result, parsing is
terminated at the first x or y character.

This reinstates the check for a final semicolon. Whereas the original
code use strchr(), this is wasteful seeing as the semicolon is always
at the end of the buffer. Thus check this character directly instead.

Signed-off-by: Mans Rullgard <mans@mansr.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# 17161392 26-Jan-2018 Jia-Ju Bai <baijiaju1990@gmail.com>

auxdisplay: charlcd: delete mdelay in long_sleep

The function long_sleep() calls mdelay() when in an interrupt handler.
But only charlcd_clear_display() and charlcd_init_display calls
long_sleep(), and my tool finds that the two functions
are never called in an interrupt handler.
Thus mdelay() and in_interrupt() are not necessary.

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Acked-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# 351f683b 17-Feb-2018 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>

auxdisplay: Replace licenses with SPDX identifiers

Cc: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Willy Tarreau <w@1wt.eu>
Acked-by: Linus Walleij <triad@dflund.se>
Acked-by: Robin van der Gracht <robin@protonic.nl>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# b34050fa 27-Feb-2018 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>

auxdisplay: charlcd: Fix and clean up handling of x/y commands

The current version is not parsing multiple x/y commands as the code
originally intended. On top of that, kstrtoul() expects
NULL-terminated strings. Finally, the code does two passes over
the string.

Some explanations about the supported syntax are added as well.

Cc: Willy Tarreau <w@1wt.eu>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Robert Abel <rabel@robertabel.eu>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# 2e8c04f7 09-Feb-2018 Robert Abel <rabel@robertabel.eu>

auxdisplay: charlcd: fix hex literal ranges for graphics command

The graphics command expects 16 hexadecimal literals, but would allow
characters in range [0-9a-zA-Z] instead of [0-9a-fA-F].

Signed-off-by: Robert Abel <rabel@robertabel.eu>
Acked-by: Willy Tarreau <w@1wt.eu>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# 99b9b490 25-Feb-2018 Robert Abel <rabel@robertabel.eu>

auxdisplay: charlcd: fix two-line command ^[[LN not marked as processed

Signed-off-by: Robert Abel <rabel@robertabel.eu>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# 9629ccca 09-Feb-2018 Robert Abel <rabel@robertabel.eu>

auxdisplay: charlcd: replace octal literal with form-feed escape sequence

There is no need to resort to octal escape sequence for the form feed
character when an established escape sequence exists.

Signed-off-by: Robert Abel <rabel@robertabel.eu>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# 8c483758 09-Feb-2018 Robert Abel <rabel@robertabel.eu>

auxdisplay: charlcd: use null character instead of zero literal to terminate strings

Using '\0' instead of plain 0 makes the intent clearer that this is
indeed a string and not a series of integers.

Signed-off-by: Robert Abel <rabel@robertabel.eu>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# 54bc937f 15-Jan-2018 Sean Young <sean@mess.org>

auxdisplay: charlcd: no need to call charlcd_gotoxy() if nothing changes

If the line extends beyond the width to the screen, nothing changes. The
existing code will call charlcd_gotoxy every time for this case.

Signed-off-by: Sean Young <sean@mess.org>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>


# 93dc1774 07-Sep-2017 Willy Tarreau <w@1wt.eu>

auxdisplay: charlcd: properly restore atomic counter on error path

Commit f4757af ("staging: panel: Fix single-open policy race condition")
introduced in 3.19-rc1 attempted to fix a race condition on the open, but
failed to properly do it and used to exit without restoring the semaphore.

This results in -EBUSY being returned after the first open error until
the module is reloaded or the system restarted (ie: consecutive to a
dual open resulting in -EBUSY or to a permission error).

[ Note for stable maintainers: the code moved from drivers/misc/panel.c
to drivers/auxdisplay/{charlcd,panel}.c during 4.12. The patch easily
applies there (modulo the renamed atomic counter) but I can provide a
tested backport if desired. ]

Fixes: f4757af85 # 3.19-rc1
Cc: stable@vger.kernel.org
Cc: Mariusz Gorski <marius.gorski@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1d3b2af2 10-Mar-2017 Geert Uytterhoeven <geert@linux-m68k.org>

auxdisplay: charlcd: Add support for displays with more than two lines

On displays with more than two lines, the additional lines are stored in
the buffers used for the first two lines, but beyond the visible parts.
Adjust the DDRAM address calculation to cater for this.

When clearing the display, avoid writing more spaces than the actual
size of the physical buffer.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ac201479 10-Mar-2017 Geert Uytterhoeven <geert@linux-m68k.org>

auxdisplay: charlcd: Add support for 4-bit interfaces

In 4-bit mode, 8-bit commands and data are written using two raw writes
to the data interface: high nibble first, low nibble last. This must be
handled by the low-level driver.

However, as we don't know in which mode (4-bit or 8-bit) nor 4-bit phase
the LCD was left, initialization must always be handled using raw
writes, and needs to configure the LCD for 8-bit mode first.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 39f8ea46 10-Mar-2017 Geert Uytterhoeven <geert@linux-m68k.org>

auxdisplay: charlcd: Extract character LCD core from misc/panel

Extract the character LCD core from the Parallel port LCD/Keypad Panel
driver in the misc subsystem, and convert it into a subdriver in the
auxdisplay subsystem. This allows the character LCD core to be used by
other drivers later.

Compilation is controlled by its own Kconfig symbol CHARLCD, which is to
be selected by its users, but can be enabled manually for
compile-testing.

All functions changed their prefix from "lcd_" to "charlcd_", and gained
a "struct charlcd *" parameter to operate on a specific instance.
While the driver API thus is ready to support multiple instances, the
current limitation of a single display (/dev/lcd has a single misc minor
assigned) is retained.

No functional changes intended.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>