Commit e55a65e5 authored by Jan-Benedict Glaw's avatar Jan-Benedict Glaw Committed by Vojtech Pavlik

[PATCH] CodingStyle and docu update to srm_env

Please import this patch. It updates the Config.help entry (which some
people requested) and cleans up coding a bit. No functional changes.
parent 50e981f7
...@@ -576,13 +576,24 @@ CONFIG_MAGIC_SYSRQ ...@@ -576,13 +576,24 @@ CONFIG_MAGIC_SYSRQ
unless you really know what this hack does. unless you really know what this hack does.
CONFIG_SRM_ENV CONFIG_SRM_ENV
If you enable this option, a subdirectory called srm_environment If you enable this option, a subdirectory inside /proc called
will give you access to the most important SRM environment /proc/srm_environment will give you access to the all important
variables. If you've got an Alpha style system supporting SRM environment variables (those which have a name) and also
SRC, then it is a good idea to say Yes or Module to this driver. to all others (by their internal number).
SRM is something like a BIOS for Alpha machines. There are some
other such BIOSes, like AlphaBIOS, which this driver cannot
support (hey, that's not SRM!).
Despite the fact that this driver doesn't work on all Alphas (but
only on those which have SRM as their firmware), it's save to
build it even if your particular machine doesn't know about SRM
(or if you intend to compile a generic kernel). It will simply
not create those subdirectory in /proc (and give you some warning,
of course).
This driver is also available as a module and will be called This driver is also available as a module and will be called
srm_env.o if you build it as a module. srm_env.o then.
CONFIG_DEBUG_KERNEL CONFIG_DEBUG_KERNEL
Say Y here if you are developing drivers or trying to debug and Say Y here if you are developing drivers or trying to debug and
......
...@@ -33,6 +33,15 @@ ...@@ -33,6 +33,15 @@
* Changelog * Changelog
* ~~~~~~~~~ * ~~~~~~~~~
* *
* Thu, 22 Aug 2002 15:10:43 +0200
* - Update Config.help entry. I got a number of emails asking
* me to tell their senders if they could make use of this
* piece of code... So: "SRM is something like BIOS for your
* Alpha"
* - Update code formatting a bit to better conform CodingStyle
* rules.
* - So this is v0.0.5, with no changes (except formatting)
*
* Wed, 22 May 2002 00:11:21 +0200 * Wed, 22 May 2002 00:11:21 +0200
* - Fix typo on comment (SRC -> SRM) * - Fix typo on comment (SRC -> SRM)
* - Call this "Version 0.0.4" * - Call this "Version 0.0.4"
...@@ -59,7 +68,7 @@ ...@@ -59,7 +68,7 @@
#define BASE_DIR "srm_environment" /* Subdir in /proc/ */ #define BASE_DIR "srm_environment" /* Subdir in /proc/ */
#define NAMED_DIR "named_variables" /* Subdir for known variables */ #define NAMED_DIR "named_variables" /* Subdir for known variables */
#define NUMBERED_DIR "numbered_variables" /* Subdir for all variables */ #define NUMBERED_DIR "numbered_variables" /* Subdir for all variables */
#define VERSION "0.0.4" /* Module version */ #define VERSION "0.0.5" /* Module version */
#define NAME "srm_env" /* Module name */ #define NAME "srm_env" /* Module name */
MODULE_AUTHOR("Jan-Benedict Glaw <jbglaw@lug-owl.de>"); MODULE_AUTHOR("Jan-Benedict Glaw <jbglaw@lug-owl.de>");
...@@ -97,9 +106,12 @@ static srm_env_t srm_named_entries[] = { ...@@ -97,9 +106,12 @@ static srm_env_t srm_named_entries[] = {
}; };
static srm_env_t srm_numbered_entries[256]; static srm_env_t srm_numbered_entries[256];
static int static int
srm_env_read(char *page, char **start, off_t off, int count, int *eof, srm_env_read(char *page, char **start, off_t off, int count, int *eof,
void *data) { void *data)
{
int nbytes; int nbytes;
unsigned long ret; unsigned long ret;
srm_env_t *entry; srm_env_t *entry;
...@@ -111,11 +123,11 @@ srm_env_read(char *page, char **start, off_t off, int count, int *eof, ...@@ -111,11 +123,11 @@ srm_env_read(char *page, char **start, off_t off, int count, int *eof,
return -EFAULT; return -EFAULT;
} }
entry = (srm_env_t *)data; entry = (srm_env_t *) data;
ret = callback_getenv(entry->id, page, count); ret = callback_getenv(entry->id, page, count);
if((ret >> 61) == 0) if((ret >> 61) == 0)
nbytes = (int)ret; nbytes = (int) ret;
else else
nbytes = -EFAULT; nbytes = -EFAULT;
...@@ -124,9 +136,11 @@ srm_env_read(char *page, char **start, off_t off, int count, int *eof, ...@@ -124,9 +136,11 @@ srm_env_read(char *page, char **start, off_t off, int count, int *eof,
return nbytes; return nbytes;
} }
static int static int
srm_env_write(struct file *file, const char *buffer, unsigned long count, srm_env_write(struct file *file, const char *buffer, unsigned long count,
void *data) { void *data)
{
#define BUFLEN 512 #define BUFLEN 512
int nbytes; int nbytes;
srm_env_t *entry; srm_env_t *entry;
...@@ -156,7 +170,7 @@ srm_env_write(struct file *file, const char *buffer, unsigned long count, ...@@ -156,7 +170,7 @@ srm_env_write(struct file *file, const char *buffer, unsigned long count,
do do
ret2 = callback_save_env(); ret2 = callback_save_env();
while((ret2 >> 61) == 1); while((ret2 >> 61) == 1);
nbytes = (int)ret1; nbytes = (int) ret1;
} else } else
nbytes = -EFAULT; nbytes = -EFAULT;
...@@ -165,8 +179,10 @@ srm_env_write(struct file *file, const char *buffer, unsigned long count, ...@@ -165,8 +179,10 @@ srm_env_write(struct file *file, const char *buffer, unsigned long count,
return nbytes; return nbytes;
} }
static void static void
srm_env_cleanup(void) { srm_env_cleanup(void)
{
srm_env_t *entry; srm_env_t *entry;
unsigned long var_num; unsigned long var_num;
...@@ -210,8 +226,10 @@ srm_env_cleanup(void) { ...@@ -210,8 +226,10 @@ srm_env_cleanup(void) {
return; return;
} }
static int __init static int __init
srm_env_init(void) { srm_env_init(void)
{
srm_env_t *entry; srm_env_t *entry;
unsigned long var_num; unsigned long var_num;
...@@ -220,7 +238,9 @@ srm_env_init(void) { ...@@ -220,7 +238,9 @@ srm_env_init(void) {
*/ */
if(!alpha_using_srm) { if(!alpha_using_srm) {
printk(KERN_INFO "%s: This Alpha system doesn't " printk(KERN_INFO "%s: This Alpha system doesn't "
"know about SRM...\n", __FUNCTION__); "know about SRM (or you've booted "
"SRM->MILO->Linux, which gets "
"misdetected)...\n", __FUNCTION__);
return -ENODEV; return -ENODEV;
} }
...@@ -274,7 +294,7 @@ srm_env_init(void) { ...@@ -274,7 +294,7 @@ srm_env_init(void) {
if(entry->proc_entry == NULL) if(entry->proc_entry == NULL)
goto cleanup; goto cleanup;
entry->proc_entry->data = (void *)entry; entry->proc_entry->data = (void *) entry;
entry->proc_entry->owner = THIS_MODULE; entry->proc_entry->owner = THIS_MODULE;
entry->proc_entry->read_proc = srm_env_read; entry->proc_entry->read_proc = srm_env_read;
entry->proc_entry->write_proc = srm_env_write; entry->proc_entry->write_proc = srm_env_write;
...@@ -295,7 +315,7 @@ srm_env_init(void) { ...@@ -295,7 +315,7 @@ srm_env_init(void) {
goto cleanup; goto cleanup;
entry->id = var_num; entry->id = var_num;
entry->proc_entry->data = (void *)entry; entry->proc_entry->data = (void *) entry;
entry->proc_entry->owner = THIS_MODULE; entry->proc_entry->owner = THIS_MODULE;
entry->proc_entry->read_proc = srm_env_read; entry->proc_entry->read_proc = srm_env_read;
entry->proc_entry->write_proc = srm_env_write; entry->proc_entry->write_proc = srm_env_write;
...@@ -303,20 +323,26 @@ srm_env_init(void) { ...@@ -303,20 +323,26 @@ srm_env_init(void) {
printk(KERN_INFO "%s: version %s loaded successfully\n", NAME, printk(KERN_INFO "%s: version %s loaded successfully\n", NAME,
VERSION); VERSION);
return 0; return 0;
cleanup: cleanup:
srm_env_cleanup(); srm_env_cleanup();
return -ENOMEM; return -ENOMEM;
} }
static void __exit static void __exit
srm_env_exit(void) { srm_env_exit(void)
{
srm_env_cleanup(); srm_env_cleanup();
printk(KERN_INFO "%s: unloaded successfully\n", NAME); printk(KERN_INFO "%s: unloaded successfully\n", NAME);
return; return;
} }
module_init(srm_env_init); module_init(srm_env_init);
module_exit(srm_env_exit); module_exit(srm_env_exit);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment