aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSreekanth Reddy <sreekanth.reddy@avagotech.com>2015-11-11 07:00:19 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2015-11-11 18:20:02 -0500
commit7497392a1193ea5b32d8a8a2b8d77888e7fe8221 (patch)
treec8674fc015b249d1495c4bd8b058b95b2fac5702
parent8a7e4c24e08fceb94887eb6d8123d6059dc5ddcd (diff)
mpt3sas: Move Gen3 HBA's device registration to a separate file
Created a mpt3sas_module.c file for mpt3sas driver where it can register SAS3 HBA devices with PCI, SML, IOCTL subsystems. Also removed the corresponding interfaces from mpt3sas_scsih.c file. Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com> Acked-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/mpt3sas/Makefile3
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_base.h4
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_ctl.c21
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_module.c252
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_scsih.c140
5 files changed, 261 insertions, 159 deletions
diff --git a/drivers/scsi/mpt3sas/Makefile b/drivers/scsi/mpt3sas/Makefile
index efb0c4c2e310..188057f69a92 100644
--- a/drivers/scsi/mpt3sas/Makefile
+++ b/drivers/scsi/mpt3sas/Makefile
@@ -5,4 +5,5 @@ mpt3sas-y += mpt3sas_base.o \
5 mpt3sas_scsih.o \ 5 mpt3sas_scsih.o \
6 mpt3sas_transport.o \ 6 mpt3sas_transport.o \
7 mpt3sas_ctl.o \ 7 mpt3sas_ctl.o \
8 mpt3sas_trigger_diag.o 8 mpt3sas_trigger_diag.o \
9 mpt3sas_module.o
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 699cf720b51b..0f86729fcf25 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -1084,6 +1084,7 @@ int mpt3sas_port_enable(struct MPT3SAS_ADAPTER *ioc);
1084 1084
1085 1085
1086/* scsih shared API */ 1086/* scsih shared API */
1087extern struct raid_template *mpt3sas_raid_template;
1087u8 mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index, 1088u8 mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
1088 u32 reply); 1089 u32 reply);
1089void mpt3sas_scsih_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase); 1090void mpt3sas_scsih_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase);
@@ -1108,7 +1109,7 @@ void mpt3sas_port_enable_complete(struct MPT3SAS_ADAPTER *ioc);
1108 1109
1109void scsih_exit(void); 1110void scsih_exit(void);
1110int scsih_init(void); 1111int scsih_init(void);
1111int scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id); 1112int scsih_probe(struct pci_dev *pdev, struct Scsi_Host *shost);
1112void scsih_remove(struct pci_dev *pdev); 1113void scsih_remove(struct pci_dev *pdev);
1113void scsih_shutdown(struct pci_dev *pdev); 1114void scsih_shutdown(struct pci_dev *pdev);
1114pci_ers_result_t scsih_pci_error_detected(struct pci_dev *pdev, 1115pci_ers_result_t scsih_pci_error_detected(struct pci_dev *pdev,
@@ -1241,6 +1242,7 @@ int mpt3sas_send_diag_release(struct MPT3SAS_ADAPTER *ioc, u8 buffer_type,
1241 u8 *issue_reset); 1242 u8 *issue_reset);
1242 1243
1243/* transport shared API */ 1244/* transport shared API */
1245extern struct scsi_transport_template *mpt3sas_transport_template;
1244u8 mpt3sas_transport_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, 1246u8 mpt3sas_transport_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1245 u32 reply); 1247 u32 reply);
1246struct _sas_port *mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc, 1248struct _sas_port *mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc,
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index e72a16c02eaf..ffe79829de30 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -3218,22 +3218,6 @@ struct device_attribute *mpt3sas_dev_attrs[] = {
3218 NULL, 3218 NULL,
3219}; 3219};
3220 3220
3221static const struct file_operations ctl_fops = {
3222 .owner = THIS_MODULE,
3223 .unlocked_ioctl = ctl_ioctl,
3224 .poll = ctl_poll,
3225 .fasync = ctl_fasync,
3226#ifdef CONFIG_COMPAT
3227 .compat_ioctl = ctl_ioctl_compat,
3228#endif
3229};
3230
3231static struct miscdevice ctl_dev = {
3232 .minor = MPT3SAS_MINOR,
3233 .name = MPT3SAS_DEV_NAME,
3234 .fops = &ctl_fops,
3235};
3236
3237/** 3221/**
3238 * ctl_init - main entry point for ctl. 3222 * ctl_init - main entry point for ctl.
3239 * 3223 *
@@ -3242,10 +3226,6 @@ void
3242ctl_init(void) 3226ctl_init(void)
3243{ 3227{
3244 async_queue = NULL; 3228 async_queue = NULL;
3245 if (misc_register(&ctl_dev) < 0)
3246 pr_err("%s can't register misc device [minor=%d]\n",
3247 MPT3SAS_DRIVER_NAME, MPT3SAS_MINOR);
3248
3249 init_waitqueue_head(&ctl_poll_wait); 3229 init_waitqueue_head(&ctl_poll_wait);
3250} 3230}
3251 3231
@@ -3279,5 +3259,4 @@ ctl_exit(void)
3279 3259
3280 kfree(ioc->event_log); 3260 kfree(ioc->event_log);
3281 } 3261 }
3282 misc_deregister(&ctl_dev);
3283} 3262}
diff --git a/drivers/scsi/mpt3sas/mpt3sas_module.c b/drivers/scsi/mpt3sas/mpt3sas_module.c
new file mode 100644
index 000000000000..e5f43ba04c4b
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_module.c
@@ -0,0 +1,252 @@
1/*
2 * Scsi Host Layer for MPT (Message Passing Technology) based controllers
3 *
4 * Copyright (C) 2012-2014 LSI Corporation
5 * Copyright (C) 2013-2015 Avago Technologies
6 * (mailto: MPT-FusionLinux.pdl@avagotech.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * NO WARRANTY
19 * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
20 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
21 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
22 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
23 * solely responsible for determining the appropriateness of using and
24 * distributing the Program and assumes all risks associated with its
25 * exercise of rights under this Agreement, including but not limited to
26 * the risks and costs of program errors, damage to or loss of data,
27 * programs or equipment, and unavailability or interruption of operations.
28
29 * DISCLAIMER OF LIABILITY
30 * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
31 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
33 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
35 * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
36 * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
37
38 * You should have received a copy of the GNU General Public License
39 * along with this program.
40 */
41
42#include <linux/module.h>
43#include <linux/pci.h>
44#include <linux/raid_class.h>
45
46#include "mpt3sas_base.h"
47#include "mpt3sas_ctl.h"
48
49MODULE_AUTHOR(MPT3SAS_AUTHOR);
50MODULE_DESCRIPTION(MPT3SAS_DESCRIPTION);
51MODULE_LICENSE("GPL");
52MODULE_VERSION(MPT3SAS_DRIVER_VERSION);
53
54/* shost template */
55static struct scsi_host_template mpt3sas_driver_template = {
56 .module = THIS_MODULE,
57 .name = "Fusion MPT SAS Host",
58 .proc_name = MPT3SAS_DRIVER_NAME,
59 .queuecommand = scsih_qcmd,
60 .target_alloc = scsih_target_alloc,
61 .slave_alloc = scsih_slave_alloc,
62 .slave_configure = scsih_slave_configure,
63 .target_destroy = scsih_target_destroy,
64 .slave_destroy = scsih_slave_destroy,
65 .scan_finished = scsih_scan_finished,
66 .scan_start = scsih_scan_start,
67 .change_queue_depth = scsih_change_queue_depth,
68 .eh_abort_handler = scsih_abort,
69 .eh_device_reset_handler = scsih_dev_reset,
70 .eh_target_reset_handler = scsih_target_reset,
71 .eh_host_reset_handler = scsih_host_reset,
72 .bios_param = scsih_bios_param,
73 .can_queue = 1,
74 .this_id = -1,
75 .sg_tablesize = MPT3SAS_SG_DEPTH,
76 .max_sectors = 32767,
77 .cmd_per_lun = 7,
78 .use_clustering = ENABLE_CLUSTERING,
79 .shost_attrs = mpt3sas_host_attrs,
80 .sdev_attrs = mpt3sas_dev_attrs,
81 .track_queue_depth = 1,
82};
83
84/* raid transport support */
85static struct raid_function_template mpt3sas_raid_functions = {
86 .cookie = &mpt3sas_driver_template,
87 .is_raid = scsih_is_raid,
88 .get_resync = scsih_get_resync,
89 .get_state = scsih_get_state,
90};
91
92/*
93 * The pci device ids are defined in mpi/mpi2_cnfg.h.
94 */
95static const struct pci_device_id mpt3sas_pci_table[] = {
96 { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3004,
97 PCI_ANY_ID, PCI_ANY_ID },
98 { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3008,
99 PCI_ANY_ID, PCI_ANY_ID },
100 /* Invader ~ 3108 */
101 { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_1,
102 PCI_ANY_ID, PCI_ANY_ID },
103 { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_2,
104 PCI_ANY_ID, PCI_ANY_ID },
105 { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_5,
106 PCI_ANY_ID, PCI_ANY_ID },
107 { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_6,
108 PCI_ANY_ID, PCI_ANY_ID },
109 {0} /* Terminating entry */
110};
111MODULE_DEVICE_TABLE(pci, mpt3sas_pci_table);
112
113static const struct file_operations mpt3sas_ctl_fops = {
114 .owner = THIS_MODULE,
115 .unlocked_ioctl = ctl_ioctl,
116 .poll = ctl_poll,
117 .fasync = ctl_fasync,
118#ifdef CONFIG_COMPAT
119 .compat_ioctl = ctl_ioctl_compat,
120#endif
121};
122
123static struct miscdevice mpt3sas_ctl_dev = {
124 .minor = MPT3SAS_MINOR,
125 .name = MPT3SAS_DEV_NAME,
126 .fops = &mpt3sas_ctl_fops,
127};
128
129/**
130 * mpt3sas_ctl_init - main entry point for ctl.
131 *
132 */
133void
134mpt3sas_ctl_init(void)
135{
136 ctl_init();
137 if (misc_register(&mpt3sas_ctl_dev) < 0)
138 pr_err("%s can't register misc device [minor=%d]\n",
139 MPT3SAS_DRIVER_NAME, MPT3SAS_MINOR);
140}
141
142/**
143 * mpt3sas_ctl_exit - exit point for ctl
144 *
145 */
146void
147mpt3sas_ctl_exit(void)
148{
149 ctl_exit();
150 misc_deregister(&mpt3sas_ctl_dev);
151}
152
153/**
154 * _mpt3sas_probe - attach and add scsi host
155 * @pdev: PCI device struct
156 * @id: pci device id
157 *
158 * Returns 0 success, anything else error.
159 */
160static int
161_mpt3sas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
162{
163 struct Scsi_Host *shost;
164 int rv;
165
166 shost = scsi_host_alloc(&mpt3sas_driver_template,
167 sizeof(struct MPT3SAS_ADAPTER));
168 if (!shost)
169 return -ENODEV;
170
171 rv = scsih_probe(pdev, shost);
172 return rv;
173}
174
175static struct pci_error_handlers _mpt3sas_err_handler = {
176 .error_detected = scsih_pci_error_detected,
177 .mmio_enabled = scsih_pci_mmio_enabled,
178 .slot_reset = scsih_pci_slot_reset,
179 .resume = scsih_pci_resume,
180};
181
182static struct pci_driver mpt3sas_driver = {
183 .name = MPT3SAS_DRIVER_NAME,
184 .id_table = mpt3sas_pci_table,
185 .probe = _mpt3sas_probe,
186 .remove = scsih_remove,
187 .shutdown = scsih_shutdown,
188 .err_handler = &_mpt3sas_err_handler,
189#ifdef CONFIG_PM
190 .suspend = scsih_suspend,
191 .resume = scsih_resume,
192#endif
193};
194
195/**
196 * _mpt3sas_init - main entry point for this driver.
197 *
198 * Returns 0 success, anything else error.
199 */
200static int __init
201_mpt3sas_init(void)
202{
203 int error;
204
205 pr_info("%s version %s loaded\n", MPT3SAS_DRIVER_NAME,
206 MPT3SAS_DRIVER_VERSION);
207
208 mpt3sas_transport_template =
209 sas_attach_transport(&mpt3sas_transport_functions);
210 if (!mpt3sas_transport_template)
211 return -ENODEV;
212
213 mpt3sas_raid_template = raid_class_attach(&mpt3sas_raid_functions);
214 if (!mpt3sas_raid_template) {
215 sas_release_transport(mpt3sas_transport_template);
216 return -ENODEV;
217 }
218
219 error = scsih_init();
220 if (error) {
221 scsih_exit();
222 return error;
223 }
224
225 mpt3sas_ctl_init();
226
227 error = pci_register_driver(&mpt3sas_driver);
228 if (error)
229 scsih_exit();
230
231 return error;
232}
233
234/**
235 * _mpt3sas_exit - exit point for this driver (when it is a module).
236 *
237 */
238static void __exit
239_mpt3sas_exit(void)
240{
241 pr_info("mpt3sas version %s unloading\n",
242 MPT3SAS_DRIVER_VERSION);
243
244 pci_unregister_driver(&mpt3sas_driver);
245
246 mpt3sas_ctl_exit();
247
248 scsih_exit();
249}
250
251module_init(_mpt3sas_init);
252module_exit(_mpt3sas_exit);
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 3353b487ab70..56726a0b37fb 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -57,11 +57,6 @@
57 57
58#include "mpt3sas_base.h" 58#include "mpt3sas_base.h"
59 59
60MODULE_AUTHOR(MPT3SAS_AUTHOR);
61MODULE_DESCRIPTION(MPT3SAS_DESCRIPTION);
62MODULE_LICENSE("GPL");
63MODULE_VERSION(MPT3SAS_DRIVER_VERSION);
64
65#define RAID_CHANNEL 1 60#define RAID_CHANNEL 1
66/* forward proto's */ 61/* forward proto's */
67static void _scsih_expander_node_remove(struct MPT3SAS_ADAPTER *ioc, 62static void _scsih_expander_node_remove(struct MPT3SAS_ADAPTER *ioc,
@@ -141,8 +136,7 @@ MODULE_PARM_DESC(prot_mask, " host protection capabilities mask, def=7 ");
141 136
142 137
143/* raid transport support */ 138/* raid transport support */
144 139struct raid_template *mpt3sas_raid_template;
145static struct raid_template *mpt3sas_raid_template;
146 140
147 141
148/** 142/**
@@ -192,9 +186,6 @@ struct fw_event_work {
192 char event_data[0] __aligned(4); 186 char event_data[0] __aligned(4);
193}; 187};
194 188
195/* raid transport support */
196static struct raid_template *mpt3sas_raid_template;
197
198/** 189/**
199 * struct _scsi_io_transfer - scsi io transfer 190 * struct _scsi_io_transfer - scsi io transfer
200 * @handle: sas device handle (assigned by firmware) 191 * @handle: sas device handle (assigned by firmware)
@@ -243,28 +234,6 @@ struct _scsi_io_transfer {
243 u32 transfer_length; 234 u32 transfer_length;
244}; 235};
245 236
246/*
247 * The pci device ids are defined in mpi/mpi2_cnfg.h.
248 */
249static const struct pci_device_id scsih_pci_table[] = {
250 /* Fury ~ 3004 and 3008 */
251 { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3004,
252 PCI_ANY_ID, PCI_ANY_ID },
253 { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3008,
254 PCI_ANY_ID, PCI_ANY_ID },
255 /* Invader ~ 3108 */
256 { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_1,
257 PCI_ANY_ID, PCI_ANY_ID },
258 { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_2,
259 PCI_ANY_ID, PCI_ANY_ID },
260 { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_5,
261 PCI_ANY_ID, PCI_ANY_ID },
262 { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_6,
263 PCI_ANY_ID, PCI_ANY_ID },
264 {0} /* Terminating entry */
265};
266MODULE_DEVICE_TABLE(pci, scsih_pci_table);
267
268/** 237/**
269 * _scsih_set_debug_level - global setting of ioc->logging_level. 238 * _scsih_set_debug_level - global setting of ioc->logging_level.
270 * 239 *
@@ -7486,36 +7455,6 @@ mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
7486 return 1; 7455 return 1;
7487} 7456}
7488 7457
7489/* shost template */
7490static struct scsi_host_template scsih_driver_template = {
7491 .module = THIS_MODULE,
7492 .name = "Fusion MPT SAS Host",
7493 .proc_name = MPT3SAS_DRIVER_NAME,
7494 .queuecommand = scsih_qcmd,
7495 .target_alloc = scsih_target_alloc,
7496 .slave_alloc = scsih_slave_alloc,
7497 .slave_configure = scsih_slave_configure,
7498 .target_destroy = scsih_target_destroy,
7499 .slave_destroy = scsih_slave_destroy,
7500 .scan_finished = scsih_scan_finished,
7501 .scan_start = scsih_scan_start,
7502 .change_queue_depth = scsih_change_queue_depth,
7503 .eh_abort_handler = scsih_abort,
7504 .eh_device_reset_handler = scsih_dev_reset,
7505 .eh_target_reset_handler = scsih_target_reset,
7506 .eh_host_reset_handler = scsih_host_reset,
7507 .bios_param = scsih_bios_param,
7508 .can_queue = 1,
7509 .this_id = -1,
7510 .sg_tablesize = MPT3SAS_SG_DEPTH,
7511 .max_sectors = 32767,
7512 .cmd_per_lun = 7,
7513 .use_clustering = ENABLE_CLUSTERING,
7514 .shost_attrs = mpt3sas_host_attrs,
7515 .sdev_attrs = mpt3sas_dev_attrs,
7516 .track_queue_depth = 1,
7517};
7518
7519/** 7458/**
7520 * _scsih_expander_node_remove - removing expander device from list. 7459 * _scsih_expander_node_remove - removing expander device from list.
7521 * @ioc: per adapter object 7460 * @ioc: per adapter object
@@ -7993,17 +7932,11 @@ scsih_scan_finished(struct Scsi_Host *shost, unsigned long time)
7993 * Returns 0 success, anything else error. 7932 * Returns 0 success, anything else error.
7994 */ 7933 */
7995int 7934int
7996scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) 7935scsih_probe(struct pci_dev *pdev, struct Scsi_Host *shost)
7997{ 7936{
7998 struct MPT3SAS_ADAPTER *ioc; 7937 struct MPT3SAS_ADAPTER *ioc;
7999 struct Scsi_Host *shost;
8000 int rv; 7938 int rv;
8001 7939
8002 shost = scsi_host_alloc(&scsih_driver_template,
8003 sizeof(struct MPT3SAS_ADAPTER));
8004 if (!shost)
8005 return -ENODEV;
8006
8007 /* init local params */ 7940 /* init local params */
8008 ioc = shost_priv(shost); 7941 ioc = shost_priv(shost);
8009 memset(ioc, 0, sizeof(struct MPT3SAS_ADAPTER)); 7942 memset(ioc, 0, sizeof(struct MPT3SAS_ADAPTER));
@@ -8298,35 +8231,6 @@ scsih_pci_mmio_enabled(struct pci_dev *pdev)
8298 return PCI_ERS_RESULT_NEED_RESET; 8231 return PCI_ERS_RESULT_NEED_RESET;
8299} 8232}
8300 8233
8301/* raid transport support */
8302static struct raid_function_template mpt3sas_raid_functions = {
8303 .cookie = &scsih_driver_template,
8304 .is_raid = scsih_is_raid,
8305 .get_resync = scsih_get_resync,
8306 .get_state = scsih_get_state,
8307};
8308
8309static struct pci_error_handlers _scsih_err_handler = {
8310 .error_detected = scsih_pci_error_detected,
8311 .mmio_enabled = scsih_pci_mmio_enabled,
8312 .slot_reset = scsih_pci_slot_reset,
8313 .resume = scsih_pci_resume,
8314};
8315
8316static struct pci_driver scsih_driver = {
8317 .name = MPT3SAS_DRIVER_NAME,
8318 .id_table = scsih_pci_table,
8319 .probe = scsih_probe,
8320 .remove = scsih_remove,
8321 .shutdown = scsih_shutdown,
8322 .err_handler = &_scsih_err_handler,
8323#ifdef CONFIG_PM
8324 .suspend = scsih_suspend,
8325 .resume = scsih_resume,
8326#endif
8327};
8328
8329
8330/** 8234/**
8331 * scsih_init - main entry point for this driver. 8235 * scsih_init - main entry point for this driver.
8332 * 8236 *
@@ -8335,25 +8239,8 @@ static struct pci_driver scsih_driver = {
8335int 8239int
8336scsih_init(void) 8240scsih_init(void)
8337{ 8241{
8338 int error;
8339
8340 mpt_ids = 0; 8242 mpt_ids = 0;
8341 8243
8342 pr_info("%s version %s loaded\n", MPT3SAS_DRIVER_NAME,
8343 MPT3SAS_DRIVER_VERSION);
8344
8345 mpt3sas_transport_template =
8346 sas_attach_transport(&mpt3sas_transport_functions);
8347 if (!mpt3sas_transport_template)
8348 return -ENODEV;
8349
8350/* raid transport support */
8351 mpt3sas_raid_template = raid_class_attach(&mpt3sas_raid_functions);
8352 if (!mpt3sas_raid_template) {
8353 sas_release_transport(mpt3sas_transport_template);
8354 return -ENODEV;
8355 }
8356
8357 mpt3sas_base_initialize_callback_handler(); 8244 mpt3sas_base_initialize_callback_handler();
8358 8245
8359 /* queuecommand callback hander */ 8246 /* queuecommand callback hander */
@@ -8390,33 +8277,17 @@ scsih_init(void)
8390 tm_sas_control_cb_idx = mpt3sas_base_register_callback_handler( 8277 tm_sas_control_cb_idx = mpt3sas_base_register_callback_handler(
8391 _scsih_sas_control_complete); 8278 _scsih_sas_control_complete);
8392 8279
8393 ctl_init(); 8280 return 0;
8394
8395 error = pci_register_driver(&scsih_driver);
8396 if (error) {
8397 /* raid transport support */
8398 raid_class_release(mpt3sas_raid_template);
8399 sas_release_transport(mpt3sas_transport_template);
8400 }
8401
8402 return error;
8403} 8281}
8404 8282
8405/** 8283/**
8406 * _scsih_exit - exit point for this driver (when it is a module). 8284 * scsih_exit - exit point for this driver (when it is a module).
8407 * 8285 *
8408 * Returns 0 success, anything else error. 8286 * Returns 0 success, anything else error.
8409 */ 8287 */
8410void 8288void
8411scsih_exit(void) 8289scsih_exit(void)
8412{ 8290{
8413 pr_info("mpt3sas version %s unloading\n",
8414 MPT3SAS_DRIVER_VERSION);
8415
8416 ctl_exit();
8417
8418 pci_unregister_driver(&scsih_driver);
8419
8420 8291
8421 mpt3sas_base_release_callback_handler(scsi_io_cb_idx); 8292 mpt3sas_base_release_callback_handler(scsi_io_cb_idx);
8422 mpt3sas_base_release_callback_handler(tm_cb_idx); 8293 mpt3sas_base_release_callback_handler(tm_cb_idx);
@@ -8435,6 +8306,3 @@ scsih_exit(void)
8435 raid_class_release(mpt3sas_raid_template); 8306 raid_class_release(mpt3sas_raid_template);
8436 sas_release_transport(mpt3sas_transport_template); 8307 sas_release_transport(mpt3sas_transport_template);
8437} 8308}
8438
8439module_init(scsih_init);
8440module_exit(scsih_exit);