Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/viro/vfs

Pull VFS updates from Al Viro,

Misc cleanups all over the place, mainly wrt /proc interfaces (switch
create_proc_entry to proc_create(), get rid of the deprecated
create_proc_read_entry() in favor of using proc_create_data() and
seq_file etc).

7kloc removed.

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (204 commits)
  don't bother with deferred freeing of fdtables
  proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h
  proc: Make the PROC_I() and PDE() macros internal to procfs
  proc: Supply a function to remove a proc entry by PDE
  take cgroup_open() and cpuset_open() to fs/proc/base.c
  ppc: Clean up scanlog
  ppc: Clean up rtas_flash driver somewhat
  hostap: proc: Use remove_proc_subtree()
  drm: proc: Use remove_proc_subtree()
  drm: proc: Use minor->index to label things, not PDE->name
  drm: Constify drm_proc_list[]
  zoran: Don't print proc_dir_entry data in debug
  reiserfs: Don't access the proc_dir_entry in r_open(), r_start() r_show()
  proc: Supply an accessor for getting the data from a PDE's parent
  airo: Use remove_proc_subtree()
  rtl8192u: Don't need to save device proc dir PDE
  rtl8187se: Use a dir under /proc/net/r8180/
  proc: Add proc_mkdir_data()
  proc: Move some bits from linux/proc_fs.h to linux/{of.h,signal.h,tty.h}
  proc: Move PDE_NET() to fs/proc/proc_net.c
  ...
  • Loading branch information
torvalds committed May 2, 2013
2 parents b9394d8 + ac3e3c5 commit 20b4fb4
Show file tree
Hide file tree
Showing 385 changed files with 7,396 additions and 14,540 deletions.
93 changes: 14 additions & 79 deletions arch/alpha/kernel/srm_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ MODULE_LICENSE("GPL");
typedef struct _srm_env {
char *name;
unsigned long id;
struct proc_dir_entry *proc_entry;
} srm_env_t;

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 },
Expand All @@ -77,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);
Expand All @@ -104,14 +99,14 @@ static int srm_env_proc_show(struct seq_file *m, void *v)

static int srm_env_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, srm_env_proc_show, PDE(inode)->data);
return single_open(file, srm_env_proc_show, PDE_DATA(inode));
}

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(file_inode(file))->data;
unsigned long id = (unsigned long)PDE_DATA(file_inode(file));
char *buf = (char *) __get_free_page(GFP_USER);
unsigned long ret1, ret2;

Expand All @@ -127,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();
Expand All @@ -149,52 +144,6 @@ static const struct file_operations srm_env_proc_fops = {
.write = srm_env_proc_write,
};

static void
srm_env_cleanup(void)
{
srm_env_t *entry;
unsigned long var_num;

if (base_dir) {
/*
* Remove named entries
*/
if (named_dir) {
entry = srm_named_entries;
while (entry->name != NULL && entry->id != 0) {
if (entry->proc_entry) {
remove_proc_entry(entry->name,
named_dir);
entry->proc_entry = NULL;
}
entry++;
}
remove_proc_entry(NAMED_DIR, base_dir);
}

/*
* Remove numbered entries
*/
if (numbered_dir) {
for (var_num = 0; var_num <= 255; var_num++) {
entry = &srm_numbered_entries[var_num];

if (entry->proc_entry) {
remove_proc_entry(entry->name,
numbered_dir);
entry->proc_entry = NULL;
entry->name = NULL;
}
}
remove_proc_entry(NUMBERED_DIR, base_dir);
}

remove_proc_entry(BASE_DIR, NULL);
}

return;
}

static int __init
srm_env_init(void)
{
Expand All @@ -212,20 +161,14 @@ 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
*/
base_dir = proc_mkdir(BASE_DIR, NULL);
if (!base_dir) {
printk(KERN_ERR "Couldn't create base dir /proc/%s\n",
BASE_DIR);
goto cleanup;
return -ENOMEM;
}

/*
Expand Down Expand Up @@ -254,9 +197,8 @@ srm_env_init(void)
*/
entry = srm_named_entries;
while (entry->name && entry->id) {
entry->proc_entry = proc_create_data(entry->name, 0644, named_dir,
&srm_env_proc_fops, entry);
if (!entry->proc_entry)
if (!proc_create_data(entry->name, 0644, named_dir,
&srm_env_proc_fops, (void *)entry->id))
goto cleanup;
entry++;
}
Expand All @@ -265,15 +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];

entry->proc_entry = proc_create_data(entry->name, 0644, numbered_dir,
&srm_env_proc_fops, entry);
if (!entry->proc_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,
Expand All @@ -282,18 +220,15 @@ srm_env_init(void)
return 0;

cleanup:
srm_env_cleanup();

remove_proc_subtree(BASE_DIR, NULL);
return -ENOMEM;
}

static void __exit
srm_env_exit(void)
{
srm_env_cleanup();
remove_proc_subtree(BASE_DIR, NULL);
printk(KERN_INFO "%s: unloaded successfully\n", NAME);

return;
}

module_init(srm_env_init);
Expand Down
28 changes: 10 additions & 18 deletions arch/arm/kernel/atags_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,18 @@ struct buffer {
char data[];
};

static int
read_buffer(char* page, char** start, off_t off, int count,
int* eof, void* data)
static ssize_t atags_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
struct buffer *buffer = (struct buffer *)data;

if (off >= buffer->size) {
*eof = 1;
return 0;
}

count = min((int) (buffer->size - off), count);

memcpy(page, &buffer->data[off], count);

return count;
struct buffer *b = PDE_DATA(file_inode(file));
return simple_read_from_buffer(buf, count, ppos, b->data, b->size);
}

static const struct file_operations atags_fops = {
.read = atags_read,
.llseek = default_llseek,
};

#define BOOT_PARAMS_SIZE 1536
static char __initdata atags_copy[BOOT_PARAMS_SIZE];

Expand Down Expand Up @@ -66,9 +60,7 @@ static int __init init_atags_procfs(void)
b->size = size;
memcpy(b->data, atags_copy, size);

tags_entry = create_proc_read_entry("atags", 0400,
NULL, read_buffer, b);

tags_entry = proc_create_data("atags", 0400, NULL, &atags_fops, b);
if (!tags_entry)
goto nomem;

Expand Down
43 changes: 19 additions & 24 deletions arch/arm/kernel/swp_emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/sched.h>
#include <linux/syscalls.h>
#include <linux/perf_event.h>
Expand Down Expand Up @@ -79,27 +80,27 @@ static unsigned long abtcounter;
static pid_t previous_pid;

#ifdef CONFIG_PROC_FS
static int proc_read_status(char *page, char **start, off_t off, int count,
int *eof, void *data)
static int proc_status_show(struct seq_file *m, void *v)
{
char *p = page;
int len;

p += sprintf(p, "Emulated SWP:\t\t%lu\n", swpcounter);
p += sprintf(p, "Emulated SWPB:\t\t%lu\n", swpbcounter);
p += sprintf(p, "Aborted SWP{B}:\t\t%lu\n", abtcounter);
seq_printf(m, "Emulated SWP:\t\t%lu\n", swpcounter);
seq_printf(m, "Emulated SWPB:\t\t%lu\n", swpbcounter);
seq_printf(m, "Aborted SWP{B}:\t\t%lu\n", abtcounter);
if (previous_pid != 0)
p += sprintf(p, "Last process:\t\t%d\n", previous_pid);

len = (p - page) - off;
if (len < 0)
len = 0;

*eof = (len <= count) ? 1 : 0;
*start = page + off;
seq_printf(m, "Last process:\t\t%d\n", previous_pid);
return 0;
}

return len;
static int proc_status_open(struct inode *inode, struct file *file)
{
return single_open(file, proc_status_show, PDE_DATA(inode));
}

static const struct file_operations proc_status_fops = {
.open = proc_status_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
#endif

/*
Expand Down Expand Up @@ -266,14 +267,8 @@ static struct undef_hook swp_hook = {
static int __init swp_emulation_init(void)
{
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *res;

res = create_proc_entry("cpu/swp_emulation", S_IRUGO, NULL);

if (!res)
if (!proc_create("cpu/swp_emulation", S_IRUGO, NULL, &proc_status_fops))
return -ENOMEM;

res->read_proc = proc_read_status;
#endif /* CONFIG_PROC_FS */

printk(KERN_NOTICE "Registering SWP/SWPB emulation handler\n");
Expand Down
20 changes: 4 additions & 16 deletions arch/arm/mach-msm/last_radio_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,8 @@ extern void *smem_item(unsigned id, unsigned *size);
static ssize_t last_radio_log_read(struct file *file, char __user *buf,
size_t len, loff_t *offset)
{
loff_t pos = *offset;
ssize_t count;

if (pos >= radio_log_size)
return 0;

count = min(len, (size_t)(radio_log_size - pos));
if (copy_to_user(buf, radio_log_base + pos, count)) {
pr_err("%s: copy to user failed\n", __func__);
return -EFAULT;
}

*offset += count;
return count;
return simple_read_from_buffer(buf, len, offset,
radio_log_base, radio_log_size);
}

static struct file_operations last_radio_log_fops = {
Expand All @@ -67,7 +55,8 @@ void msm_init_last_radio_log(struct module *owner)
return;
}

entry = create_proc_entry("last_radio_log", S_IFREG | S_IRUGO, NULL);
entry = proc_create("last_radio_log", S_IRUGO, NULL,
&last_radio_log_fops);
if (!entry) {
pr_err("%s: could not create proc entry for radio log\n",
__func__);
Expand All @@ -77,7 +66,6 @@ void msm_init_last_radio_log(struct module *owner)
pr_err("%s: last radio log is %d bytes long\n", __func__,
radio_log_size);
last_radio_log_fops.owner = owner;
entry->proc_fops = &last_radio_log_fops;
entry->size = radio_log_size;
}
EXPORT_SYMBOL(msm_init_last_radio_log);
Loading

0 comments on commit 20b4fb4

Please sign in to comment.