CONSOLE_LP_STRICT Kconfig option
PATCH 1/1 CONSOLE_LP_STRICT Kconfig option
This patch, built against kernel version 2.6.16-rc3, provides a Kconfig option in order to easily enable or disable CONSOLE_LP_STRICT variable in drivers/char/lp.c without modifying it directly.
drivers/char/lp.c 2006-02-14 13:43:41.000000000 +0100 renamed from drivers/char/lp.c.orig 2006-01-08 16:48:14.000000000 +0100 +8 -4
@@ -686,9 +686,13 @@ static struct file_operations lp_fops = #define CONSOLE_LP 0 /* If the printer is out of paper, we can either lose the messages or - * stall until the printer is happy again. Define CONSOLE_LP_STRICT - * non-zero to get the latter behaviour. */ -#define CONSOLE_LP_STRICT 1 + * stall until the printer is happy again. If CONSOLE_LP_STRICT is + * non-zero to, we get the latter behaviour. */ +#ifdef CONFIG_LP_CONSOLE_STRICT +# define CONSOLE_LP_STRICT 1 +#else +# define CONSOLE_LP_STRICT 0 +#endif /* The console must be locked when we get here. */
@@ -697,7 +701,7 @@ static void lp_console_write (struct con { struct pardevice *dev = lp_table[CONSOLE_LP].dev; struct parport *port = dev->port; - ssize_t written; + ssize_t written = 0; if (parport_claim (dev)) /* Nothing we can do. */
drivers/char/Kconfig 2006-02-14 13:47:33.000000000 +0100 renamed from drivers/char/Kconfig.orig 2006-02-14 00:14:08.000000000 +0100 +13 -6
@@ -512,14 +512,21 @@ config LP_CONSOLE doing that; to actually get it to happen you need to pass the option "console=lp0" to the kernel at boot time. - If the printer is out of paper (or off, or unplugged, or too - busy..) the kernel will stall until the printer is ready again. - By defining CONSOLE_LP_STRICT to 0 (at your own risk) you - can make the kernel continue when this happens, - but it'll lose the kernel messages. - If unsure, say N. +config LP_CONSOLE_STRICT + bool "Wait for a ready printer" + depends on LP_CONSOLE + default y + ---help--- + With this option enabled, if the printer is out of paper (or off, + or unplugged, or too busy..) the kernel will stall until the printer + is ready again. By turning this option off (at your own risk), you + can make the kernel continue when this happens, but it will lose + some kernel messages. + + If unsure, say Y + config PPDEV tristate "Support for user-space parallel port device drivers" depends on PARPORT
Regards,
Signature · 1 line
Luca
Quoted 3 lines · Luca Falavigna
This patch, built against kernel version 2.6.16-rc3, provides a
Kconfigoption in order to easily enable or disableCONSOLE_LP_STRICTvariable indrivers/char/lp.cwithout modifying it directly.
This shouldn't be a CONFIG. This should be a runtime option. It's ridiculous to have to recompile your kernel just to fix some problem with your printer.
e.g. sysctl, ioctl, sysfs entry, module parameter. Whatever is en vogue these days. Easiest would be probably a module_param().
-Andi
Oops, I noticed I sent twice my email. Sorry.
14 Feb 2006 15:59:56 +0100, Andi Kleen <[email protected]>:
Quoted 6 lines
This shouldn't be a CONFIG. This should be a runtime option. It's ridiculous to have to recompile your kernel just to fix some problem with your printer.
e.g. sysctl, ioctl, sysfs entry, module parameter. Whatever is en vogue these days. Easiest would be probably a
module_param().
This feature only gets involved when passing console=lp0 parameter to the bootloader. I never tried to load a new system console while system was running so I'm not sure if it behaves correctly. If it does, I will modify this patch following your advices.
Regards,
--
Luca
Quoted 7 lines · On Wed, 15 Feb 2006 10:03:30 +0100 Luca Falavigna wrote:
Oops, I noticed I sent twice my email. Sorry.
14 Feb 2006 15:59:56 +0100, Andi Kleen <[email protected]>:
Quoted 4 lines
This shouldn't be a CONFIG. This should be a runtime option. It's ridiculous to have to recompile your kernel just to fix some problem with your printer.
Quoted 7 lines
Quoted 2 lines
e.g. sysctl, ioctl, sysfs entry, module parameter. Whatever is en vogue these days. Easiest would be probably a
module_param().This feature only gets involved when passing console=lp0 parameter to the bootloader. I never tried to load a new system console while system was running so I'm not sure if it behaves correctly. If it does, I will modify this patch following your advices.
Andi's suggestion seems fine to me: use a module_param() for CONSOLE_LP_STRICT instead of a hidden build-time (non-Kconfig) option. Are you interested in making this change?
---
~Randy
Quoted 18 lines · On Wed, 12 Apr 2006 20:53:28 +0200 Luca Falavigna wrote:
2006/4/12, Randy.Dunlap <[email protected]>:
Quoted 17 lines · On Wed, 15 Feb 2006 10:03:30 +0100 Luca Falavigna wrote:
Quoted 15 lines
Oops, I noticed I sent twice my email. Sorry.
14 Feb 2006 15:59:56 +0100, Andi Kleen <[email protected]>:
Quoted 6 lines
This shouldn't be a CONFIG. This should be a runtime option. It's ridiculous to have to recompile your kernel just to fix some problem with your printer.
e.g. sysctl, ioctl, sysfs entry, module parameter. Whatever is en vogue these days. Easiest would be probably a
module_param().This feature only gets involved when passing console=lp0 parameter to the bootloader. I never tried to load a new system console while system was running so I'm not sure if it behaves correctly. If it does, I will modify this patch following your advices.
Quoted 7 lines
Quoted 5 lines
Andi's suggestion seems fine to me: use a
module_param()forCONSOLE_LP_STRICTinstead of a hidden build-time (non-Kconfig) option. Are you interested in making this change?---
I can give it a try. I'm not sure if this can be done when system is loaded.
I think that if you make it a module_param() and use (root-) writeable permissions on it, it's just a variable that can be changed after the driver is loaded and running.
Andi, did you want just a boot-time option or a run-time (changeable) option?
---
~Randy
Randy.Dunlap ha scritto:
Quoted 5 lines
I think that if you make it a
module_param()and use (root-) writeable permissions on it, it's just a variable that can be changed after the driver is loaded and running.Andi, did you want just a boot-time option or a run-time (changeable) option?
Here is a patch (built against 2.6.17-rc1) which does use of __setup() call to dynamically adjust console_lp_strict value. Actually the only way to get console line printer working is to enable it at system startup so I adjusted Kconfig parameters accordingly. Feel free to submit any feedback.
drivers/char/lp.c renamed from drivers/char/lp.c.orig +13 -5
@@ -686,9 +686,17 @@ static struct file_operations lp_fops =#define CONSOLE_LP 0/* If the printer is out of paper, we can either lose the messages or -* stall until the printer is happy again. Define CONSOLE_LP_STRICT +* stall until the printer is happy again. Setting console_lp_strict * non-zero to get the latter behaviour. */ -#define CONSOLE_LP_STRICT 1 +static unsigned int console_lp_strict =1 ; + +static int __init console_lp_strict_setup (char *str) +{ + console_lp_strict =simple_strtol (str,NULL ,0 ); +return 1 ; +} + +__setup ("console_lp_strict=" , console_lp_strict_setup);/* The console must be locked when we get here. */
@@ -697,7 +705,7 @@ static void lp_console_write (struct con {struct pardevice *dev = lp_table[CONSOLE_LP ].dev;struct parport *port = dev->port; -ssize_t written; +ssize_t written =0 ;if (parport_claim (dev))/* Nothing we can do. */
@@ -737,9 +745,9 @@ static void lp_console_write (struct con written =parport_write (port, crlf, i);if (written >0 ) i -= written, crlf += written; - }while (i >0 && (CONSOLE_LP_STRICT || written >0 )); + }while (i >0 && (console_lp_strict || written >0 )); } - }while (count >0 && (CONSOLE_LP_STRICT || written >0 )); + }while (count >0 && (console_lp_strict || written >0 ));parport_release (dev); }
drivers/char/Kconfig renamed from drivers/char/Kconfig.orig +4 -4
@@ -506,7 +506,7 @@ config PRINTER config LP_CONSOLE bool "Support for console on line printer" - depends on PRINTER + depends on PRINTER = y ---help--- If you want kernel messages to be printed out as they occur, you can have a console on the printer. This option adds support for
@@ -515,9 +515,9 @@ config LP_CONSOLE If the printer is out of paper (or off, or unplugged, or too busy..) the kernel will stall until the printer is ready again. - By defining CONSOLE_LP_STRICT to 0 (at your own risk) you - can make the kernel continue when this happens, - but it'll lose the kernel messages. + By passing the option "console_lp_strict=0" to the kernel at + boot time (at your own risk) you can make the kernel continue + when this happens, but it will lose the kernel messages. If unsure, say N.
Regards,
Signature · 1 line
Luca