Skip to contentSkip to conversation

staging: panel: register driver after checking device

PATCH In review Sudip Mukherjee 2 participants 4 messages Feb 10, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 staging: panel: register driver after checking device

register the driver only if lcd or keypad has been enabled and if both are disabled then just exit.

---
 drivers/staging/panel/panel.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/staging/panel/panel.c +6 -12
index 6ed35b6..df044b2 100644
@@ -2379,23 +2379,17 @@ static int __init panel_init_module(void)
 	/* tells various subsystems about the fact that we are initializing */
 	init_in_progress = 1;
 
-	if (parport_register_driver(&panel_driver)) {
-		pr_err("could not register with parport. Aborting.\n");
-		return -EIO;
-	}
-
 	if (!lcd.enabled && !keypad.enabled) {
-		/* no device enabled, let's release the parport */
-		if (pprt) {
-			parport_release(pprt);
-			parport_unregister_device(pprt);
-			pprt = NULL;
-		}
-		parport_unregister_driver(&panel_driver);
+		/* no device enabled, let's exit */
 		pr_err("driver version " PANEL_VERSION " disabled.\n");
 		return -ENODEV;
 	}
 
+	if (parport_register_driver(&panel_driver)) {
+		pr_err("could not register with parport. Aborting.\n");
+		return -EIO;
+	}
+
 	register_reboot_notifier(&panel_notifier);
 
 	if (pprt)
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 2/2 staging: panel: initialize lcd if lcd enabled

initialiaze lcd parameters only if lcd is enabled.

---
 drivers/staging/panel/panel.c | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)
drivers/staging/panel/panel.c +22 -19
index df044b2..05657f2 100644
@@ -2323,25 +2323,6 @@ static int __init panel_init_module(void)
 		break;
 	}
 
-	/*
-	 * Init lcd struct with load-time values to preserve exact current
-	 * functionality (at least for now).
-	 */
-	lcd.height = lcd_height;
-	lcd.width = lcd_width;
-	lcd.bwidth = lcd_bwidth;
-	lcd.hwidth = lcd_hwidth;
-	lcd.charset = lcd_charset;
-	lcd.proto = lcd_proto;
-	lcd.pins.e = lcd_e_pin;
-	lcd.pins.rs = lcd_rs_pin;
-	lcd.pins.rw = lcd_rw_pin;
-	lcd.pins.cl = lcd_cl_pin;
-	lcd.pins.da = lcd_da_pin;
-	lcd.pins.bl = lcd_bl_pin;
-
-	/* Leave it for now, just in case */
-	lcd.esc_seq.len = -1;
 
 	/*
 	 * Overwrite selection with module param values (both keypad and lcd),
@@ -2361,6 +2342,28 @@ static int __init panel_init_module(void)
 
 	lcd.enabled = (selected_lcd_type > 0);
 
+	if (lcd.enabled) {
+		/*
+		 * Init lcd struct with load-time values to preserve exact
+		 * current functionality (at least for now).
+		 */
+		lcd.height = lcd_height;
+		lcd.width = lcd_width;
+		lcd.bwidth = lcd_bwidth;
+		lcd.hwidth = lcd_hwidth;
+		lcd.charset = lcd_charset;
+		lcd.proto = lcd_proto;
+		lcd.pins.e = lcd_e_pin;
+		lcd.pins.rs = lcd_rs_pin;
+		lcd.pins.rw = lcd_rw_pin;
+		lcd.pins.cl = lcd_cl_pin;
+		lcd.pins.da = lcd_da_pin;
+		lcd.pins.bl = lcd_bl_pin;
+
+	/* Leave it for now, just in case */
+		lcd.esc_seq.len = -1;
+	}
+
 	switch (selected_keypad_type) {
 	case KEYPAD_TYPE_OLD:
 		keypad_profile = old_keypad_profile;
Signature · 1 line
1.8.1.2
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] staging: panel: initialize lcd if lcd enabled

Quoted 3 lines · Sudip Mukherjee

initialiaze lcd parameters only if lcd is enabled.

One minor comment below (cosmetic), but after this it's OK.

Quoted 9 lines
drivers/staging/panel/panel.c +9 -0
+	if (lcd.enabled) {
+		/*
+		 * Init lcd struct with load-time values to preserve exact
+		 * current functionality (at least for now).
+		 */
+		lcd.height = lcd_height;
+		lcd.width = lcd_width;
+		lcd.bwidth = lcd_bwidth;
+		lcd.hwidth = lcd_hwidth;

drivers/staging/panel/panel.c static int __init panel_init_module(void) · line 2363

Quoted 10 lines
drivers/staging/panel/panel.c +10 -0
+		lcd.charset = lcd_charset;
+		lcd.proto = lcd_proto;
+		lcd.pins.e = lcd_e_pin;
+		lcd.pins.rs = lcd_rs_pin;
+		lcd.pins.rw = lcd_rw_pin;
+		lcd.pins.cl = lcd_cl_pin;
+		lcd.pins.da = lcd_da_pin;
+		lcd.pins.bl = lcd_bl_pin;
+
+	/* Leave it for now, just in case */

^^^^^^^^^^^^^^^^^^^
Please fix indenting the comment here.

drivers/staging/panel/panel.c static int __init panel_init_module(void) · line 2366

Quoted 3 lines
drivers/staging/panel/panel.c +3 -0
+		lcd.esc_seq.len = -1;
+	}
+

Willy