2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-16 17:23:55 +08:00

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: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2013-03-31 21:45:09 -04:00
parent c35f2e49f8
commit 1c1ec6c625

View File

@ -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);