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