staging: i2o: Remove use of seq_printf return value
[deliverable/linux.git] / drivers / staging / i2o / i2o_proc.c
CommitLineData
1da177e4
LT
1/*
2 * procfs handler for Linux I2O subsystem
3 *
4 * (c) Copyright 1999 Deepak Saxena
5 *
6 * Originally written by Deepak Saxena(deepak@plexity.net)
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * This is an initial test release. The code is based on the design of the
14 * ide procfs system (drivers/block/ide-proc.c). Some code taken from
15 * i2o-core module by Alan Cox.
16 *
17 * DISCLAIMER: This code is still under development/test and may cause
18 * your system to behave unpredictably. Use at your own discretion.
19 *
20 *
21 * Fixes/additions:
96de0e25
JE
22 * Juha Sievänen (Juha.Sievanen@cs.Helsinki.FI),
23 * Auvo Häkkinen (Auvo.Hakkinen@cs.Helsinki.FI)
1da177e4
LT
24 * University of Helsinki, Department of Computer Science
25 * LAN entries
26 * Markus Lidel <Markus.Lidel@shadowconnect.com>
27 * Changes for new I2O API
28 */
29
30#define OSM_NAME "proc-osm"
2e1973a3 31#define OSM_VERSION "1.316"
1da177e4
LT
32#define OSM_DESCRIPTION "I2O ProcFS OSM"
33
34#define I2O_MAX_MODULES 4
35// FIXME!
36#define FMT_U64_HEX "0x%08x%08x"
37#define U64_VAL(pu64) *((u32*)(pu64)+1), *((u32*)(pu64))
38
39#include <linux/types.h>
40#include <linux/kernel.h>
41#include <linux/pci.h>
2cbf7fe2 42#include "i2o.h"
5a0e3ad6 43#include <linux/slab.h>
1da177e4
LT
44#include <linux/proc_fs.h>
45#include <linux/seq_file.h>
46#include <linux/init.h>
47#include <linux/module.h>
48#include <linux/errno.h>
49#include <linux/spinlock.h>
50#include <linux/workqueue.h>
30463dcf 51#include <linux/uaccess.h>
1da177e4
LT
52
53#include <asm/io.h>
1da177e4
LT
54#include <asm/byteorder.h>
55
56/* Structure used to define /proc entries */
57typedef struct _i2o_proc_entry_t {
58 char *name; /* entry name */
d161a13f 59 umode_t mode; /* mode */
99ac48f5 60 const struct file_operations *fops; /* open function */
1da177e4
LT
61} i2o_proc_entry;
62
63/* global I2O /proc/i2o entry */
64static struct proc_dir_entry *i2o_proc_dir_root;
65
66/* proc OSM driver struct */
67static struct i2o_driver i2o_proc_driver = {
68 .name = OSM_NAME,
69};
70
71static int print_serial_number(struct seq_file *seq, u8 * serialno, int max_len)
72{
73 int i;
74
75 /* 19990419 -sralston
76 * The I2O v1.5 (and v2.0 so far) "official specification"
77 * got serial numbers WRONG!
78 * Apparently, and despite what Section 3.4.4 says and
79 * Figure 3-35 shows (pg 3-39 in the pdf doc),
80 * the convention / consensus seems to be:
81 * + First byte is SNFormat
82 * + Second byte is SNLen (but only if SNFormat==7 (?))
83 * + (v2.0) SCSI+BS may use IEEE Registered (64 or 128 bit) format
84 */
85 switch (serialno[0]) {
86 case I2O_SNFORMAT_BINARY: /* Binary */
87 seq_printf(seq, "0x");
cbd8e086 88 for (i = 0; i < serialno[1]; i++)
1da177e4 89 seq_printf(seq, "%02X", serialno[2 + i]);
1da177e4
LT
90 break;
91
92 case I2O_SNFORMAT_ASCII: /* ASCII */
93 if (serialno[1] < ' ') { /* printable or SNLen? */
94 /* sanity */
95 max_len =
96 (max_len < serialno[1]) ? max_len : serialno[1];
97 serialno[1 + max_len] = '\0';
98
99 /* just print it */
100 seq_printf(seq, "%s", &serialno[2]);
101 } else {
102 /* print chars for specified length */
cbd8e086 103 for (i = 0; i < serialno[1]; i++)
1da177e4 104 seq_printf(seq, "%c", serialno[2 + i]);
1da177e4
LT
105 }
106 break;
107
108 case I2O_SNFORMAT_UNICODE: /* UNICODE */
109 seq_printf(seq, "UNICODE Format. Can't Display\n");
110 break;
111
112 case I2O_SNFORMAT_LAN48_MAC: /* LAN-48 MAC Address */
cf30273b 113 seq_printf(seq, "LAN-48 MAC address @ %pM", &serialno[2]);
1da177e4
LT
114 break;
115
116 case I2O_SNFORMAT_WAN: /* WAN MAC Address */
117 /* FIXME: Figure out what a WAN access address looks like?? */
118 seq_printf(seq, "WAN Access Address");
119 break;
120
121/* plus new in v2.0 */
122 case I2O_SNFORMAT_LAN64_MAC: /* LAN-64 MAC Address */
123 /* FIXME: Figure out what a LAN-64 address really looks like?? */
124 seq_printf(seq,
cf30273b
HS
125 "LAN-64 MAC address @ [?:%02X:%02X:?] %pM",
126 serialno[8], serialno[9], &serialno[2]);
1da177e4
LT
127 break;
128
129 case I2O_SNFORMAT_DDM: /* I2O DDM */
130 seq_printf(seq,
131 "DDM: Tid=%03Xh, Rsvd=%04Xh, OrgId=%04Xh",
132 *(u16 *) & serialno[2],
133 *(u16 *) & serialno[4], *(u16 *) & serialno[6]);
134 break;
135
136 case I2O_SNFORMAT_IEEE_REG64: /* IEEE Registered (64-bit) */
137 case I2O_SNFORMAT_IEEE_REG128: /* IEEE Registered (128-bit) */
138 /* FIXME: Figure if this is even close?? */
139 seq_printf(seq,
140 "IEEE NodeName(hi,lo)=(%08Xh:%08Xh), PortName(hi,lo)=(%08Xh:%08Xh)\n",
141 *(u32 *) & serialno[2],
142 *(u32 *) & serialno[6],
143 *(u32 *) & serialno[10], *(u32 *) & serialno[14]);
144 break;
145
146 case I2O_SNFORMAT_UNKNOWN: /* Unknown 0 */
147 case I2O_SNFORMAT_UNKNOWN2: /* Unknown 0xff */
148 default:
149 seq_printf(seq, "Unknown data format (0x%02x)", serialno[0]);
150 break;
151 }
152
153 return 0;
154}
155
156/**
157 * i2o_get_class_name - do i2o class name lookup
158 * @class: class number
159 *
d9489fb6 160 * Return a descriptive string for an i2o class.
1da177e4
LT
161 */
162static const char *i2o_get_class_name(int class)
163{
164 int idx = 16;
165 static char *i2o_class_name[] = {
166 "Executive",
167 "Device Driver Module",
168 "Block Device",
169 "Tape Device",
170 "LAN Interface",
171 "WAN Interface",
172 "Fibre Channel Port",
173 "Fibre Channel Device",
174 "SCSI Device",
175 "ATE Port",
176 "ATE Device",
177 "Floppy Controller",
178 "Floppy Device",
179 "Secondary Bus Port",
180 "Peer Transport Agent",
181 "Peer Transport",
182 "Unknown"
183 };
184
185 switch (class & 0xfff) {
186 case I2O_CLASS_EXECUTIVE:
187 idx = 0;
188 break;
189 case I2O_CLASS_DDM:
190 idx = 1;
191 break;
192 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
193 idx = 2;
194 break;
195 case I2O_CLASS_SEQUENTIAL_STORAGE:
196 idx = 3;
197 break;
198 case I2O_CLASS_LAN:
199 idx = 4;
200 break;
201 case I2O_CLASS_WAN:
202 idx = 5;
203 break;
204 case I2O_CLASS_FIBRE_CHANNEL_PORT:
205 idx = 6;
206 break;
207 case I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL:
208 idx = 7;
209 break;
210 case I2O_CLASS_SCSI_PERIPHERAL:
211 idx = 8;
212 break;
213 case I2O_CLASS_ATE_PORT:
214 idx = 9;
215 break;
216 case I2O_CLASS_ATE_PERIPHERAL:
217 idx = 10;
218 break;
219 case I2O_CLASS_FLOPPY_CONTROLLER:
220 idx = 11;
221 break;
222 case I2O_CLASS_FLOPPY_DEVICE:
223 idx = 12;
224 break;
f10378ff 225 case I2O_CLASS_BUS_ADAPTER:
1da177e4
LT
226 idx = 13;
227 break;
228 case I2O_CLASS_PEER_TRANSPORT_AGENT:
229 idx = 14;
230 break;
231 case I2O_CLASS_PEER_TRANSPORT:
232 idx = 15;
233 break;
234 }
235
236 return i2o_class_name[idx];
237}
238
239#define SCSI_TABLE_SIZE 13
240static char *scsi_devices[] = {
241 "Direct-Access Read/Write",
242 "Sequential-Access Storage",
243 "Printer",
244 "Processor",
245 "WORM Device",
246 "CD-ROM Device",
247 "Scanner Device",
248 "Optical Memory Device",
249 "Medium Changer Device",
250 "Communications Device",
251 "Graphics Art Pre-Press Device",
252 "Graphics Art Pre-Press Device",
253 "Array Controller Device"
254};
255
40251b8e 256static char *chtostr(char *tmp, u8 *chars, int n)
1da177e4 257{
1da177e4
LT
258 tmp[0] = 0;
259 return strncat(tmp, (char *)chars, n);
260}
261
262static int i2o_report_query_status(struct seq_file *seq, int block_status,
263 char *group)
264{
265 switch (block_status) {
266 case -ETIMEDOUT:
6a3386b1
JP
267 seq_printf(seq, "Timeout reading group %s.\n", group);
268 break;
1da177e4 269 case -ENOMEM:
6a3386b1
JP
270 seq_puts(seq, "No free memory to read the table.\n");
271 break;
1da177e4 272 case -I2O_PARAMS_STATUS_INVALID_GROUP_ID:
6a3386b1
JP
273 seq_printf(seq, "Group %s not supported.\n", group);
274 break;
1da177e4 275 default:
6a3386b1
JP
276 seq_printf(seq,
277 "Error reading group %s. BlockStatus 0x%02X\n",
278 group, -block_status);
279 break;
1da177e4 280 }
6a3386b1
JP
281
282 return 0;
1da177e4
LT
283}
284
285static char *bus_strings[] = {
286 "Local Bus",
287 "ISA",
288 "EISA",
1da177e4
LT
289 "PCI",
290 "PCMCIA",
291 "NUBUS",
292 "CARDBUS"
293};
294
295static int i2o_seq_show_hrt(struct seq_file *seq, void *v)
296{
297 struct i2o_controller *c = (struct i2o_controller *)seq->private;
298 i2o_hrt *hrt = (i2o_hrt *) c->hrt.virt;
299 u32 bus;
300 int i;
301
302 if (hrt->hrt_version) {
303 seq_printf(seq,
304 "HRT table for controller is too new a version.\n");
305 return 0;
306 }
307
308 seq_printf(seq, "HRT has %d entries of %d bytes each.\n",
309 hrt->num_entries, hrt->entry_len << 2);
310
311 for (i = 0; i < hrt->num_entries; i++) {
312 seq_printf(seq, "Entry %d:\n", i);
313 seq_printf(seq, " Adapter ID: %0#10x\n",
314 hrt->hrt_entry[i].adapter_id);
315 seq_printf(seq, " Controlling tid: %0#6x\n",
316 hrt->hrt_entry[i].parent_tid);
317
318 if (hrt->hrt_entry[i].bus_type != 0x80) {
319 bus = hrt->hrt_entry[i].bus_type;
320 seq_printf(seq, " %s Information\n",
321 bus_strings[bus]);
322
323 switch (bus) {
324 case I2O_BUS_LOCAL:
325 seq_printf(seq, " IOBase: %0#6x,",
326 hrt->hrt_entry[i].bus.local_bus.
327 LbBaseIOPort);
328 seq_printf(seq, " MemoryBase: %0#10x\n",
329 hrt->hrt_entry[i].bus.local_bus.
330 LbBaseMemoryAddress);
331 break;
332
333 case I2O_BUS_ISA:
334 seq_printf(seq, " IOBase: %0#6x,",
335 hrt->hrt_entry[i].bus.isa_bus.
336 IsaBaseIOPort);
337 seq_printf(seq, " MemoryBase: %0#10x,",
338 hrt->hrt_entry[i].bus.isa_bus.
339 IsaBaseMemoryAddress);
340 seq_printf(seq, " CSN: %0#4x,",
341 hrt->hrt_entry[i].bus.isa_bus.CSN);
342 break;
343
344 case I2O_BUS_EISA:
345 seq_printf(seq, " IOBase: %0#6x,",
346 hrt->hrt_entry[i].bus.eisa_bus.
347 EisaBaseIOPort);
348 seq_printf(seq, " MemoryBase: %0#10x,",
349 hrt->hrt_entry[i].bus.eisa_bus.
350 EisaBaseMemoryAddress);
351 seq_printf(seq, " Slot: %0#4x,",
352 hrt->hrt_entry[i].bus.eisa_bus.
353 EisaSlotNumber);
1da177e4
LT
354 break;
355
356 case I2O_BUS_PCI:
357 seq_printf(seq, " Bus: %0#4x",
358 hrt->hrt_entry[i].bus.pci_bus.
359 PciBusNumber);
360 seq_printf(seq, " Dev: %0#4x",
361 hrt->hrt_entry[i].bus.pci_bus.
362 PciDeviceNumber);
363 seq_printf(seq, " Func: %0#4x",
364 hrt->hrt_entry[i].bus.pci_bus.
365 PciFunctionNumber);
366 seq_printf(seq, " Vendor: %0#6x",
367 hrt->hrt_entry[i].bus.pci_bus.
368 PciVendorID);
369 seq_printf(seq, " Device: %0#6x\n",
370 hrt->hrt_entry[i].bus.pci_bus.
371 PciDeviceID);
372 break;
373
374 default:
375 seq_printf(seq, " Unsupported Bus Type\n");
376 }
377 } else
378 seq_printf(seq, " Unknown Bus Type\n");
379 }
380
381 return 0;
382}
383
384static int i2o_seq_show_lct(struct seq_file *seq, void *v)
385{
386 struct i2o_controller *c = (struct i2o_controller *)seq->private;
387 i2o_lct *lct = (i2o_lct *) c->lct;
388 int entries;
389 int i;
390
391#define BUS_TABLE_SIZE 3
392 static char *bus_ports[] = {
393 "Generic Bus",
394 "SCSI Bus",
395 "Fibre Channel Bus"
396 };
397
398 entries = (lct->table_size - 3) / 9;
399
400 seq_printf(seq, "LCT contains %d %s\n", entries,
401 entries == 1 ? "entry" : "entries");
402 if (lct->boot_tid)
403 seq_printf(seq, "Boot Device @ ID %d\n", lct->boot_tid);
404
405 seq_printf(seq, "Current Change Indicator: %#10x\n", lct->change_ind);
406
407 for (i = 0; i < entries; i++) {
408 seq_printf(seq, "Entry %d\n", i);
409 seq_printf(seq, " Class, SubClass : %s",
410 i2o_get_class_name(lct->lct_entry[i].class_id));
411
412 /*
413 * Classes which we'll print subclass info for
414 */
415 switch (lct->lct_entry[i].class_id & 0xFFF) {
416 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
417 switch (lct->lct_entry[i].sub_class) {
418 case 0x00:
419 seq_printf(seq, ", Direct-Access Read/Write");
420 break;
421
422 case 0x04:
423 seq_printf(seq, ", WORM Drive");
424 break;
425
426 case 0x05:
427 seq_printf(seq, ", CD-ROM Drive");
428 break;
429
430 case 0x07:
431 seq_printf(seq, ", Optical Memory Device");
432 break;
433
434 default:
435 seq_printf(seq, ", Unknown (0x%02x)",
436 lct->lct_entry[i].sub_class);
437 break;
438 }
439 break;
440
441 case I2O_CLASS_LAN:
442 switch (lct->lct_entry[i].sub_class & 0xFF) {
443 case 0x30:
444 seq_printf(seq, ", Ethernet");
445 break;
446
447 case 0x40:
448 seq_printf(seq, ", 100base VG");
449 break;
450
451 case 0x50:
452 seq_printf(seq, ", IEEE 802.5/Token-Ring");
453 break;
454
455 case 0x60:
456 seq_printf(seq, ", ANSI X3T9.5 FDDI");
457 break;
458
459 case 0x70:
460 seq_printf(seq, ", Fibre Channel");
461 break;
462
463 default:
464 seq_printf(seq, ", Unknown Sub-Class (0x%02x)",
465 lct->lct_entry[i].sub_class & 0xFF);
466 break;
467 }
468 break;
469
470 case I2O_CLASS_SCSI_PERIPHERAL:
471 if (lct->lct_entry[i].sub_class < SCSI_TABLE_SIZE)
472 seq_printf(seq, ", %s",
473 scsi_devices[lct->lct_entry[i].
474 sub_class]);
475 else
476 seq_printf(seq, ", Unknown Device Type");
477 break;
478
f10378ff 479 case I2O_CLASS_BUS_ADAPTER:
1da177e4
LT
480 if (lct->lct_entry[i].sub_class < BUS_TABLE_SIZE)
481 seq_printf(seq, ", %s",
482 bus_ports[lct->lct_entry[i].
483 sub_class]);
484 else
485 seq_printf(seq, ", Unknown Bus Type");
486 break;
487 }
488 seq_printf(seq, "\n");
489
490 seq_printf(seq, " Local TID : 0x%03x\n",
491 lct->lct_entry[i].tid);
492 seq_printf(seq, " User TID : 0x%03x\n",
493 lct->lct_entry[i].user_tid);
494 seq_printf(seq, " Parent TID : 0x%03x\n",
495 lct->lct_entry[i].parent_tid);
496 seq_printf(seq, " Identity Tag : 0x%x%x%x%x%x%x%x%x\n",
497 lct->lct_entry[i].identity_tag[0],
498 lct->lct_entry[i].identity_tag[1],
499 lct->lct_entry[i].identity_tag[2],
500 lct->lct_entry[i].identity_tag[3],
501 lct->lct_entry[i].identity_tag[4],
502 lct->lct_entry[i].identity_tag[5],
503 lct->lct_entry[i].identity_tag[6],
504 lct->lct_entry[i].identity_tag[7]);
505 seq_printf(seq, " Change Indicator : %0#10x\n",
506 lct->lct_entry[i].change_ind);
507 seq_printf(seq, " Event Capab Mask : %0#10x\n",
508 lct->lct_entry[i].device_flags);
509 }
510
511 return 0;
512}
513
514static int i2o_seq_show_status(struct seq_file *seq, void *v)
515{
516 struct i2o_controller *c = (struct i2o_controller *)seq->private;
517 char prodstr[25];
518 int version;
519 i2o_status_block *sb = c->status_block.virt;
520
521 i2o_status_get(c); // reread the status block
522
523 seq_printf(seq, "Organization ID : %0#6x\n", sb->org_id);
524
525 version = sb->i2o_version;
526
527/* FIXME for Spec 2.0
528 if (version == 0x02) {
529 seq_printf(seq, "Lowest I2O version supported: ");
530 switch(workspace[2]) {
531 case 0x00:
532 seq_printf(seq, "1.0\n");
533 break;
534 case 0x01:
535 seq_printf(seq, "1.5\n");
536 break;
537 case 0x02:
538 seq_printf(seq, "2.0\n");
539 break;
540 }
541
542 seq_printf(seq, "Highest I2O version supported: ");
543 switch(workspace[3]) {
544 case 0x00:
545 seq_printf(seq, "1.0\n");
546 break;
547 case 0x01:
548 seq_printf(seq, "1.5\n");
549 break;
550 case 0x02:
551 seq_printf(seq, "2.0\n");
552 break;
553 }
554 }
555*/
556 seq_printf(seq, "IOP ID : %0#5x\n", sb->iop_id);
557 seq_printf(seq, "Host Unit ID : %0#6x\n", sb->host_unit_id);
558 seq_printf(seq, "Segment Number : %0#5x\n", sb->segment_number);
559
560 seq_printf(seq, "I2O version : ");
561 switch (version) {
562 case 0x00:
563 seq_printf(seq, "1.0\n");
564 break;
565 case 0x01:
566 seq_printf(seq, "1.5\n");
567 break;
568 case 0x02:
569 seq_printf(seq, "2.0\n");
570 break;
571 default:
572 seq_printf(seq, "Unknown version\n");
573 }
574
575 seq_printf(seq, "IOP State : ");
576 switch (sb->iop_state) {
577 case 0x01:
578 seq_printf(seq, "INIT\n");
579 break;
580
581 case 0x02:
582 seq_printf(seq, "RESET\n");
583 break;
584
585 case 0x04:
586 seq_printf(seq, "HOLD\n");
587 break;
588
589 case 0x05:
590 seq_printf(seq, "READY\n");
591 break;
592
593 case 0x08:
594 seq_printf(seq, "OPERATIONAL\n");
595 break;
596
597 case 0x10:
598 seq_printf(seq, "FAILED\n");
599 break;
600
601 case 0x11:
602 seq_printf(seq, "FAULTED\n");
603 break;
604
605 default:
606 seq_printf(seq, "Unknown\n");
607 break;
608 }
609
610 seq_printf(seq, "Messenger Type : ");
611 switch (sb->msg_type) {
612 case 0x00:
613 seq_printf(seq, "Memory mapped\n");
614 break;
615 case 0x01:
616 seq_printf(seq, "Memory mapped only\n");
617 break;
618 case 0x02:
619 seq_printf(seq, "Remote only\n");
620 break;
621 case 0x03:
622 seq_printf(seq, "Memory mapped and remote\n");
623 break;
624 default:
625 seq_printf(seq, "Unknown\n");
626 }
627
628 seq_printf(seq, "Inbound Frame Size : %d bytes\n",
629 sb->inbound_frame_size << 2);
630 seq_printf(seq, "Max Inbound Frames : %d\n",
631 sb->max_inbound_frames);
632 seq_printf(seq, "Current Inbound Frames : %d\n",
633 sb->cur_inbound_frames);
634 seq_printf(seq, "Max Outbound Frames : %d\n",
635 sb->max_outbound_frames);
636
637 /* Spec doesn't say if NULL terminated or not... */
638 memcpy(prodstr, sb->product_id, 24);
639 prodstr[24] = '\0';
640 seq_printf(seq, "Product ID : %s\n", prodstr);
641 seq_printf(seq, "Expected LCT Size : %d bytes\n",
642 sb->expected_lct_size);
643
644 seq_printf(seq, "IOP Capabilities\n");
645 seq_printf(seq, " Context Field Size Support : ");
646 switch (sb->iop_capabilities & 0x0000003) {
647 case 0:
648 seq_printf(seq, "Supports only 32-bit context fields\n");
649 break;
650 case 1:
651 seq_printf(seq, "Supports only 64-bit context fields\n");
652 break;
653 case 2:
654 seq_printf(seq, "Supports 32-bit and 64-bit context fields, "
655 "but not concurrently\n");
656 break;
657 case 3:
658 seq_printf(seq, "Supports 32-bit and 64-bit context fields "
659 "concurrently\n");
660 break;
661 default:
662 seq_printf(seq, "0x%08x\n", sb->iop_capabilities);
663 }
664 seq_printf(seq, " Current Context Field Size : ");
665 switch (sb->iop_capabilities & 0x0000000C) {
666 case 0:
667 seq_printf(seq, "not configured\n");
668 break;
669 case 4:
670 seq_printf(seq, "Supports only 32-bit context fields\n");
671 break;
672 case 8:
673 seq_printf(seq, "Supports only 64-bit context fields\n");
674 break;
675 case 12:
676 seq_printf(seq, "Supports both 32-bit or 64-bit context fields "
677 "concurrently\n");
678 break;
679 default:
680 seq_printf(seq, "\n");
681 }
682 seq_printf(seq, " Inbound Peer Support : %s\n",
683 (sb->
684 iop_capabilities & 0x00000010) ? "Supported" :
685 "Not supported");
686 seq_printf(seq, " Outbound Peer Support : %s\n",
687 (sb->
688 iop_capabilities & 0x00000020) ? "Supported" :
689 "Not supported");
690 seq_printf(seq, " Peer to Peer Support : %s\n",
691 (sb->
692 iop_capabilities & 0x00000040) ? "Supported" :
693 "Not supported");
694
695 seq_printf(seq, "Desired private memory size : %d kB\n",
696 sb->desired_mem_size >> 10);
697 seq_printf(seq, "Allocated private memory size : %d kB\n",
698 sb->current_mem_size >> 10);
699 seq_printf(seq, "Private memory base address : %0#10x\n",
700 sb->current_mem_base);
701 seq_printf(seq, "Desired private I/O size : %d kB\n",
702 sb->desired_io_size >> 10);
703 seq_printf(seq, "Allocated private I/O size : %d kB\n",
704 sb->current_io_size >> 10);
705 seq_printf(seq, "Private I/O base address : %0#10x\n",
706 sb->current_io_base);
707
708 return 0;
709}
710
711static int i2o_seq_show_hw(struct seq_file *seq, void *v)
712{
713 struct i2o_controller *c = (struct i2o_controller *)seq->private;
714 static u32 work32[5];
715 static u8 *work8 = (u8 *) work32;
716 static u16 *work16 = (u16 *) work32;
717 int token;
718 u32 hwcap;
719
720 static char *cpu_table[] = {
721 "Intel 80960 series",
722 "AMD2900 series",
723 "Motorola 68000 series",
724 "ARM series",
725 "MIPS series",
726 "Sparc series",
727 "PowerPC series",
728 "Intel x86 series"
729 };
730
731 token =
732 i2o_parm_field_get(c->exec, 0x0000, -1, &work32, sizeof(work32));
733
734 if (token < 0) {
735 i2o_report_query_status(seq, token, "0x0000 IOP Hardware");
736 return 0;
737 }
738
739 seq_printf(seq, "I2O Vendor ID : %0#6x\n", work16[0]);
740 seq_printf(seq, "Product ID : %0#6x\n", work16[1]);
741 seq_printf(seq, "CPU : ");
742 if (work8[16] > 8)
743 seq_printf(seq, "Unknown\n");
744 else
745 seq_printf(seq, "%s\n", cpu_table[work8[16]]);
746 /* Anyone using ProcessorVersion? */
747
748 seq_printf(seq, "RAM : %dkB\n", work32[1] >> 10);
749 seq_printf(seq, "Non-Volatile Mem : %dkB\n", work32[2] >> 10);
750
751 hwcap = work32[3];
752 seq_printf(seq, "Capabilities : 0x%08x\n", hwcap);
753 seq_printf(seq, " [%s] Self booting\n",
754 (hwcap & 0x00000001) ? "+" : "-");
755 seq_printf(seq, " [%s] Upgradable IRTOS\n",
756 (hwcap & 0x00000002) ? "+" : "-");
757 seq_printf(seq, " [%s] Supports downloading DDMs\n",
758 (hwcap & 0x00000004) ? "+" : "-");
759 seq_printf(seq, " [%s] Supports installing DDMs\n",
760 (hwcap & 0x00000008) ? "+" : "-");
761 seq_printf(seq, " [%s] Battery-backed RAM\n",
762 (hwcap & 0x00000010) ? "+" : "-");
763
764 return 0;
765}
766
767/* Executive group 0003h - Executing DDM List (table) */
768static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
769{
770 struct i2o_controller *c = (struct i2o_controller *)seq->private;
771 int token;
772 int i;
773
774 typedef struct _i2o_exec_execute_ddm_table {
775 u16 ddm_tid;
776 u8 module_type;
777 u8 reserved;
778 u16 i2o_vendor_id;
779 u16 module_id;
780 u8 module_name_version[28];
781 u32 data_size;
782 u32 code_size;
783 } i2o_exec_execute_ddm_table;
784
785 struct {
786 u16 result_count;
787 u16 pad;
788 u16 block_size;
789 u8 block_status;
790 u8 error_info_size;
791 u16 row_count;
792 u16 more_flag;
793 i2o_exec_execute_ddm_table ddm_table[I2O_MAX_MODULES];
794 } *result;
795
796 i2o_exec_execute_ddm_table ddm_table;
40251b8e 797 char tmp[28 + 1];
1da177e4
LT
798
799 result = kmalloc(sizeof(*result), GFP_KERNEL);
800 if (!result)
801 return -ENOMEM;
802
803 token = i2o_parm_table_get(c->exec, I2O_PARAMS_TABLE_GET, 0x0003, -1,
804 NULL, 0, result, sizeof(*result));
805
806 if (token < 0) {
807 i2o_report_query_status(seq, token,
808 "0x0003 Executing DDM List");
809 goto out;
810 }
811
812 seq_printf(seq,
813 "Tid Module_type Vendor Mod_id Module_name Vrs Data_size Code_size\n");
814 ddm_table = result->ddm_table[0];
815
816 for (i = 0; i < result->row_count; ddm_table = result->ddm_table[++i]) {
817 seq_printf(seq, "0x%03x ", ddm_table.ddm_tid & 0xFFF);
818
819 switch (ddm_table.module_type) {
820 case 0x01:
821 seq_printf(seq, "Downloaded DDM ");
822 break;
823 case 0x22:
824 seq_printf(seq, "Embedded DDM ");
825 break;
826 default:
827 seq_printf(seq, " ");
828 }
829
830 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
831 seq_printf(seq, "%-#8x", ddm_table.module_id);
832 seq_printf(seq, "%-29s",
40251b8e 833 chtostr(tmp, ddm_table.module_name_version, 28));
1da177e4
LT
834 seq_printf(seq, "%9d ", ddm_table.data_size);
835 seq_printf(seq, "%8d", ddm_table.code_size);
836
837 seq_printf(seq, "\n");
838 }
839 out:
840 kfree(result);
841 return 0;
842}
843
844/* Executive group 0004h - Driver Store (scalar) */
845static int i2o_seq_show_driver_store(struct seq_file *seq, void *v)
846{
847 struct i2o_controller *c = (struct i2o_controller *)seq->private;
848 u32 work32[8];
849 int token;
850
851 token =
852 i2o_parm_field_get(c->exec, 0x0004, -1, &work32, sizeof(work32));
853 if (token < 0) {
854 i2o_report_query_status(seq, token, "0x0004 Driver Store");
855 return 0;
856 }
857
858 seq_printf(seq, "Module limit : %d\n"
859 "Module count : %d\n"
860 "Current space : %d kB\n"
861 "Free space : %d kB\n",
862 work32[0], work32[1], work32[2] >> 10, work32[3] >> 10);
863
864 return 0;
865}
866
867/* Executive group 0005h - Driver Store Table (table) */
868static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
869{
870 typedef struct _i2o_driver_store {
871 u16 stored_ddm_index;
872 u8 module_type;
873 u8 reserved;
874 u16 i2o_vendor_id;
875 u16 module_id;
876 u8 module_name_version[28];
877 u8 date[8];
878 u32 module_size;
879 u32 mpb_size;
880 u32 module_flags;
881 } i2o_driver_store_table;
882
883 struct i2o_controller *c = (struct i2o_controller *)seq->private;
884 int token;
885 int i;
886
887 typedef struct {
888 u16 result_count;
889 u16 pad;
890 u16 block_size;
891 u8 block_status;
892 u8 error_info_size;
893 u16 row_count;
894 u16 more_flag;
895 i2o_driver_store_table dst[I2O_MAX_MODULES];
896 } i2o_driver_result_table;
897
898 i2o_driver_result_table *result;
899 i2o_driver_store_table *dst;
40251b8e 900 char tmp[28 + 1];
1da177e4
LT
901
902 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
903 if (result == NULL)
904 return -ENOMEM;
905
906 token = i2o_parm_table_get(c->exec, I2O_PARAMS_TABLE_GET, 0x0005, -1,
907 NULL, 0, result, sizeof(*result));
908
909 if (token < 0) {
910 i2o_report_query_status(seq, token,
911 "0x0005 DRIVER STORE TABLE");
912 kfree(result);
913 return 0;
914 }
915
916 seq_printf(seq,
917 "# Module_type Vendor Mod_id Module_name Vrs"
918 "Date Mod_size Par_size Flags\n");
919 for (i = 0, dst = &result->dst[0]; i < result->row_count;
920 dst = &result->dst[++i]) {
921 seq_printf(seq, "%-3d", dst->stored_ddm_index);
922 switch (dst->module_type) {
923 case 0x01:
924 seq_printf(seq, "Downloaded DDM ");
925 break;
926 case 0x22:
927 seq_printf(seq, "Embedded DDM ");
928 break;
929 default:
930 seq_printf(seq, " ");
931 }
932
933 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
934 seq_printf(seq, "%-#8x", dst->module_id);
40251b8e
KD
935 seq_printf(seq, "%-29s",
936 chtostr(tmp, dst->module_name_version, 28));
937 seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
1da177e4
LT
938 seq_printf(seq, "%8d ", dst->module_size);
939 seq_printf(seq, "%8d ", dst->mpb_size);
940 seq_printf(seq, "0x%04x", dst->module_flags);
941 seq_printf(seq, "\n");
942 }
943
944 kfree(result);
945 return 0;
946}
947
948/* Generic group F000h - Params Descriptor (table) */
949static int i2o_seq_show_groups(struct seq_file *seq, void *v)
950{
951 struct i2o_device *d = (struct i2o_device *)seq->private;
952 int token;
953 int i;
954 u8 properties;
955
956 typedef struct _i2o_group_info {
957 u16 group_number;
958 u16 field_count;
959 u16 row_count;
960 u8 properties;
961 u8 reserved;
962 } i2o_group_info;
963
964 struct {
965 u16 result_count;
966 u16 pad;
967 u16 block_size;
968 u8 block_status;
969 u8 error_info_size;
970 u16 row_count;
971 u16 more_flag;
972 i2o_group_info group[256];
973 } *result;
974
975 result = kmalloc(sizeof(*result), GFP_KERNEL);
976 if (!result)
977 return -ENOMEM;
978
979 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF000, -1, NULL, 0,
980 result, sizeof(*result));
981
982 if (token < 0) {
983 i2o_report_query_status(seq, token, "0xF000 Params Descriptor");
984 goto out;
985 }
986
987 seq_printf(seq,
988 "# Group FieldCount RowCount Type Add Del Clear\n");
989
990 for (i = 0; i < result->row_count; i++) {
991 seq_printf(seq, "%-3d", i);
992 seq_printf(seq, "0x%04X ", result->group[i].group_number);
993 seq_printf(seq, "%10d ", result->group[i].field_count);
994 seq_printf(seq, "%8d ", result->group[i].row_count);
995
996 properties = result->group[i].properties;
997 if (properties & 0x1)
998 seq_printf(seq, "Table ");
999 else
1000 seq_printf(seq, "Scalar ");
1001 if (properties & 0x2)
1002 seq_printf(seq, " + ");
1003 else
1004 seq_printf(seq, " - ");
1005 if (properties & 0x4)
1006 seq_printf(seq, " + ");
1007 else
1008 seq_printf(seq, " - ");
1009 if (properties & 0x8)
1010 seq_printf(seq, " + ");
1011 else
1012 seq_printf(seq, " - ");
1013
1014 seq_printf(seq, "\n");
1015 }
1016
1017 if (result->more_flag)
1018 seq_printf(seq, "There is more...\n");
1019 out:
1020 kfree(result);
1021 return 0;
1022}
1023
1024/* Generic group F001h - Physical Device Table (table) */
1025static int i2o_seq_show_phys_device(struct seq_file *seq, void *v)
1026{
1027 struct i2o_device *d = (struct i2o_device *)seq->private;
1028 int token;
1029 int i;
1030
1031 struct {
1032 u16 result_count;
1033 u16 pad;
1034 u16 block_size;
1035 u8 block_status;
1036 u8 error_info_size;
1037 u16 row_count;
1038 u16 more_flag;
1039 u32 adapter_id[64];
1040 } result;
1041
1042 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF001, -1, NULL, 0,
1043 &result, sizeof(result));
1044
1045 if (token < 0) {
1046 i2o_report_query_status(seq, token,
1047 "0xF001 Physical Device Table");
1048 return 0;
1049 }
1050
1051 if (result.row_count)
1052 seq_printf(seq, "# AdapterId\n");
1053
1054 for (i = 0; i < result.row_count; i++) {
1055 seq_printf(seq, "%-2d", i);
1056 seq_printf(seq, "%#7x\n", result.adapter_id[i]);
1057 }
1058
1059 if (result.more_flag)
1060 seq_printf(seq, "There is more...\n");
1061
1062 return 0;
1063}
1064
1065/* Generic group F002h - Claimed Table (table) */
1066static int i2o_seq_show_claimed(struct seq_file *seq, void *v)
1067{
1068 struct i2o_device *d = (struct i2o_device *)seq->private;
1069 int token;
1070 int i;
1071
1072 struct {
1073 u16 result_count;
1074 u16 pad;
1075 u16 block_size;
1076 u8 block_status;
1077 u8 error_info_size;
1078 u16 row_count;
1079 u16 more_flag;
1080 u16 claimed_tid[64];
1081 } result;
1082
1083 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF002, -1, NULL, 0,
1084 &result, sizeof(result));
1085
1086 if (token < 0) {
1087 i2o_report_query_status(seq, token, "0xF002 Claimed Table");
1088 return 0;
1089 }
1090
1091 if (result.row_count)
1092 seq_printf(seq, "# ClaimedTid\n");
1093
1094 for (i = 0; i < result.row_count; i++) {
1095 seq_printf(seq, "%-2d", i);
1096 seq_printf(seq, "%#7x\n", result.claimed_tid[i]);
1097 }
1098
1099 if (result.more_flag)
1100 seq_printf(seq, "There is more...\n");
1101
1102 return 0;
1103}
1104
1105/* Generic group F003h - User Table (table) */
1106static int i2o_seq_show_users(struct seq_file *seq, void *v)
1107{
1108 struct i2o_device *d = (struct i2o_device *)seq->private;
1109 int token;
1110 int i;
1111
1112 typedef struct _i2o_user_table {
1113 u16 instance;
1114 u16 user_tid;
1115 u8 claim_type;
1116 u8 reserved1;
1117 u16 reserved2;
1118 } i2o_user_table;
1119
1120 struct {
1121 u16 result_count;
1122 u16 pad;
1123 u16 block_size;
1124 u8 block_status;
1125 u8 error_info_size;
1126 u16 row_count;
1127 u16 more_flag;
1128 i2o_user_table user[64];
1129 } *result;
1130
1131 result = kmalloc(sizeof(*result), GFP_KERNEL);
1132 if (!result)
1133 return -ENOMEM;
1134
1135 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF003, -1, NULL, 0,
1136 result, sizeof(*result));
1137
1138 if (token < 0) {
1139 i2o_report_query_status(seq, token, "0xF003 User Table");
1140 goto out;
1141 }
1142
1143 seq_printf(seq, "# Instance UserTid ClaimType\n");
1144
1145 for (i = 0; i < result->row_count; i++) {
1146 seq_printf(seq, "%-3d", i);
1147 seq_printf(seq, "%#8x ", result->user[i].instance);
1148 seq_printf(seq, "%#7x ", result->user[i].user_tid);
1149 seq_printf(seq, "%#9x\n", result->user[i].claim_type);
1150 }
1151
1152 if (result->more_flag)
1153 seq_printf(seq, "There is more...\n");
1154 out:
1155 kfree(result);
1156 return 0;
1157}
1158
1159/* Generic group F005h - Private message extensions (table) (optional) */
1160static int i2o_seq_show_priv_msgs(struct seq_file *seq, void *v)
1161{
1162 struct i2o_device *d = (struct i2o_device *)seq->private;
1163 int token;
1164 int i;
1165
1166 typedef struct _i2o_private {
1167 u16 ext_instance;
1168 u16 organization_id;
1169 u16 x_function_code;
1170 } i2o_private;
1171
1172 struct {
1173 u16 result_count;
1174 u16 pad;
1175 u16 block_size;
1176 u8 block_status;
1177 u8 error_info_size;
1178 u16 row_count;
1179 u16 more_flag;
1180 i2o_private extension[64];
1181 } result;
1182
1183 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF000, -1, NULL, 0,
1184 &result, sizeof(result));
1185
1186 if (token < 0) {
1187 i2o_report_query_status(seq, token,
1188 "0xF005 Private Message Extensions (optional)");
1189 return 0;
1190 }
1191
1192 seq_printf(seq, "Instance# OrgId FunctionCode\n");
1193
1194 for (i = 0; i < result.row_count; i++) {
1195 seq_printf(seq, "%0#9x ", result.extension[i].ext_instance);
1196 seq_printf(seq, "%0#6x ", result.extension[i].organization_id);
1197 seq_printf(seq, "%0#6x", result.extension[i].x_function_code);
1198
1199 seq_printf(seq, "\n");
1200 }
1201
1202 if (result.more_flag)
1203 seq_printf(seq, "There is more...\n");
1204
1205 return 0;
1206}
1207
1208/* Generic group F006h - Authorized User Table (table) */
1209static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
1210{
1211 struct i2o_device *d = (struct i2o_device *)seq->private;
1212 int token;
1213 int i;
1214
1215 struct {
1216 u16 result_count;
1217 u16 pad;
1218 u16 block_size;
1219 u8 block_status;
1220 u8 error_info_size;
1221 u16 row_count;
1222 u16 more_flag;
1223 u32 alternate_tid[64];
1224 } result;
1225
1226 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF006, -1, NULL, 0,
1227 &result, sizeof(result));
1228
1229 if (token < 0) {
1230 i2o_report_query_status(seq, token,
1231 "0xF006 Autohorized User Table");
1232 return 0;
1233 }
1234
1235 if (result.row_count)
1236 seq_printf(seq, "# AlternateTid\n");
1237
1238 for (i = 0; i < result.row_count; i++) {
1239 seq_printf(seq, "%-2d", i);
1240 seq_printf(seq, "%#7x ", result.alternate_tid[i]);
1241 }
1242
1243 if (result.more_flag)
1244 seq_printf(seq, "There is more...\n");
1245
1246 return 0;
1247}
1248
1249/* Generic group F100h - Device Identity (scalar) */
1250static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
1251{
1252 struct i2o_device *d = (struct i2o_device *)seq->private;
1253 static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
1254 // == (allow) 512d bytes (max)
1255 static u16 *work16 = (u16 *) work32;
1256 int token;
40251b8e 1257 char tmp[16 + 1];
1da177e4
LT
1258
1259 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
1260
1261 if (token < 0) {
1262 i2o_report_query_status(seq, token, "0xF100 Device Identity");
1263 return 0;
1264 }
1265
1266 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
1267 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
1268 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
1269 seq_printf(seq, "Vendor info : %s\n",
40251b8e 1270 chtostr(tmp, (u8 *) (work32 + 2), 16));
1da177e4 1271 seq_printf(seq, "Product info : %s\n",
40251b8e 1272 chtostr(tmp, (u8 *) (work32 + 6), 16));
1da177e4 1273 seq_printf(seq, "Description : %s\n",
40251b8e 1274 chtostr(tmp, (u8 *) (work32 + 10), 16));
1da177e4 1275 seq_printf(seq, "Product rev. : %s\n",
40251b8e 1276 chtostr(tmp, (u8 *) (work32 + 14), 8));
1da177e4
LT
1277
1278 seq_printf(seq, "Serial number : ");
1279 print_serial_number(seq, (u8 *) (work32 + 16),
1280 /* allow for SNLen plus
1281 * possible trailing '\0'
1282 */
1283 sizeof(work32) - (16 * sizeof(u32)) - 2);
1284 seq_printf(seq, "\n");
1285
1286 return 0;
1287}
1288
1289static int i2o_seq_show_dev_name(struct seq_file *seq, void *v)
1290{
1291 struct i2o_device *d = (struct i2o_device *)seq->private;
1292
cd3ed6b4 1293 seq_printf(seq, "%s\n", dev_name(&d->device));
1da177e4
LT
1294
1295 return 0;
1296}
1297
1298/* Generic group F101h - DDM Identity (scalar) */
1299static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
1300{
1301 struct i2o_device *d = (struct i2o_device *)seq->private;
1302 int token;
1303
1304 struct {
1305 u16 ddm_tid;
1306 u8 module_name[24];
1307 u8 module_rev[8];
1308 u8 sn_format;
1309 u8 serial_number[12];
1310 u8 pad[256]; // allow up to 256 byte (max) serial number
1311 } result;
1312
40251b8e
KD
1313 char tmp[24 + 1];
1314
1da177e4
LT
1315 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
1316
1317 if (token < 0) {
1318 i2o_report_query_status(seq, token, "0xF101 DDM Identity");
1319 return 0;
1320 }
1321
1322 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
1323 seq_printf(seq, "Module name : %s\n",
40251b8e 1324 chtostr(tmp, result.module_name, 24));
1da177e4 1325 seq_printf(seq, "Module revision : %s\n",
40251b8e 1326 chtostr(tmp, result.module_rev, 8));
1da177e4
LT
1327
1328 seq_printf(seq, "Serial number : ");
1329 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
1330 /* allow for SNLen plus possible trailing '\0' */
1331
1332 seq_printf(seq, "\n");
1333
1334 return 0;
1335}
1336
1337/* Generic group F102h - User Information (scalar) */
1338static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
1339{
1340 struct i2o_device *d = (struct i2o_device *)seq->private;
1341 int token;
1342
1343 struct {
1344 u8 device_name[64];
1345 u8 service_name[64];
1346 u8 physical_location[64];
1347 u8 instance_number[4];
1348 } result;
1349
40251b8e
KD
1350 char tmp[64 + 1];
1351
1da177e4
LT
1352 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
1353
1354 if (token < 0) {
1355 i2o_report_query_status(seq, token, "0xF102 User Information");
1356 return 0;
1357 }
1358
1359 seq_printf(seq, "Device name : %s\n",
40251b8e 1360 chtostr(tmp, result.device_name, 64));
1da177e4 1361 seq_printf(seq, "Service name : %s\n",
40251b8e 1362 chtostr(tmp, result.service_name, 64));
1da177e4 1363 seq_printf(seq, "Physical name : %s\n",
40251b8e 1364 chtostr(tmp, result.physical_location, 64));
1da177e4 1365 seq_printf(seq, "Instance number : %s\n",
40251b8e 1366 chtostr(tmp, result.instance_number, 4));
1da177e4
LT
1367
1368 return 0;
1369}
1370
1371/* Generic group F103h - SGL Operating Limits (scalar) */
1372static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
1373{
1374 struct i2o_device *d = (struct i2o_device *)seq->private;
1375 static u32 work32[12];
1376 static u16 *work16 = (u16 *) work32;
1377 static u8 *work8 = (u8 *) work32;
1378 int token;
1379
1380 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
1381
1382 if (token < 0) {
1383 i2o_report_query_status(seq, token,
1384 "0xF103 SGL Operating Limits");
1385 return 0;
1386 }
1387
1388 seq_printf(seq, "SGL chain size : %d\n", work32[0]);
1389 seq_printf(seq, "Max SGL chain size : %d\n", work32[1]);
1390 seq_printf(seq, "SGL chain size target : %d\n", work32[2]);
1391 seq_printf(seq, "SGL frag count : %d\n", work16[6]);
1392 seq_printf(seq, "Max SGL frag count : %d\n", work16[7]);
1393 seq_printf(seq, "SGL frag count target : %d\n", work16[8]);
1394
1395/* FIXME
1396 if (d->i2oversion == 0x02)
1397 {
1398*/
1399 seq_printf(seq, "SGL data alignment : %d\n", work16[8]);
1400 seq_printf(seq, "SGL addr limit : %d\n", work8[20]);
1401 seq_printf(seq, "SGL addr sizes supported : ");
1402 if (work8[21] & 0x01)
1403 seq_printf(seq, "32 bit ");
1404 if (work8[21] & 0x02)
1405 seq_printf(seq, "64 bit ");
1406 if (work8[21] & 0x04)
1407 seq_printf(seq, "96 bit ");
1408 if (work8[21] & 0x08)
1409 seq_printf(seq, "128 bit ");
1410 seq_printf(seq, "\n");
1411/*
1412 }
1413*/
1414
1415 return 0;
1416}
1417
1418/* Generic group F200h - Sensors (scalar) */
1419static int i2o_seq_show_sensors(struct seq_file *seq, void *v)
1420{
1421 struct i2o_device *d = (struct i2o_device *)seq->private;
1422 int token;
1423
1424 struct {
1425 u16 sensor_instance;
1426 u8 component;
1427 u16 component_instance;
1428 u8 sensor_class;
1429 u8 sensor_type;
1430 u8 scaling_exponent;
1431 u32 actual_reading;
1432 u32 minimum_reading;
1433 u32 low2lowcat_treshold;
1434 u32 lowcat2low_treshold;
1435 u32 lowwarn2low_treshold;
1436 u32 low2lowwarn_treshold;
1437 u32 norm2lowwarn_treshold;
1438 u32 lowwarn2norm_treshold;
1439 u32 nominal_reading;
1440 u32 hiwarn2norm_treshold;
1441 u32 norm2hiwarn_treshold;
1442 u32 high2hiwarn_treshold;
1443 u32 hiwarn2high_treshold;
1444 u32 hicat2high_treshold;
1445 u32 hi2hicat_treshold;
1446 u32 maximum_reading;
1447 u8 sensor_state;
1448 u16 event_enable;
1449 } result;
1450
1451 token = i2o_parm_field_get(d, 0xF200, -1, &result, sizeof(result));
1452
1453 if (token < 0) {
1454 i2o_report_query_status(seq, token,
1455 "0xF200 Sensors (optional)");
1456 return 0;
1457 }
1458
1459 seq_printf(seq, "Sensor instance : %d\n", result.sensor_instance);
1460
1461 seq_printf(seq, "Component : %d = ", result.component);
1462 switch (result.component) {
1463 case 0:
1464 seq_printf(seq, "Other");
1465 break;
1466 case 1:
1467 seq_printf(seq, "Planar logic Board");
1468 break;
1469 case 2:
1470 seq_printf(seq, "CPU");
1471 break;
1472 case 3:
1473 seq_printf(seq, "Chassis");
1474 break;
1475 case 4:
1476 seq_printf(seq, "Power Supply");
1477 break;
1478 case 5:
1479 seq_printf(seq, "Storage");
1480 break;
1481 case 6:
1482 seq_printf(seq, "External");
1483 break;
1484 }
1485 seq_printf(seq, "\n");
1486
1487 seq_printf(seq, "Component instance : %d\n",
1488 result.component_instance);
1489 seq_printf(seq, "Sensor class : %s\n",
1490 result.sensor_class ? "Analog" : "Digital");
1491
1492 seq_printf(seq, "Sensor type : %d = ", result.sensor_type);
1493 switch (result.sensor_type) {
1494 case 0:
1495 seq_printf(seq, "Other\n");
1496 break;
1497 case 1:
1498 seq_printf(seq, "Thermal\n");
1499 break;
1500 case 2:
1501 seq_printf(seq, "DC voltage (DC volts)\n");
1502 break;
1503 case 3:
1504 seq_printf(seq, "AC voltage (AC volts)\n");
1505 break;
1506 case 4:
1507 seq_printf(seq, "DC current (DC amps)\n");
1508 break;
1509 case 5:
1510 seq_printf(seq, "AC current (AC volts)\n");
1511 break;
1512 case 6:
1513 seq_printf(seq, "Door open\n");
1514 break;
1515 case 7:
1516 seq_printf(seq, "Fan operational\n");
1517 break;
1518 }
1519
1520 seq_printf(seq, "Scaling exponent : %d\n",
1521 result.scaling_exponent);
1522 seq_printf(seq, "Actual reading : %d\n", result.actual_reading);
1523 seq_printf(seq, "Minimum reading : %d\n", result.minimum_reading);
1524 seq_printf(seq, "Low2LowCat treshold : %d\n",
1525 result.low2lowcat_treshold);
1526 seq_printf(seq, "LowCat2Low treshold : %d\n",
1527 result.lowcat2low_treshold);
1528 seq_printf(seq, "LowWarn2Low treshold : %d\n",
1529 result.lowwarn2low_treshold);
1530 seq_printf(seq, "Low2LowWarn treshold : %d\n",
1531 result.low2lowwarn_treshold);
1532 seq_printf(seq, "Norm2LowWarn treshold : %d\n",
1533 result.norm2lowwarn_treshold);
1534 seq_printf(seq, "LowWarn2Norm treshold : %d\n",
1535 result.lowwarn2norm_treshold);
1536 seq_printf(seq, "Nominal reading : %d\n", result.nominal_reading);
1537 seq_printf(seq, "HiWarn2Norm treshold : %d\n",
1538 result.hiwarn2norm_treshold);
1539 seq_printf(seq, "Norm2HiWarn treshold : %d\n",
1540 result.norm2hiwarn_treshold);
1541 seq_printf(seq, "High2HiWarn treshold : %d\n",
1542 result.high2hiwarn_treshold);
1543 seq_printf(seq, "HiWarn2High treshold : %d\n",
1544 result.hiwarn2high_treshold);
1545 seq_printf(seq, "HiCat2High treshold : %d\n",
1546 result.hicat2high_treshold);
1547 seq_printf(seq, "High2HiCat treshold : %d\n",
1548 result.hi2hicat_treshold);
1549 seq_printf(seq, "Maximum reading : %d\n", result.maximum_reading);
1550
1551 seq_printf(seq, "Sensor state : %d = ", result.sensor_state);
1552 switch (result.sensor_state) {
1553 case 0:
1554 seq_printf(seq, "Normal\n");
1555 break;
1556 case 1:
1557 seq_printf(seq, "Abnormal\n");
1558 break;
1559 case 2:
1560 seq_printf(seq, "Unknown\n");
1561 break;
1562 case 3:
1563 seq_printf(seq, "Low Catastrophic (LoCat)\n");
1564 break;
1565 case 4:
1566 seq_printf(seq, "Low (Low)\n");
1567 break;
1568 case 5:
1569 seq_printf(seq, "Low Warning (LoWarn)\n");
1570 break;
1571 case 6:
1572 seq_printf(seq, "High Warning (HiWarn)\n");
1573 break;
1574 case 7:
1575 seq_printf(seq, "High (High)\n");
1576 break;
1577 case 8:
1578 seq_printf(seq, "High Catastrophic (HiCat)\n");
1579 break;
1580 }
1581
1582 seq_printf(seq, "Event_enable : 0x%02X\n", result.event_enable);
1583 seq_printf(seq, " [%s] Operational state change. \n",
1584 (result.event_enable & 0x01) ? "+" : "-");
1585 seq_printf(seq, " [%s] Low catastrophic. \n",
1586 (result.event_enable & 0x02) ? "+" : "-");
1587 seq_printf(seq, " [%s] Low reading. \n",
1588 (result.event_enable & 0x04) ? "+" : "-");
1589 seq_printf(seq, " [%s] Low warning. \n",
1590 (result.event_enable & 0x08) ? "+" : "-");
1591 seq_printf(seq,
1592 " [%s] Change back to normal from out of range state. \n",
1593 (result.event_enable & 0x10) ? "+" : "-");
1594 seq_printf(seq, " [%s] High warning. \n",
1595 (result.event_enable & 0x20) ? "+" : "-");
1596 seq_printf(seq, " [%s] High reading. \n",
1597 (result.event_enable & 0x40) ? "+" : "-");
1598 seq_printf(seq, " [%s] High catastrophic. \n",
1599 (result.event_enable & 0x80) ? "+" : "-");
1600
1601 return 0;
1602}
1603
1604static int i2o_seq_open_hrt(struct inode *inode, struct file *file)
1605{
d9dda78b 1606 return single_open(file, i2o_seq_show_hrt, PDE_DATA(inode));
1da177e4
LT
1607};
1608
1609static int i2o_seq_open_lct(struct inode *inode, struct file *file)
1610{
d9dda78b 1611 return single_open(file, i2o_seq_show_lct, PDE_DATA(inode));
1da177e4
LT
1612};
1613
1614static int i2o_seq_open_status(struct inode *inode, struct file *file)
1615{
d9dda78b 1616 return single_open(file, i2o_seq_show_status, PDE_DATA(inode));
1da177e4
LT
1617};
1618
1619static int i2o_seq_open_hw(struct inode *inode, struct file *file)
1620{
d9dda78b 1621 return single_open(file, i2o_seq_show_hw, PDE_DATA(inode));
1da177e4
LT
1622};
1623
1624static int i2o_seq_open_ddm_table(struct inode *inode, struct file *file)
1625{
d9dda78b 1626 return single_open(file, i2o_seq_show_ddm_table, PDE_DATA(inode));
1da177e4
LT
1627};
1628
1629static int i2o_seq_open_driver_store(struct inode *inode, struct file *file)
1630{
d9dda78b 1631 return single_open(file, i2o_seq_show_driver_store, PDE_DATA(inode));
1da177e4
LT
1632};
1633
1634static int i2o_seq_open_drivers_stored(struct inode *inode, struct file *file)
1635{
d9dda78b 1636 return single_open(file, i2o_seq_show_drivers_stored, PDE_DATA(inode));
1da177e4
LT
1637};
1638
1639static int i2o_seq_open_groups(struct inode *inode, struct file *file)
1640{
d9dda78b 1641 return single_open(file, i2o_seq_show_groups, PDE_DATA(inode));
1da177e4
LT
1642};
1643
1644static int i2o_seq_open_phys_device(struct inode *inode, struct file *file)
1645{
d9dda78b 1646 return single_open(file, i2o_seq_show_phys_device, PDE_DATA(inode));
1da177e4
LT
1647};
1648
1649static int i2o_seq_open_claimed(struct inode *inode, struct file *file)
1650{
d9dda78b 1651 return single_open(file, i2o_seq_show_claimed, PDE_DATA(inode));
1da177e4
LT
1652};
1653
1654static int i2o_seq_open_users(struct inode *inode, struct file *file)
1655{
d9dda78b 1656 return single_open(file, i2o_seq_show_users, PDE_DATA(inode));
1da177e4
LT
1657};
1658
1659static int i2o_seq_open_priv_msgs(struct inode *inode, struct file *file)
1660{
d9dda78b 1661 return single_open(file, i2o_seq_show_priv_msgs, PDE_DATA(inode));
1da177e4
LT
1662};
1663
1664static int i2o_seq_open_authorized_users(struct inode *inode, struct file *file)
1665{
1666 return single_open(file, i2o_seq_show_authorized_users,
d9dda78b 1667 PDE_DATA(inode));
1da177e4
LT
1668};
1669
1670static int i2o_seq_open_dev_identity(struct inode *inode, struct file *file)
1671{
d9dda78b 1672 return single_open(file, i2o_seq_show_dev_identity, PDE_DATA(inode));
1da177e4
LT
1673};
1674
1675static int i2o_seq_open_ddm_identity(struct inode *inode, struct file *file)
1676{
d9dda78b 1677 return single_open(file, i2o_seq_show_ddm_identity, PDE_DATA(inode));
1da177e4
LT
1678};
1679
1680static int i2o_seq_open_uinfo(struct inode *inode, struct file *file)
1681{
d9dda78b 1682 return single_open(file, i2o_seq_show_uinfo, PDE_DATA(inode));
1da177e4
LT
1683};
1684
1685static int i2o_seq_open_sgl_limits(struct inode *inode, struct file *file)
1686{
d9dda78b 1687 return single_open(file, i2o_seq_show_sgl_limits, PDE_DATA(inode));
1da177e4
LT
1688};
1689
1690static int i2o_seq_open_sensors(struct inode *inode, struct file *file)
1691{
d9dda78b 1692 return single_open(file, i2o_seq_show_sensors, PDE_DATA(inode));
1da177e4
LT
1693};
1694
1695static int i2o_seq_open_dev_name(struct inode *inode, struct file *file)
1696{
d9dda78b 1697 return single_open(file, i2o_seq_show_dev_name, PDE_DATA(inode));
1da177e4
LT
1698};
1699
d54b1fdb 1700static const struct file_operations i2o_seq_fops_lct = {
1da177e4
LT
1701 .open = i2o_seq_open_lct,
1702 .read = seq_read,
1703 .llseek = seq_lseek,
1704 .release = single_release,
1705};
1706
d54b1fdb 1707static const struct file_operations i2o_seq_fops_hrt = {
1da177e4
LT
1708 .open = i2o_seq_open_hrt,
1709 .read = seq_read,
1710 .llseek = seq_lseek,
1711 .release = single_release,
1712};
1713
d54b1fdb 1714static const struct file_operations i2o_seq_fops_status = {
1da177e4
LT
1715 .open = i2o_seq_open_status,
1716 .read = seq_read,
1717 .llseek = seq_lseek,
1718 .release = single_release,
1719};
1720
d54b1fdb 1721static const struct file_operations i2o_seq_fops_hw = {
1da177e4
LT
1722 .open = i2o_seq_open_hw,
1723 .read = seq_read,
1724 .llseek = seq_lseek,
1725 .release = single_release,
1726};
1727
d54b1fdb 1728static const struct file_operations i2o_seq_fops_ddm_table = {
1da177e4
LT
1729 .open = i2o_seq_open_ddm_table,
1730 .read = seq_read,
1731 .llseek = seq_lseek,
1732 .release = single_release,
1733};
1734
d54b1fdb 1735static const struct file_operations i2o_seq_fops_driver_store = {
1da177e4
LT
1736 .open = i2o_seq_open_driver_store,
1737 .read = seq_read,
1738 .llseek = seq_lseek,
1739 .release = single_release,
1740};
1741
d54b1fdb 1742static const struct file_operations i2o_seq_fops_drivers_stored = {
1da177e4
LT
1743 .open = i2o_seq_open_drivers_stored,
1744 .read = seq_read,
1745 .llseek = seq_lseek,
1746 .release = single_release,
1747};
1748
d54b1fdb 1749static const struct file_operations i2o_seq_fops_groups = {
1da177e4
LT
1750 .open = i2o_seq_open_groups,
1751 .read = seq_read,
1752 .llseek = seq_lseek,
1753 .release = single_release,
1754};
1755
d54b1fdb 1756static const struct file_operations i2o_seq_fops_phys_device = {
1da177e4
LT
1757 .open = i2o_seq_open_phys_device,
1758 .read = seq_read,
1759 .llseek = seq_lseek,
1760 .release = single_release,
1761};
1762
d54b1fdb 1763static const struct file_operations i2o_seq_fops_claimed = {
1da177e4
LT
1764 .open = i2o_seq_open_claimed,
1765 .read = seq_read,
1766 .llseek = seq_lseek,
1767 .release = single_release,
1768};
1769
d54b1fdb 1770static const struct file_operations i2o_seq_fops_users = {
1da177e4
LT
1771 .open = i2o_seq_open_users,
1772 .read = seq_read,
1773 .llseek = seq_lseek,
1774 .release = single_release,
1775};
1776
d54b1fdb 1777static const struct file_operations i2o_seq_fops_priv_msgs = {
1da177e4
LT
1778 .open = i2o_seq_open_priv_msgs,
1779 .read = seq_read,
1780 .llseek = seq_lseek,
1781 .release = single_release,
1782};
1783
d54b1fdb 1784static const struct file_operations i2o_seq_fops_authorized_users = {
1da177e4
LT
1785 .open = i2o_seq_open_authorized_users,
1786 .read = seq_read,
1787 .llseek = seq_lseek,
1788 .release = single_release,
1789};
1790
d54b1fdb 1791static const struct file_operations i2o_seq_fops_dev_name = {
1da177e4
LT
1792 .open = i2o_seq_open_dev_name,
1793 .read = seq_read,
1794 .llseek = seq_lseek,
1795 .release = single_release,
1796};
1797
d54b1fdb 1798static const struct file_operations i2o_seq_fops_dev_identity = {
1da177e4
LT
1799 .open = i2o_seq_open_dev_identity,
1800 .read = seq_read,
1801 .llseek = seq_lseek,
1802 .release = single_release,
1803};
1804
d54b1fdb 1805static const struct file_operations i2o_seq_fops_ddm_identity = {
1da177e4
LT
1806 .open = i2o_seq_open_ddm_identity,
1807 .read = seq_read,
1808 .llseek = seq_lseek,
1809 .release = single_release,
1810};
1811
d54b1fdb 1812static const struct file_operations i2o_seq_fops_uinfo = {
1da177e4
LT
1813 .open = i2o_seq_open_uinfo,
1814 .read = seq_read,
1815 .llseek = seq_lseek,
1816 .release = single_release,
1817};
1818
d54b1fdb 1819static const struct file_operations i2o_seq_fops_sgl_limits = {
1da177e4
LT
1820 .open = i2o_seq_open_sgl_limits,
1821 .read = seq_read,
1822 .llseek = seq_lseek,
1823 .release = single_release,
1824};
1825
d54b1fdb 1826static const struct file_operations i2o_seq_fops_sensors = {
1da177e4
LT
1827 .open = i2o_seq_open_sensors,
1828 .read = seq_read,
1829 .llseek = seq_lseek,
1830 .release = single_release,
1831};
1832
1833/*
1834 * IOP specific entries...write field just in case someone
1835 * ever wants one.
1836 */
1837static i2o_proc_entry i2o_proc_generic_iop_entries[] = {
1838 {"hrt", S_IFREG | S_IRUGO, &i2o_seq_fops_hrt},
1839 {"lct", S_IFREG | S_IRUGO, &i2o_seq_fops_lct},
1840 {"status", S_IFREG | S_IRUGO, &i2o_seq_fops_status},
1841 {"hw", S_IFREG | S_IRUGO, &i2o_seq_fops_hw},
1842 {"ddm_table", S_IFREG | S_IRUGO, &i2o_seq_fops_ddm_table},
1843 {"driver_store", S_IFREG | S_IRUGO, &i2o_seq_fops_driver_store},
1844 {"drivers_stored", S_IFREG | S_IRUGO, &i2o_seq_fops_drivers_stored},
1845 {NULL, 0, NULL}
1846};
1847
1848/*
1849 * Device specific entries
1850 */
1851static i2o_proc_entry generic_dev_entries[] = {
1852 {"groups", S_IFREG | S_IRUGO, &i2o_seq_fops_groups},
1853 {"phys_dev", S_IFREG | S_IRUGO, &i2o_seq_fops_phys_device},
1854 {"claimed", S_IFREG | S_IRUGO, &i2o_seq_fops_claimed},
1855 {"users", S_IFREG | S_IRUGO, &i2o_seq_fops_users},
1856 {"priv_msgs", S_IFREG | S_IRUGO, &i2o_seq_fops_priv_msgs},
1857 {"authorized_users", S_IFREG | S_IRUGO, &i2o_seq_fops_authorized_users},
1858 {"dev_identity", S_IFREG | S_IRUGO, &i2o_seq_fops_dev_identity},
1859 {"ddm_identity", S_IFREG | S_IRUGO, &i2o_seq_fops_ddm_identity},
1860 {"user_info", S_IFREG | S_IRUGO, &i2o_seq_fops_uinfo},
1861 {"sgl_limits", S_IFREG | S_IRUGO, &i2o_seq_fops_sgl_limits},
1862 {"sensors", S_IFREG | S_IRUGO, &i2o_seq_fops_sensors},
1863 {NULL, 0, NULL}
1864};
1865
1866/*
1867 * Storage unit specific entries (SCSI Periph, BS) with device names
1868 */
1869static i2o_proc_entry rbs_dev_entries[] = {
1870 {"dev_name", S_IFREG | S_IRUGO, &i2o_seq_fops_dev_name},
1871 {NULL, 0, NULL}
1872};
1873
1874/**
1875 * i2o_proc_create_entries - Creates proc dir entries
1876 * @dir: proc dir entry under which the entries should be placed
1877 * @i2o_pe: pointer to the entries which should be added
1878 * @data: pointer to I2O controller or device
1879 *
1880 * Create proc dir entries for a I2O controller or I2O device.
1881 *
1882 * Returns 0 on success or negative error code on failure.
1883 */
1884static int i2o_proc_create_entries(struct proc_dir_entry *dir,
1885 i2o_proc_entry * i2o_pe, void *data)
1886{
1887 struct proc_dir_entry *tmp;
1888
1889 while (i2o_pe->name) {
c7705f34
DL
1890 tmp = proc_create_data(i2o_pe->name, i2o_pe->mode, dir,
1891 i2o_pe->fops, data);
1da177e4
LT
1892 if (!tmp)
1893 return -1;
1894
1da177e4
LT
1895 i2o_pe++;
1896 }
1897
1898 return 0;
1899}
1900
1da177e4
LT
1901/**
1902 * i2o_proc_device_add - Add an I2O device to the proc dir
1903 * @dir: proc dir entry to which the device should be added
1904 * @dev: I2O device which should be added
1905 *
1906 * Add an I2O device to the proc dir entry dir and create the entries for
1907 * the device depending on the class of the I2O device.
1908 */
1909static void i2o_proc_device_add(struct proc_dir_entry *dir,
1910 struct i2o_device *dev)
1911{
1912 char buff[10];
1913 struct proc_dir_entry *devdir;
1914 i2o_proc_entry *i2o_pe = NULL;
1915
1916 sprintf(buff, "%03x", dev->lct_data.tid);
1917
1918 osm_debug("adding device /proc/i2o/%s/%s\n", dev->iop->name, buff);
1919
270b5ac2 1920 devdir = proc_mkdir_data(buff, 0, dir, dev);
1da177e4
LT
1921 if (!devdir) {
1922 osm_warn("Could not allocate procdir!\n");
1923 return;
1924 }
1925
1da177e4
LT
1926 i2o_proc_create_entries(devdir, generic_dev_entries, dev);
1927
1928 /* Inform core that we want updates about this device's status */
1929 switch (dev->lct_data.class_id) {
1930 case I2O_CLASS_SCSI_PERIPHERAL:
1931 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
1932 i2o_pe = rbs_dev_entries;
1933 break;
1934 default:
1935 break;
1936 }
1937 if (i2o_pe)
1938 i2o_proc_create_entries(devdir, i2o_pe, dev);
1939}
1940
1941/**
1942 * i2o_proc_iop_add - Add an I2O controller to the i2o proc tree
1943 * @dir: parent proc dir entry
1944 * @c: I2O controller which should be added
1945 *
1946 * Add the entries to the parent proc dir entry. Also each device is added
1947 * to the controllers proc dir entry.
1948 *
1949 * Returns 0 on success or negative error code on failure.
1950 */
1951static int i2o_proc_iop_add(struct proc_dir_entry *dir,
1952 struct i2o_controller *c)
1953{
1954 struct proc_dir_entry *iopdir;
1955 struct i2o_device *dev;
1956
1957 osm_debug("adding IOP /proc/i2o/%s\n", c->name);
1958
270b5ac2 1959 iopdir = proc_mkdir_data(c->name, 0, dir, c);
1da177e4
LT
1960 if (!iopdir)
1961 return -1;
1962
1da177e4
LT
1963 i2o_proc_create_entries(iopdir, i2o_proc_generic_iop_entries, c);
1964
1965 list_for_each_entry(dev, &c->devices, list)
1966 i2o_proc_device_add(iopdir, dev);
1967
1968 return 0;
1969}
1970
1da177e4
LT
1971/**
1972 * i2o_proc_fs_create - Create the i2o proc fs.
1973 *
1974 * Iterate over each I2O controller and create the entries for it.
1975 *
1976 * Returns 0 on success or negative error code on failure.
1977 */
1978static int __init i2o_proc_fs_create(void)
1979{
1980 struct i2o_controller *c;
1981
1982 i2o_proc_dir_root = proc_mkdir("i2o", NULL);
1983 if (!i2o_proc_dir_root)
1984 return -1;
1985
1da177e4
LT
1986 list_for_each_entry(c, &i2o_controllers, list)
1987 i2o_proc_iop_add(i2o_proc_dir_root, c);
1988
1989 return 0;
1990};
1991
1992/**
1993 * i2o_proc_fs_destroy - Cleanup the all i2o proc entries
1994 *
1995 * Iterate over each I2O controller and remove the entries for it.
1996 *
1997 * Returns 0 on success or negative error code on failure.
1998 */
1999static int __exit i2o_proc_fs_destroy(void)
2000{
21ba37c9 2001 remove_proc_subtree("i2o", NULL);
1da177e4
LT
2002
2003 return 0;
2004};
2005
2006/**
2007 * i2o_proc_init - Init function for procfs
2008 *
2009 * Registers Proc OSM and creates procfs entries.
2010 *
2011 * Returns 0 on success or negative error code on failure.
2012 */
2013static int __init i2o_proc_init(void)
2014{
2015 int rc;
2016
2017 printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
2018
2019 rc = i2o_driver_register(&i2o_proc_driver);
2020 if (rc)
2021 return rc;
2022
2023 rc = i2o_proc_fs_create();
2024 if (rc) {
2025 i2o_driver_unregister(&i2o_proc_driver);
2026 return rc;
2027 }
2028
2029 return 0;
2030};
2031
2032/**
2033 * i2o_proc_exit - Exit function for procfs
2034 *
2035 * Unregisters Proc OSM and removes procfs entries.
2036 */
2037static void __exit i2o_proc_exit(void)
2038{
2039 i2o_driver_unregister(&i2o_proc_driver);
2040 i2o_proc_fs_destroy();
2041};
2042
2043MODULE_AUTHOR("Deepak Saxena");
2044MODULE_LICENSE("GPL");
2045MODULE_DESCRIPTION(OSM_DESCRIPTION);
2046MODULE_VERSION(OSM_VERSION);
2047
2048module_init(i2o_proc_init);
2049module_exit(i2o_proc_exit);
This page took 0.870013 seconds and 5 git commands to generate.