summaryrefslogtreecommitdiffstats
path: root/drivers/nubus
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-04-10 15:05:38 +0100
committerAl Viro <viro@zeniv.linux.org.uk>2013-04-29 15:41:54 -0400
commit11db656ad462c9aa7aff7e3817214578cfc307b3 (patch)
tree02b536ede231d4f1f5c51030ff6a2691c1759921 /drivers/nubus
parent77cd02c151cb6b7d81aad4802ee8b98a033863d6 (diff)
downloadlinux-11db656ad462c9aa7aff7e3817214578cfc307b3.tar.bz2
nubus: Don't use create_proc_read_entry()
Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells <dhowells@redhat.com> cc: linux-m68k@lists.linux-m68k.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/nubus')
-rw-r--r--drivers/nubus/nubus.c55
-rw-r--r--drivers/nubus/proc.c81
2 files changed, 76 insertions, 60 deletions
diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index 44d01afafe9c..43926cd25ae8 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -19,7 +19,6 @@
#include <asm/setup.h>
#include <asm/page.h>
#include <asm/hwtest.h>
-#include <linux/proc_fs.h>
#include <asm/mac_via.h>
#include <asm/mac_oss.h>
@@ -954,56 +953,6 @@ void __init nubus_probe_slot(int slot)
}
}
-#if defined(CONFIG_PROC_FS)
-
-/* /proc/nubus stuff */
-
-static int sprint_nubus_board(struct nubus_board* board, char* ptr, int len)
-{
- if(len < 100)
- return -1;
-
- sprintf(ptr, "Slot %X: %s\n",
- board->slot, board->name);
-
- return strlen(ptr);
-}
-
-static int nubus_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int nprinted, len, begin = 0;
- int size = PAGE_SIZE;
- struct nubus_board* board;
-
- len = sprintf(page, "Nubus devices found:\n");
- /* Walk the list of NuBus boards */
- for (board = nubus_boards; board != NULL; board = board->next)
- {
- nprinted = sprint_nubus_board(board, page + len, size - len);
- if (nprinted < 0)
- break;
- len += nprinted;
- if (len+begin < off) {
- begin += len;
- len = 0;
- }
- if (len+begin >= off+count)
- break;
- }
- if (len+begin < off)
- *eof = 1;
- off -= begin;
- *start = page + off;
- len -= off;
- if (len>count)
- len = count;
- if (len<0)
- len = 0;
- return len;
-}
-#endif
-
void __init nubus_scan_bus(void)
{
int slot;
@@ -1041,11 +990,7 @@ static int __init nubus_init(void)
nubus_devices = NULL;
nubus_boards = NULL;
nubus_scan_bus();
-
-#ifdef CONFIG_PROC_FS
- create_proc_read_entry("nubus", 0, NULL, nubus_read_proc, NULL);
nubus_proc_init();
-#endif
return 0;
}
diff --git a/drivers/nubus/proc.c b/drivers/nubus/proc.c
index bb1446bb2802..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,10 +76,10 @@ static void nubus_proc_subdir(struct nubus_dev* dev,
struct proc_dir_entry* e;
sprintf(name, "%x", ent.type);
-#warning Need to set some I/O handlers here
- e = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
- parent, NULL, NULL);
- if (!e) return;
+ e = proc_create(name, S_IFREG | S_IRUGO | S_IWUSR, parent,
+ &nubus_proc_subdir_fops);
+ if (!e)
+ return;
}
}
@@ -159,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;
@@ -169,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);