summaryrefslogtreecommitdiff
path: root/drivers/nubus/proc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 17:51:54 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 17:51:54 -0700
commit20b4fb485227404329e41ad15588afad3df23050 (patch)
treef3e099f0ab3da8a93b447203e294d2bb22f6dc05 /drivers/nubus/proc.c
parentb9394d8a657cd3c064fa432aa0905c1b58b38fe9 (diff)
parentac3e3c5b1164397656df81b9e9ab4991184d3236 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/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 ...
Diffstat (limited to 'drivers/nubus/proc.c')
-rw-r--r--drivers/nubus/proc.c80
1 files changed, 76 insertions, 4 deletions
diff --git a/drivers/nubus/proc.c b/drivers/nubus/proc.c
index 208dd12825bc..b8286ed65919 100644
--- a/drivers/nubus/proc.c
+++ b/drivers/nubus/proc.c
@@ -52,7 +52,6 @@ static int nubus_devices_proc_open(struct inode *inode, struct file *file)
}
static const struct file_operations nubus_devices_proc_fops = {
- .owner = THIS_MODULE,
.open = nubus_devices_proc_open,
.read = seq_read,
.llseek = seq_lseek,
@@ -61,6 +60,10 @@ static const struct file_operations nubus_devices_proc_fops = {
static struct proc_dir_entry *proc_bus_nubus_dir;
+static const struct file_operations nubus_proc_subdir_fops = {
+#warning Need to set some I/O handlers here
+};
+
static void nubus_proc_subdir(struct nubus_dev* dev,
struct proc_dir_entry* parent,
struct nubus_dir* dir)
@@ -73,9 +76,10 @@ static void nubus_proc_subdir(struct nubus_dev* dev,
struct proc_dir_entry* e;
sprintf(name, "%x", ent.type);
- e = create_proc_entry(name, S_IFREG | S_IRUGO |
- S_IWUSR, parent);
- if (!e) return;
+ e = proc_create(name, S_IFREG | S_IRUGO | S_IWUSR, parent,
+ &nubus_proc_subdir_fops);
+ if (!e)
+ return;
}
}
@@ -158,6 +162,73 @@ int nubus_proc_detach_device(struct nubus_dev *dev)
}
EXPORT_SYMBOL(nubus_proc_detach_device);
+/*
+ * /proc/nubus stuff
+ */
+static int nubus_proc_show(struct seq_file *m, void *v)
+{
+ const struct nubus_board *board = v;
+
+ /* Display header on line 1 */
+ if (v == SEQ_START_TOKEN)
+ seq_puts(m, "Nubus devices found:\n");
+ else
+ seq_printf(m, "Slot %X: %s\n", board->slot, board->name);
+ return 0;
+}
+
+static void *nubus_proc_start(struct seq_file *m, loff_t *_pos)
+{
+ struct nubus_board *board;
+ unsigned pos;
+
+ if (*_pos > LONG_MAX)
+ return NULL;
+ pos = *_pos;
+ if (pos == 0)
+ return SEQ_START_TOKEN;
+ for (board = nubus_boards; board; board = board->next)
+ if (--pos == 0)
+ break;
+ return board;
+}
+
+static void *nubus_proc_next(struct seq_file *p, void *v, loff_t *_pos)
+{
+ /* Walk the list of NuBus boards */
+ struct nubus_board *board = v;
+
+ ++*_pos;
+ if (v == SEQ_START_TOKEN)
+ board = nubus_boards;
+ else if (board)
+ board = board->next;
+ return board;
+}
+
+static void nubus_proc_stop(struct seq_file *p, void *v)
+{
+}
+
+static const struct seq_operations nubus_proc_seqops = {
+ .start = nubus_proc_start,
+ .next = nubus_proc_next,
+ .stop = nubus_proc_stop,
+ .show = nubus_proc_show,
+};
+
+static int nubus_proc_open(struct inode *inode, struct file *file)
+{
+ return seq_open(file, &nubus_proc_seqops);
+}
+
+static const struct file_operations nubus_proc_fops = {
+ .open = nubus_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release,
+};
+
void __init proc_bus_nubus_add_devices(void)
{
struct nubus_dev *dev;
@@ -168,6 +239,7 @@ void __init proc_bus_nubus_add_devices(void)
void __init nubus_proc_init(void)
{
+ proc_create("nubus", 0, NULL, &nubus_proc_fops);
if (!MACH_IS_MAC)
return;
proc_bus_nubus_dir = proc_mkdir("bus/nubus", NULL);