File: /usr/src/linux/drivers/message/fusion/isense.c
1 /*
2 * linux/drivers/message/fusion/isense.c
3 * Little linux driver / shim that interfaces with the Fusion MPT
4 * Linux base driver to provide english readable strings in SCSI
5 * Error Report logging output. This module implements SCSI-3
6 * Opcode lookup and a sorted table of SCSI-3 ASC/ASCQ strings.
7 *
8 * Copyright (c) 1991-2001 Steven J. Ralston
9 * Written By: Steven J. Ralston
10 * (yes I wrote some of the orig. code back in 1991!)
11 * (mailto:Steve.Ralston@lsil.com)
12 *
13 * $Id: isense.c,v 1.28.14.1 2001/08/24 20:07:04 sralston Exp $
14 */
15 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
16 /*
17 This program is free software; you can redistribute it and/or modify
18 it under the terms of the GNU General Public License as published by
19 the Free Software Foundation; version 2 of the License.
20
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
25
26 NO WARRANTY
27 THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
28 CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
29 LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
30 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
31 solely responsible for determining the appropriateness of using and
32 distributing the Program and assumes all risks associated with its
33 exercise of rights under this Agreement, including but not limited to
34 the risks and costs of program errors, damage to or loss of data,
35 programs or equipment, and unavailability or interruption of operations.
36
37 DISCLAIMER OF LIABILITY
38 NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
39 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40 DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
41 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
42 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
43 USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
44 HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
45
46 You should have received a copy of the GNU General Public License
47 along with this program; if not, write to the Free Software
48 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
49 */
50 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
51
52 #include <linux/module.h>
53 #include <linux/kernel.h>
54 #include <linux/errno.h>
55 #include <linux/init.h>
56 #include <linux/version.h>
57
58 /* Hmmm, avoid undefined spinlock_t on lk-2.2.14-5.0 */
59 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
60 #include <asm/spinlock.h>
61 #endif
62
63 #define MODULEAUTHOR "Steven J. Ralston"
64 #define COPYRIGHT "Copyright (c) 2001 " MODULEAUTHOR
65 #include "mptbase.h"
66
67 #include "isense.h"
68
69 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
70 /*
71 * Private data...
72 */
73
74 /*
75 * YIKES! I don't usually #include C source files, but..
76 * The following #include's pulls in our needed ASCQ_Table[] array,
77 * ASCQ_TableSz integer, and ScsiOpcodeString[] array!
78 */
79 #include "ascq_tbl.c"
80 #include "scsiops.c"
81
82 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
83 #define my_NAME "SCSI-3 Opcodes & ASC/ASCQ Strings"
84 #define my_VERSION MPT_LINUX_VERSION_COMMON
85 #define MYNAM "isense"
86
87 EXPORT_NO_SYMBOLS;
88 MODULE_AUTHOR(MODULEAUTHOR);
89 MODULE_DESCRIPTION(my_NAME);
90
91 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
92 int __init isense_init(void)
93 {
94 show_mptmod_ver(my_NAME, my_VERSION);
95
96 /*
97 * Install our handler
98 */
99 if (mpt_register_ascqops_strings(&ASCQ_Table[0], ASCQ_TableSize, ScsiOpcodeString) != 1)
100 {
101 printk(KERN_ERR MYNAM ": ERROR: Can't register with Fusion MPT base driver!\n");
102 return -EBUSY;
103 }
104 printk(KERN_INFO MYNAM ": Registered SCSI-3 Opcodes & ASC/ASCQ Strings\n");
105 return 0;
106 }
107
108
109 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
110 static void isense_exit(void)
111 {
112 #ifdef MODULE
113 mpt_deregister_ascqops_strings();
114 #endif
115 printk(KERN_INFO MYNAM ": Deregistered SCSI-3 Opcodes & ASC/ASCQ Strings\n");
116 }
117
118 module_init(isense_init);
119 module_exit(isense_exit);
120
121 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
122
123