Commit 1c1ec6c6 authored by Al Viro's avatar Al Viro

srm_env: don't bother with pointer to srm_env_t

Since the only thing in it the methods actually care about is
variable id, just store that directly.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent c35f2e49
......@@ -56,7 +56,6 @@ typedef struct _srm_env {
static struct proc_dir_entry *base_dir;
static struct proc_dir_entry *named_dir;
static struct proc_dir_entry *numbered_dir;
static char number[256][4];
static srm_env_t srm_named_entries[] = {
{ "auto_action", ENV_AUTO_ACTION },
......@@ -76,21 +75,18 @@ static srm_env_t srm_named_entries[] = {
{ "tty_dev", ENV_TTY_DEV },
{ NULL, 0 },
};
static srm_env_t srm_numbered_entries[256];
static int srm_env_proc_show(struct seq_file *m, void *v)
{
unsigned long ret;
srm_env_t *entry;
unsigned long id = (unsigned long)m->private;
char *page;
entry = m->private;
page = (char *)__get_free_page(GFP_USER);
if (!page)
return -ENOMEM;
ret = callback_getenv(entry->id, page, PAGE_SIZE);
ret = callback_getenv(id, page, PAGE_SIZE);
if ((ret >> 61) == 0) {
seq_write(m, page, ret);
......@@ -110,7 +106,7 @@ static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *pos)
{
int res;
srm_env_t *entry = PDE_DATA(file_inode(file));
unsigned long id = (unsigned long)PDE_DATA(file_inode(file));
char *buf = (char *) __get_free_page(GFP_USER);
unsigned long ret1, ret2;
......@@ -126,7 +122,7 @@ static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer,
goto out;
buf[count] = '\0';
ret1 = callback_setenv(entry->id, buf, count);
ret1 = callback_setenv(id, buf, count);
if ((ret1 >> 61) == 0) {
do
ret2 = callback_save_env();
......@@ -165,12 +161,6 @@ srm_env_init(void)
return -ENODEV;
}
/*
* Init numbers
*/
for (var_num = 0; var_num <= 255; var_num++)
sprintf(number[var_num], "%ld", var_num);
/*
* Create base directory
*/
......@@ -208,7 +198,7 @@ srm_env_init(void)
entry = srm_named_entries;
while (entry->name && entry->id) {
if (!proc_create_data(entry->name, 0644, named_dir,
&srm_env_proc_fops, entry))
&srm_env_proc_fops, (void *)entry->id))
goto cleanup;
entry++;
}
......@@ -217,14 +207,11 @@ srm_env_init(void)
* Create all numbered nodes
*/
for (var_num = 0; var_num <= 255; var_num++) {
entry = &srm_numbered_entries[var_num];
entry->name = number[var_num];
if (!proc_create_data(entry->name, 0644, numbered_dir,
&srm_env_proc_fops, entry))
char name[4];
sprintf(name, "%ld", var_num);
if (!proc_create_data(name, 0644, numbered_dir,
&srm_env_proc_fops, (void *)var_num))
goto cleanup;
entry->id = var_num;
}
printk(KERN_INFO "%s: version %s loaded successfully\n", NAME,
......@@ -242,8 +229,6 @@ srm_env_exit(void)
{
remove_proc_subtree(BASE_DIR, NULL);
printk(KERN_INFO "%s: unloaded successfully\n", NAME);
return;
}
module_init(srm_env_init);
......
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