aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nubus
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-04-10 10:05:38 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-04-29 15:41:54 -0400
commit11db656ad462c9aa7aff7e3817214578cfc307b3 (patch)
tree02b536ede231d4f1f5c51030ff6a2691c1759921 /drivers/nubus
parent77cd02c151cb6b7d81aad4802ee8b98a033863d6 (diff)
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 @@
19#include <asm/setup.h> 19#include <asm/setup.h>
20#include <asm/page.h> 20#include <asm/page.h>
21#include <asm/hwtest.h> 21#include <asm/hwtest.h>
22#include <linux/proc_fs.h>
23#include <asm/mac_via.h> 22#include <asm/mac_via.h>
24#include <asm/mac_oss.h> 23#include <asm/mac_oss.h>
25 24
@@ -954,56 +953,6 @@ void __init nubus_probe_slot(int slot)
954 } 953 }
955} 954}
956 955
957#if defined(CONFIG_PROC_FS)
958
959/* /proc/nubus stuff */
960
961static int sprint_nubus_board(struct nubus_board* board, char* ptr, int len)
962{
963 if(len < 100)
964 return -1;
965
966 sprintf(ptr, "Slot %X: %s\n",
967 board->slot, board->name);
968
969 return strlen(ptr);
970}
971
972static int nubus_read_proc(char *page, char **start, off_t off,
973 int count, int *eof, void *data)
974{
975 int nprinted, len, begin = 0;
976 int size = PAGE_SIZE;
977 struct nubus_board* board;
978
979 len = sprintf(page, "Nubus devices found:\n");
980 /* Walk the list of NuBus boards */
981 for (board = nubus_boards; board != NULL; board = board->next)
982 {
983 nprinted = sprint_nubus_board(board, page + len, size - len);
984 if (nprinted < 0)
985 break;
986 len += nprinted;
987 if (len+begin < off) {
988 begin += len;
989 len = 0;
990 }
991 if (len+begin >= off+count)
992 break;
993 }
994 if (len+begin < off)
995 *eof = 1;
996 off -= begin;
997 *start = page + off;
998 len -= off;
999 if (len>count)
1000 len = count;
1001 if (len<0)
1002 len = 0;
1003 return len;
1004}
1005#endif
1006
1007void __init nubus_scan_bus(void) 956void __init nubus_scan_bus(void)
1008{ 957{
1009 int slot; 958 int slot;
@@ -1041,11 +990,7 @@ static int __init nubus_init(void)
1041 nubus_devices = NULL; 990 nubus_devices = NULL;
1042 nubus_boards = NULL; 991 nubus_boards = NULL;
1043 nubus_scan_bus(); 992 nubus_scan_bus();
1044
1045#ifdef CONFIG_PROC_FS
1046 create_proc_read_entry("nubus", 0, NULL, nubus_read_proc, NULL);
1047 nubus_proc_init(); 993 nubus_proc_init();
1048#endif
1049 return 0; 994 return 0;
1050} 995}
1051 996
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)
52} 52}
53 53
54static const struct file_operations nubus_devices_proc_fops = { 54static const struct file_operations nubus_devices_proc_fops = {
55 .owner = THIS_MODULE,
56 .open = nubus_devices_proc_open, 55 .open = nubus_devices_proc_open,
57 .read = seq_read, 56 .read = seq_read,
58 .llseek = seq_lseek, 57 .llseek = seq_lseek,
@@ -61,6 +60,10 @@ static const struct file_operations nubus_devices_proc_fops = {
61 60
62static struct proc_dir_entry *proc_bus_nubus_dir; 61static struct proc_dir_entry *proc_bus_nubus_dir;
63 62
63static const struct file_operations nubus_proc_subdir_fops = {
64#warning Need to set some I/O handlers here
65};
66
64static void nubus_proc_subdir(struct nubus_dev* dev, 67static void nubus_proc_subdir(struct nubus_dev* dev,
65 struct proc_dir_entry* parent, 68 struct proc_dir_entry* parent,
66 struct nubus_dir* dir) 69 struct nubus_dir* dir)
@@ -73,10 +76,10 @@ static void nubus_proc_subdir(struct nubus_dev* dev,
73 struct proc_dir_entry* e; 76 struct proc_dir_entry* e;
74 77
75 sprintf(name, "%x", ent.type); 78 sprintf(name, "%x", ent.type);
76#warning Need to set some I/O handlers here 79 e = proc_create(name, S_IFREG | S_IRUGO | S_IWUSR, parent,
77 e = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, 80 &nubus_proc_subdir_fops);
78 parent, NULL, NULL); 81 if (!e)
79 if (!e) return; 82 return;
80 } 83 }
81} 84}
82 85
@@ -159,6 +162,73 @@ int nubus_proc_detach_device(struct nubus_dev *dev)
159} 162}
160EXPORT_SYMBOL(nubus_proc_detach_device); 163EXPORT_SYMBOL(nubus_proc_detach_device);
161 164
165/*
166 * /proc/nubus stuff
167 */
168static int nubus_proc_show(struct seq_file *m, void *v)
169{
170 const struct nubus_board *board = v;
171
172 /* Display header on line 1 */
173 if (v == SEQ_START_TOKEN)
174 seq_puts(m, "Nubus devices found:\n");
175 else
176 seq_printf(m, "Slot %X: %s\n", board->slot, board->name);
177 return 0;
178}
179
180static void *nubus_proc_start(struct seq_file *m, loff_t *_pos)
181{
182 struct nubus_board *board;
183 unsigned pos;
184
185 if (*_pos > LONG_MAX)
186 return NULL;
187 pos = *_pos;
188 if (pos == 0)
189 return SEQ_START_TOKEN;
190 for (board = nubus_boards; board; board = board->next)
191 if (--pos == 0)
192 break;
193 return board;
194}
195
196static void *nubus_proc_next(struct seq_file *p, void *v, loff_t *_pos)
197{
198 /* Walk the list of NuBus boards */
199 struct nubus_board *board = v;
200
201 ++*_pos;
202 if (v == SEQ_START_TOKEN)
203 board = nubus_boards;
204 else if (board)
205 board = board->next;
206 return board;
207}
208
209static void nubus_proc_stop(struct seq_file *p, void *v)
210{
211}
212
213static const struct seq_operations nubus_proc_seqops = {
214 .start = nubus_proc_start,
215 .next = nubus_proc_next,
216 .stop = nubus_proc_stop,
217 .show = nubus_proc_show,
218};
219
220static int nubus_proc_open(struct inode *inode, struct file *file)
221{
222 return seq_open(file, &nubus_proc_seqops);
223}
224
225static const struct file_operations nubus_proc_fops = {
226 .open = nubus_proc_open,
227 .read = seq_read,
228 .llseek = seq_lseek,
229 .release = seq_release,
230};
231
162void __init proc_bus_nubus_add_devices(void) 232void __init proc_bus_nubus_add_devices(void)
163{ 233{
164 struct nubus_dev *dev; 234 struct nubus_dev *dev;
@@ -169,6 +239,7 @@ void __init proc_bus_nubus_add_devices(void)
169 239
170void __init nubus_proc_init(void) 240void __init nubus_proc_init(void)
171{ 241{
242 proc_create("nubus", 0, NULL, &nubus_proc_fops);
172 if (!MACH_IS_MAC) 243 if (!MACH_IS_MAC)
173 return; 244 return;
174 proc_bus_nubus_dir = proc_mkdir("bus/nubus", NULL); 245 proc_bus_nubus_dir = proc_mkdir("bus/nubus", NULL);