staging: panel: register reboot
PATCH v2 1/3 staging: panel: register reboot
we donot need the reboot notifier in module init section, as the notifier is used after lcd is initialized. so lets register for the reboot notifier only after we have successfully attached to the parallel port. and similarly unregister at detach.
---
v2: same as v1
drivers/staging/panel/panel.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/panel/panel.c +3 -4
@@ -2206,6 +2206,7 @@ static void panel_attach(struct parport *port)if (misc_register (&keypad_dev)) goto err_lcd_unreg; } +register_reboot_notifier (&panel_notifier);return ; err_lcd_unreg:
@@ -2227,6 +2228,8 @@ static void panel_detach(struct parport *port)return ; } +unregister_reboot_notifier (&panel_notifier); +if (keypad.enabled && keypad_initialized) {misc_deregister (&keypad_dev); keypad_initialized =0 ;
@@ -2293,7 +2296,6 @@ static int __init panel_init_module(void)break ; } -/* * Overwrite selection with module param values (both keypad and lcd), * where the deprecated params have lower prio.
@@ -2363,8 +2365,6 @@ static int __init panel_init_module(void)return -EIO ; } -register_reboot_notifier (&panel_notifier); -if (pprt) pr_info("driver version " PANEL_VERSION " registered on parport%d (io=0x%lx).\n", parport,
@@ -2380,7 +2380,6 @@ static int __init panel_init_module(void) static void __exit panel_cleanup_module(void) { -unregister_reboot_notifier (&panel_notifier);if (scan_timer.function !=NULL )del_timer_sync (&scan_timer);
Signature · 1 line
1.8.1.2
PATCH v2 2/3 staging: panel: return register value
we were returning success even if the module failed to register. now we are returning the actual return value, success or error.
---
v2: added the error message if parport_register_driver() fails.
drivers/staging/panel/panel.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/panel/panel.c +4 -3
@@ -2254,7 +2254,7 @@ static struct parport_driver panel_driver = {/* init function */ static int __init panel_init_module (void ) { -int selected_keypad_type =NOT_SET ; +int selected_keypad_type =NOT_SET , err;/* take care of an eventual profile */ switch (profile) {
@@ -2360,9 +2360,10 @@ static int __init panel_init_module(void)return -ENODEV ; } -if (parport_register_driver (&panel_driver)) { + err =parport_register_driver (&panel_driver); +if (err) {pr_err ("could not register with parport. Aborting.\n" ); -return -EIO ; +return err; }if (pprt)
Signature · 1 line
1.8.1.2
Re: [PATCH v2 2/3] staging: panel: return register value
Quoted 4 lines · Sudip Mukherjee
we were returning success even if the module failed to register. now we are returning the actual return value, success or error.
Signed-off-by Sudip Mukherjee <[email protected]>
Thanks for this.
Willy
PATCH v2 3/3 staging: panel: remove initialization check
In reply to Sudip Mukherjeeno need to monitor init_in_progress now as keypad_send_key() can only be called after the timer is initialized. and timer is initialized from keypad_init() which is in the attach section and can only execute after the module has initialized.
---
v2: same as v1, only it had to be rewritten because of the changes in patch 2/3
drivers/staging/panel/panel.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/staging/panel/panel.c +0 -11
@@ -452,8 +452,6 @@ static struct pardevice *pprt;static int keypad_initialized; -static char init_in_progress; -static void (*lcd_write_cmd)(int );static void (*lcd_write_data)(int );static void (*lcd_clear_fast)(void );
@@ -1688,9 +1686,6 @@ static struct miscdevice keypad_dev = {static void keypad_send_key (const char *string,int max_len) { -if (init_in_progress) -return ; -/* send the key to the device only if a process is attached to it. */ if (!atomic_read (&keypad_available)) {while (max_len-- && keypad_buflen <KEYPAD_BUFFER && *string) {
@@ -2351,9 +2346,6 @@ static int __init panel_init_module(void)break ; } -/* tells various subsystems about the fact that we are initializing */ - init_in_progress =1 ; -if (!lcd.enabled && !keypad.enabled) {/* no device enabled, let's exit */ pr_err ("driver version " PANEL_VERSION " disabled.\n" );
@@ -2373,9 +2365,6 @@ static int __init panel_init_module(void)else pr_info ("driver version " PANEL_VERSION " not yet registered\n" ); -/* tells various subsystems about the fact that initialization -is finished */ - init_in_progress =0 ;return 0 ; }
Signature · 1 line
1.8.1.2