From 9059c615a8ba503cb5a7823d7f943a384e6063e3 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Tue, 7 Apr 2015 13:55:01 +0530 Subject: staging: panel: remove duplicate code both the misc_deregister(), parport_release() and parport_unregister_device() is there in the module_exit function also. detach is called from parport_unregister_driver() and by the time detach executes misc_deregister(), parport_release() and parport_unregister_device() has already executed marking keypad_initialized and lcd.initialized as false. so this part of the code will never execute. Signed-off-by: Sudip Mukherjee Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'drivers/staging/panel') diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index ea54fb4..1d8ed8b 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -2252,20 +2252,6 @@ static void panel_detach(struct parport *port) } unregister_reboot_notifier(&panel_notifier); - - if (keypad.enabled && keypad_initialized) { - misc_deregister(&keypad_dev); - keypad_initialized = 0; - } - - if (lcd.enabled && lcd.initialized) { - misc_deregister(&lcd_dev); - lcd.initialized = false; - } - - parport_release(pprt); - parport_unregister_device(pprt); - pprt = NULL; } static struct parport_driver panel_driver = { -- cgit v1.1 From 7d98c63edc45e4ab3096af2c8d98fd2d94249640 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Tue, 12 May 2015 17:36:08 +0530 Subject: staging: panel: fix stackdump if we load the module, unload and then again try to load the module, we will get a stackdump. In the module_exit function we are unregistering the device and releasing the parport. So when we reach the detach function parport is already null and the unregister_reboot_notifier() is never called. When we again try to load the module it again tries register_reboot_notifier() and gives us a stackdump as its earlier registration is still not removed. It was caused by the commit bb046fef9668 ('staging: panel: register reboot') Fix this by moving all the unregistering and releasing in the detach function, which should be the ideal case as the detach will be called if we try to unregister the driver or if the parport is removed. Fixes: bb046fef9668 ('staging: panel: register reboot') Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 44 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 23 deletions(-) (limited to 'drivers/staging/panel') diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 1d8ed8b..0046ee0a 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -2250,8 +2250,28 @@ static void panel_detach(struct parport *port) __func__, port->number, parport); return; } + if (scan_timer.function != NULL) + del_timer_sync(&scan_timer); - unregister_reboot_notifier(&panel_notifier); + if (pprt != NULL) { + if (keypad.enabled) { + misc_deregister(&keypad_dev); + keypad_initialized = 0; + } + + if (lcd.enabled) { + panel_lcd_print("\x0cLCD driver " PANEL_VERSION + "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-"); + misc_deregister(&lcd_dev); + lcd.initialized = false; + } + + /* TODO: free all input signals */ + parport_release(pprt); + parport_unregister_device(pprt); + pprt = NULL; + unregister_reboot_notifier(&panel_notifier); + } } static struct parport_driver panel_driver = { @@ -2384,28 +2404,6 @@ static int __init panel_init_module(void) static void __exit panel_cleanup_module(void) { - - if (scan_timer.function != NULL) - del_timer_sync(&scan_timer); - - if (pprt != NULL) { - if (keypad.enabled) { - misc_deregister(&keypad_dev); - keypad_initialized = 0; - } - - if (lcd.enabled) { - panel_lcd_print("\x0cLCD driver " PANEL_VERSION - "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-"); - misc_deregister(&lcd_dev); - lcd.initialized = false; - } - - /* TODO: free all input signals */ - parport_release(pprt); - parport_unregister_device(pprt); - pprt = NULL; - } parport_unregister_driver(&panel_driver); } -- cgit v1.1 From 895875a3d85596e3e2e46aeb382bf14f1419de82 Mon Sep 17 00:00:00 2001 From: Nicholas Mc Guire Date: Fri, 29 May 2015 19:02:32 +0200 Subject: staging: panel: use schedule_timeout_interruptible() API consolidation with coccinelle found: ./drivers/staging/panel/panel.c:782:2-18: consolidation with schedule_timeout_*() recommended This is a 1:1 conversion with respect to schedule_timeout() to the schedule_timeout_interruptible() helper only - so only an API consolidation to improve readability. The timeout was being passed as (ms * HZ + 999) / 1000 but that simply looks wrong - rather than "manual" converting to jiffies, msecs_to_jiffies which handles all corner-cases correctly, was used. Patch was compile tested with x86_64_defconfig + CONFIG_STAGING=y, CONFIG_PARPORT=m, CONFIG_PANEL=m Signed-off-by: Nicholas Mc Guire Acked-by: Willy Tarreau Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers/staging/panel') diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 0046ee0a..d670494 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -775,12 +775,10 @@ static void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val) /* sleeps that many milliseconds with a reschedule */ static void long_sleep(int ms) { - if (in_interrupt()) { + if (in_interrupt()) mdelay(ms); - } else { - __set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout((ms * HZ + 999) / 1000); - } + else + schedule_timeout_interruptible(msecs_to_jiffies(ms)); } /* send a serial byte to the LCD panel. The caller is responsible for locking -- cgit v1.1