09 Mar, 2022
3 commits
-
commit 9ed331f8a0fb674f4f06edf05a1687bf755af27b upstream.
While it might work, the current approach is fragile in a few ways:
- whenever members in the structure are shuffled, the pointer will be wrong
- the resource freeing may include more than covered by kfree()Fix this by using charlcd_free() call instead of kfree().
Fixes: 8c9108d014c5 ("auxdisplay: add a driver for lcd2s character display")
Cc: Lars Poeschel
Signed-off-by: Andy Shevchenko
Signed-off-by: Miguel Ojeda
Signed-off-by: Greg Kroah-Hartman -
commit 898c0a15425a5bcaa8d44bd436eae5afd2483796 upstream.
Once allocated the struct lcd2s_data is never freed.
Fix the memory leak by switching to devm_kzalloc().Fixes: 8c9108d014c5 ("auxdisplay: add a driver for lcd2s character display")
Cc: Lars Poeschel
Signed-off-by: Andy Shevchenko
Signed-off-by: Miguel Ojeda
Signed-off-by: Greg Kroah-Hartman -
commit 4424c35ead667ba2e8de7ab8206da66453e6f728 upstream.
It seems that the lcd2s_redefine_char() has never been properly
tested. The buffer is filled by DEF_CUSTOM_CHAR command followed
by the character number (from 0 to 7), but immediately after that
these bytes are rewritten by the decoded hex stream.Fix the index to fill the buffer after the command and number.
Fixes: 8c9108d014c5 ("auxdisplay: add a driver for lcd2s character display")
Cc: Lars Poeschel
Signed-off-by: Andy Shevchenko
Reviewed-by: Geert Uytterhoeven
[fixed typo in commit message]
Signed-off-by: Miguel Ojeda
Signed-off-by: Greg Kroah-Hartman
11 Jan, 2022
1 commit
-
[ Upstream commit 4daa9ff89ef27be43c15995412d6aee393a78200 ]
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
Signed-off-by: Miguel Ojeda
Signed-off-by: Sasha Levin
19 Nov, 2021
3 commits
-
[ Upstream commit 840fe258332544aa7321921e1723d37b772af7a9 ]
As the ht16k33 frame buffer sub-driver does not register an
fb_ops.fb_blank() handler, blanking does not work:$ echo 1 > /sys/class/graphics/fb0/blank
sh: write error: Invalid argumentFix this by providing a handler that always returns zero, to make sure
blank events will be sent to the actual device handling the backlight.Reported-by: Robin van der Gracht
Suggested-by: Robin van der Gracht
Fixes: 8992da44c6805d53 ("auxdisplay: ht16k33: Driver for LED controller")
Signed-off-by: Geert Uytterhoeven
Signed-off-by: Miguel Ojeda
Signed-off-by: Sasha Levin -
[ Upstream commit 80f9eb70fd9276938f0a131f76d438021bfd8b34 ]
Currently /sys/class/graphics/fb0/bl_curve is not accessible (-ENODEV),
as the driver does not connect the backlight to the frame buffer device.
Fix this moving backlight initialization up, and filling in
fb_info.bl_dev.Fixes: 8992da44c6805d53 ("auxdisplay: ht16k33: Driver for LED controller")
Signed-off-by: Geert Uytterhoeven
Reviewed-by: Robin van der Gracht
Signed-off-by: Miguel Ojeda
Signed-off-by: Sasha Levin -
[ Upstream commit afcb5a811ff3ab3969f09666535eb6018a160358 ]
While writing an empty string to a device attribute is a no-op, and thus
does not need explicit safeguards, the user can still write a single
newline to an attribute file:echo > .../message
If that happens, img_ascii_lcd_display() trims the newline, yielding an
empty string, and causing an infinite loop in img_ascii_lcd_scroll().Fix this by adding a check for empty strings. Clear the display in case
one is encountered.Fixes: 0cad855fbd083ee5 ("auxdisplay: img-ascii-lcd: driver for simple ASCII LCD displays")
Signed-off-by: Geert Uytterhoeven
Signed-off-by: Miguel Ojeda
Signed-off-by: Sasha Levin
16 Jul, 2021
4 commits
-
Resolves the checkpatch warning.
Signed-off-by: Jinchao Wang
[edited wording]
Signed-off-by: Miguel Ojeda -
Switch to use module_parport_driver() to reduce boilerplate code.
Signed-off-by: Andy Shevchenko
Signed-off-by: Miguel Ojeda -
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
Acked-by: Willy Tarreau
Signed-off-by: Miguel Ojeda -
Fixes: 718e05ed92ec ("auxdisplay: Introduce hd44780_common.[ch]")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/lkml/CAHp75VfKyqy+vM0XkP9Yb+znGOTVT4zYCRY3A3nQ7C3WNUVN0g@mail.gmail.com/
Reported-By: Andy Shevchenko
Signed-off-by: Lars Poeschel
Tested-by: Andy Shevchenko
[added Link, Fixes, Cc stable tags, edited message]
Signed-off-by: Miguel Ojeda
07 May, 2021
1 commit
-
The section "19) Editor modelines and other cruft" in
Documentation/process/coding-style.rst clearly says, "Do not include any
of these in source files."I recently receive a patch to explicitly add a new one.
Let's do treewide cleanups, otherwise some people follow the existing code
and attempt to upstream their favoriate editor setups.It is even nicer if scripts/checkpatch.pl can check it.
If we like to impose coding style in an editor-independent manner, I think
editorconfig (patch [1]) is a saner solution.[1] https://lore.kernel.org/lkml/20200703073143.423557-1-danny@kdrag0n.dev/
Link: https://lkml.kernel.org/r/20210324054457.1477489-1-masahiroy@kernel.org
Signed-off-by: Masahiro Yamada
Acked-by: Geert Uytterhoeven
Reviewed-by: Miguel Ojeda [auxdisplay]
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
16 Mar, 2021
1 commit
-
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
[mo: fixed a couple typos in comment and commit message]
Signed-off-by: Miguel Ojeda
27 Feb, 2021
1 commit
-
Update contact info.
Link: https://lkml.kernel.org/r/20210206162524.GA11520@kernel.org
Signed-off-by: Miguel Ojeda
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
26 Jan, 2021
3 commits
-
A second CHARLCD config symbol was added instead of moving the existing
one. Fix this by removing the old one.Fixes: 718e05ed92ecac0d ("auxdisplay: Introduce hd44780_common.[ch]")
Signed-off-by: Geert Uytterhoeven
Signed-off-by: Miguel Ojeda -
Drop the call to msecs_to_jiffies(), as "HZ / fbdev->refresh_rate" is
already the number of jiffies to wait.Fixes: 8992da44c6805d53 ("auxdisplay: ht16k33: Driver for LED controller")
Signed-off-by: Geert Uytterhoeven
Signed-off-by: Miguel Ojeda -
Keyscan should be optional to support simple LED matrix displays (output
only).Reported-by: Michael Kaplan
Signed-off-by: Robin van der Gracht
[geert: Rebased]
Signed-off-by: Geert Uytterhoeven
Acked-by: Robin van der Gracht
Signed-off-by: Miguel Ojeda
17 Nov, 2020
2 commits
-
The three struct charlcd_ops contain the same data, so we only need one
of this structures. The other two are removed.Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
charlcd drivers need to provide some print function to charlcd. For
hd44780 based panel driver this function was missing. We provide the
generic hd44780_common_print function which should be suitable.Fixes: b26deabb1d915fe87d395081bbd3058b938dee89 ("auxdisplay: hd44780_common_print")
Reported-by: kernel test robot
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda
14 Nov, 2020
1 commit
-
drivers/auxdisplay/lcd2s.c:373:3-8: No need to set .owner here. The core will do it.
Remove .owner field if calls are used which set it automatically
Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
Fixes: 8c9108d014c5 ("auxdisplay: add a driver for lcd2s character display")
CC: Lars Poeschel
Reported-by: kernel test robot
Signed-off-by: kernel test robot
Signed-off-by: Miguel Ojeda
09 Nov, 2020
2 commits
-
The kfree() needs to be moved down a line to prevent a use after free.
Fixes: 8c9108d014c5 ("auxdisplay: add a driver for lcd2s character display")
Signed-off-by: Dan Carpenter
Signed-off-by: Miguel Ojeda -
When building the hd44780_common driver without a driver that actually
uses it like panel or hd44780 you get a build error, because
hd44780_common uses charlcd, but did not select it. Its users did
select it.This is fixed now. hd4478_common now selects charlcd in Kconfig and
panel and hd44780 do not. They only select hd44780_common.Reported-by: Randy Dunlap
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda
04 Nov, 2020
18 commits
-
This driver allows to use a lcd2s 20x4 character display from Modtronix
engineering as an auxdisplay charlcd device.Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
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
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
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
Signed-off-by: Miguel Ojeda -
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
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
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
Signed-off-by: Miguel Ojeda -
Digging in the hd44780 datasheet revealed that the timeout needed after
clearing the whole display is only 1,64ms not 15ms. So we can reduce
that timeout.Link: https://lore.kernel.org/lkml/20200922092121.GG16421@1wt.eu/
Link: https://www.crystalfontz.com/controllers/Hitachi/HD44780/433/Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
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
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
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
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
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
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
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_linesReviewed-by: Willy Tarreau
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
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
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
To turn the backlight on or off use our new enum CHARLCD_ON /
CHARLCD_OFF.Reviewed-by: Willy Tarreau
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
hd44780_common wants to use the charlcd_backlight function, so make it
visible.Reviewed-by: Willy Tarreau
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
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
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
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
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
Provide a hd44780_common_gotoxy function and a pointer in the ops for
charlcd to use to move the cursor.Reviewed-by: Willy Tarreau
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
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
Reviewed-by: Willy Tarreau
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda -
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
Signed-off-by: Lars Poeschel
Signed-off-by: Miguel Ojeda