Skip to content

Commit e0046bb

Browse files
committed
Merge tag 'auxdisplay-for-linus-v5.1-rc2' of git://github.com/ojeda/linux
Pull auxdisplay updates from Miguel Ojeda: "A few fixes and improvements for auxdisplay: - Series to fix a memory leak in hd44780 while introducing charlcd_free(). From Andy Shevchenko - Series to clean up the Kconfig menus and a couple of improvements for charlcd. From Mans Rullgard" * tag 'auxdisplay-for-linus-v5.1-rc2' of git://github.com/ojeda/linux: auxdisplay: charlcd: make backlight initial state configurable auxdisplay: charlcd: simplify init message display auxdisplay: deconfuse configuration auxdisplay: hd44780: Convert to use charlcd_free() auxdisplay: panel: Convert to use charlcd_free() auxdisplay: charlcd: Introduce charlcd_free() helper auxdisplay: charlcd: Move to_priv() to charlcd namespace auxdisplay: hd44780: Fix memory leak on ->remove()
2 parents 1fa8109 + cc5d04d commit e0046bb

File tree

6 files changed

+75
-29
lines changed

6 files changed

+75
-29
lines changed

drivers/auxdisplay/Kconfig

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ config ARM_CHARLCD
164164
line and the Linux version on the second line, but that's
165165
still useful.
166166

167-
endif # AUXDISPLAY
168-
169-
menuconfig PANEL
167+
menuconfig PARPORT_PANEL
170168
tristate "Parallel port LCD/Keypad Panel support"
171169
depends on PARPORT
172170
select CHARLCD
@@ -178,7 +176,7 @@ menuconfig PANEL
178176
compiled as a module, or linked into the kernel and started at boot.
179177
If you don't understand what all this is about, say N.
180178

181-
if PANEL
179+
if PARPORT_PANEL
182180

183181
config PANEL_PARPORT
184182
int "Default parallel port number (0=LPT1)"
@@ -419,8 +417,11 @@ config PANEL_LCD_PIN_BL
419417

420418
Default for the 'BL' pin in custom profile is '0' (uncontrolled).
421419

420+
endif # PARPORT_PANEL
421+
422422
config PANEL_CHANGE_MESSAGE
423423
bool "Change LCD initialization message ?"
424+
depends on CHARLCD
424425
default "n"
425426
---help---
426427
This allows you to replace the boot message indicating the kernel version
@@ -444,7 +445,34 @@ config PANEL_BOOT_MESSAGE
444445
An empty message will only clear the display at driver init time. Any other
445446
printf()-formatted message is valid with newline and escape codes.
446447

447-
endif # PANEL
448+
choice
449+
prompt "Backlight initial state"
450+
default CHARLCD_BL_FLASH
451+
452+
config CHARLCD_BL_OFF
453+
bool "Off"
454+
help
455+
Backlight is initially turned off
456+
457+
config CHARLCD_BL_ON
458+
bool "On"
459+
help
460+
Backlight is initially turned on
461+
462+
config CHARLCD_BL_FLASH
463+
bool "Flash"
464+
help
465+
Backlight is flashed briefly on init
466+
467+
endchoice
468+
469+
endif # AUXDISPLAY
470+
471+
config PANEL
472+
tristate "Parallel port LCD/Keypad Panel support (OLD OPTION)"
473+
depends on PARPORT
474+
select AUXDISPLAY
475+
select PARPORT_PANEL
448476

449477
config CHARLCD
450478
tristate "Character LCD core support" if COMPILE_TEST

drivers/auxdisplay/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ obj-$(CONFIG_CFAG12864B) += cfag12864b.o cfag12864bfb.o
1010
obj-$(CONFIG_IMG_ASCII_LCD) += img-ascii-lcd.o
1111
obj-$(CONFIG_HD44780) += hd44780.o
1212
obj-$(CONFIG_HT16K33) += ht16k33.o
13-
obj-$(CONFIG_PANEL) += panel.o
13+
obj-$(CONFIG_PARPORT_PANEL) += panel.o

drivers/auxdisplay/charlcd.c

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct charlcd_priv {
9191
unsigned long long drvdata[0];
9292
};
9393

94-
#define to_priv(p) container_of(p, struct charlcd_priv, lcd)
94+
#define charlcd_to_priv(p) container_of(p, struct charlcd_priv, lcd)
9595

9696
/* Device single-open policy control */
9797
static atomic_t charlcd_available = ATOMIC_INIT(1);
@@ -105,7 +105,7 @@ static void long_sleep(int ms)
105105
/* turn the backlight on or off */
106106
static void charlcd_backlight(struct charlcd *lcd, int on)
107107
{
108-
struct charlcd_priv *priv = to_priv(lcd);
108+
struct charlcd_priv *priv = charlcd_to_priv(lcd);
109109

110110
if (!lcd->ops->backlight)
111111
return;
@@ -134,7 +134,7 @@ static void charlcd_bl_off(struct work_struct *work)
134134
/* turn the backlight on for a little while */
135135
void charlcd_poke(struct charlcd *lcd)
136136
{
137-
struct charlcd_priv *priv = to_priv(lcd);
137+
struct charlcd_priv *priv = charlcd_to_priv(lcd);
138138

139139
if (!lcd->ops->backlight)
140140
return;
@@ -152,7 +152,7 @@ EXPORT_SYMBOL_GPL(charlcd_poke);
152152

153153
static void charlcd_gotoxy(struct charlcd *lcd)
154154
{
155-
struct charlcd_priv *priv = to_priv(lcd);
155+
struct charlcd_priv *priv = charlcd_to_priv(lcd);
156156
unsigned int addr;
157157

158158
/*
@@ -170,7 +170,7 @@ static void charlcd_gotoxy(struct charlcd *lcd)
170170

171171
static void charlcd_home(struct charlcd *lcd)
172172
{
173-
struct charlcd_priv *priv = to_priv(lcd);
173+
struct charlcd_priv *priv = charlcd_to_priv(lcd);
174174

175175
priv->addr.x = 0;
176176
priv->addr.y = 0;
@@ -179,7 +179,7 @@ static void charlcd_home(struct charlcd *lcd)
179179

180180
static void charlcd_print(struct charlcd *lcd, char c)
181181
{
182-
struct charlcd_priv *priv = to_priv(lcd);
182+
struct charlcd_priv *priv = charlcd_to_priv(lcd);
183183

184184
if (priv->addr.x < lcd->bwidth) {
185185
if (lcd->char_conv)
@@ -211,7 +211,7 @@ static void charlcd_clear_fast(struct charlcd *lcd)
211211
/* clears the display and resets X/Y */
212212
static void charlcd_clear_display(struct charlcd *lcd)
213213
{
214-
struct charlcd_priv *priv = to_priv(lcd);
214+
struct charlcd_priv *priv = charlcd_to_priv(lcd);
215215

216216
lcd->ops->write_cmd(lcd, LCD_CMD_DISPLAY_CLEAR);
217217
priv->addr.x = 0;
@@ -223,7 +223,7 @@ static void charlcd_clear_display(struct charlcd *lcd)
223223
static int charlcd_init_display(struct charlcd *lcd)
224224
{
225225
void (*write_cmd_raw)(struct charlcd *lcd, int cmd);
226-
struct charlcd_priv *priv = to_priv(lcd);
226+
struct charlcd_priv *priv = charlcd_to_priv(lcd);
227227
u8 init;
228228

229229
if (lcd->ifwidth != 4 && lcd->ifwidth != 8)
@@ -369,7 +369,7 @@ static bool parse_xy(const char *s, unsigned long *x, unsigned long *y)
369369

370370
static inline int handle_lcd_special_code(struct charlcd *lcd)
371371
{
372-
struct charlcd_priv *priv = to_priv(lcd);
372+
struct charlcd_priv *priv = charlcd_to_priv(lcd);
373373

374374
/* LCD special codes */
375375

@@ -580,7 +580,7 @@ static inline int handle_lcd_special_code(struct charlcd *lcd)
580580

581581
static void charlcd_write_char(struct charlcd *lcd, char c)
582582
{
583-
struct charlcd_priv *priv = to_priv(lcd);
583+
struct charlcd_priv *priv = charlcd_to_priv(lcd);
584584

585585
/* first, we'll test if we're in escape mode */
586586
if ((c != '\n') && priv->esc_seq.len >= 0) {
@@ -705,7 +705,7 @@ static ssize_t charlcd_write(struct file *file, const char __user *buf,
705705

706706
static int charlcd_open(struct inode *inode, struct file *file)
707707
{
708-
struct charlcd_priv *priv = to_priv(the_charlcd);
708+
struct charlcd_priv *priv = charlcd_to_priv(the_charlcd);
709709
int ret;
710710

711711
ret = -EBUSY;
@@ -763,10 +763,24 @@ static void charlcd_puts(struct charlcd *lcd, const char *s)
763763
}
764764
}
765765

766+
#ifdef CONFIG_PANEL_BOOT_MESSAGE
767+
#define LCD_INIT_TEXT CONFIG_PANEL_BOOT_MESSAGE
768+
#else
769+
#define LCD_INIT_TEXT "Linux-" UTS_RELEASE "\n"
770+
#endif
771+
772+
#ifdef CONFIG_CHARLCD_BL_ON
773+
#define LCD_INIT_BL "\x1b[L+"
774+
#elif defined(CONFIG_CHARLCD_BL_FLASH)
775+
#define LCD_INIT_BL "\x1b[L*"
776+
#else
777+
#define LCD_INIT_BL "\x1b[L-"
778+
#endif
779+
766780
/* initialize the LCD driver */
767781
static int charlcd_init(struct charlcd *lcd)
768782
{
769-
struct charlcd_priv *priv = to_priv(lcd);
783+
struct charlcd_priv *priv = charlcd_to_priv(lcd);
770784
int ret;
771785

772786
if (lcd->ops->backlight) {
@@ -784,13 +798,8 @@ static int charlcd_init(struct charlcd *lcd)
784798
return ret;
785799

786800
/* display a short message */
787-
#ifdef CONFIG_PANEL_CHANGE_MESSAGE
788-
#ifdef CONFIG_PANEL_BOOT_MESSAGE
789-
charlcd_puts(lcd, "\x1b[Lc\x1b[Lb\x1b[L*" CONFIG_PANEL_BOOT_MESSAGE);
790-
#endif
791-
#else
792-
charlcd_puts(lcd, "\x1b[Lc\x1b[Lb\x1b[L*Linux-" UTS_RELEASE "\n");
793-
#endif
801+
charlcd_puts(lcd, "\x1b[Lc\x1b[Lb" LCD_INIT_BL LCD_INIT_TEXT);
802+
794803
/* clear the display on the next device opening */
795804
priv->must_clear = true;
796805
charlcd_home(lcd);
@@ -818,6 +827,12 @@ struct charlcd *charlcd_alloc(unsigned int drvdata_size)
818827
}
819828
EXPORT_SYMBOL_GPL(charlcd_alloc);
820829

830+
void charlcd_free(struct charlcd *lcd)
831+
{
832+
kfree(charlcd_to_priv(lcd));
833+
}
834+
EXPORT_SYMBOL_GPL(charlcd_free);
835+
821836
static int panel_notify_sys(struct notifier_block *this, unsigned long code,
822837
void *unused)
823838
{
@@ -866,7 +881,7 @@ EXPORT_SYMBOL_GPL(charlcd_register);
866881

867882
int charlcd_unregister(struct charlcd *lcd)
868883
{
869-
struct charlcd_priv *priv = to_priv(lcd);
884+
struct charlcd_priv *priv = charlcd_to_priv(lcd);
870885

871886
unregister_reboot_notifier(&panel_notifier);
872887
charlcd_puts(lcd, "\x0cLCD driver unloaded.\x1b[Lc\x1b[Lb\x1b[L-");

drivers/auxdisplay/hd44780.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ static int hd44780_probe(struct platform_device *pdev)
271271
return 0;
272272

273273
fail:
274-
kfree(lcd);
274+
charlcd_free(lcd);
275275
return ret;
276276
}
277277

@@ -280,6 +280,8 @@ static int hd44780_remove(struct platform_device *pdev)
280280
struct charlcd *lcd = platform_get_drvdata(pdev);
281281

282282
charlcd_unregister(lcd);
283+
284+
charlcd_free(lcd);
283285
return 0;
284286
}
285287

drivers/auxdisplay/panel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ static void panel_attach(struct parport *port)
16201620
if (lcd.enabled)
16211621
charlcd_unregister(lcd.charlcd);
16221622
err_unreg_device:
1623-
kfree(lcd.charlcd);
1623+
charlcd_free(lcd.charlcd);
16241624
lcd.charlcd = NULL;
16251625
parport_unregister_device(pprt);
16261626
pprt = NULL;
@@ -1647,7 +1647,7 @@ static void panel_detach(struct parport *port)
16471647
if (lcd.enabled) {
16481648
charlcd_unregister(lcd.charlcd);
16491649
lcd.initialized = false;
1650-
kfree(lcd.charlcd);
1650+
charlcd_free(lcd.charlcd);
16511651
lcd.charlcd = NULL;
16521652
}
16531653

include/misc/charlcd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct charlcd_ops {
3535
};
3636

3737
struct charlcd *charlcd_alloc(unsigned int drvdata_size);
38+
void charlcd_free(struct charlcd *lcd);
3839

3940
int charlcd_register(struct charlcd *lcd);
4041
int charlcd_unregister(struct charlcd *lcd);

0 commit comments

Comments
 (0)