Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Basic HP/COMPAQ MSA 1000 support. This is only needed if your HW cannot be |
| 3 | * upgraded. |
| 4 | * |
| 5 | * Copyright (C) 2006 Red Hat, Inc. All rights reserved. |
| 6 | * Copyright (C) 2006 Mike Christie |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 7 | * Copyright (C) 2008 Hannes Reinecke <hare@suse.de> |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2, or (at your option) |
| 12 | * any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; see the file COPYING. If not, write to |
| 21 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 | */ |
| 23 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 24 | #include <linux/slab.h> |
Paul Gortmaker | acf3368f | 2011-05-27 09:47:43 -0400 | [diff] [blame] | 25 | #include <linux/module.h> |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 26 | #include <scsi/scsi.h> |
| 27 | #include <scsi/scsi_dbg.h> |
| 28 | #include <scsi/scsi_eh.h> |
| 29 | #include <scsi/scsi_dh.h> |
| 30 | |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 31 | #define HP_SW_NAME "hp_sw" |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 32 | |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 33 | #define HP_SW_TIMEOUT (60 * HZ) |
| 34 | #define HP_SW_RETRIES 3 |
| 35 | |
| 36 | #define HP_SW_PATH_UNINITIALIZED -1 |
| 37 | #define HP_SW_PATH_ACTIVE 0 |
| 38 | #define HP_SW_PATH_PASSIVE 1 |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 39 | |
| 40 | struct hp_sw_dh_data { |
Christoph Hellwig | cd37743 | 2014-09-13 19:59:51 -0700 | [diff] [blame] | 41 | struct scsi_dh_data dh_data; |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 42 | unsigned char sense[SCSI_SENSE_BUFFERSIZE]; |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 43 | int path_state; |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 44 | int retries; |
Chandra Seetharaman | 4e2ef86 | 2009-10-21 09:22:58 -0700 | [diff] [blame] | 45 | int retry_cnt; |
| 46 | struct scsi_device *sdev; |
| 47 | activate_complete callback_fn; |
| 48 | void *callback_data; |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
Chandra Seetharaman | 4e2ef86 | 2009-10-21 09:22:58 -0700 | [diff] [blame] | 51 | static int hp_sw_start_stop(struct hp_sw_dh_data *); |
| 52 | |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 53 | static inline struct hp_sw_dh_data *get_hp_sw_data(struct scsi_device *sdev) |
| 54 | { |
Christoph Hellwig | cd37743 | 2014-09-13 19:59:51 -0700 | [diff] [blame] | 55 | return container_of(sdev->scsi_dh_data, struct hp_sw_dh_data, dh_data); |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 58 | /* |
| 59 | * tur_done - Handle TEST UNIT READY return status |
| 60 | * @sdev: sdev the command has been sent to |
| 61 | * @errors: blk error code |
| 62 | * |
| 63 | * Returns SCSI_DH_DEV_OFFLINED if the sdev is on the passive path |
| 64 | */ |
| 65 | static int tur_done(struct scsi_device *sdev, unsigned char *sense) |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 66 | { |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 67 | struct scsi_sense_hdr sshdr; |
| 68 | int ret; |
| 69 | |
| 70 | ret = scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, &sshdr); |
| 71 | if (!ret) { |
| 72 | sdev_printk(KERN_WARNING, sdev, |
| 73 | "%s: sending tur failed, no sense available\n", |
| 74 | HP_SW_NAME); |
| 75 | ret = SCSI_DH_IO; |
| 76 | goto done; |
| 77 | } |
| 78 | switch (sshdr.sense_key) { |
| 79 | case UNIT_ATTENTION: |
| 80 | ret = SCSI_DH_IMM_RETRY; |
| 81 | break; |
| 82 | case NOT_READY: |
| 83 | if ((sshdr.asc == 0x04) && (sshdr.ascq == 2)) { |
| 84 | /* |
| 85 | * LUN not ready - Initialization command required |
| 86 | * |
| 87 | * This is the passive path |
| 88 | */ |
| 89 | ret = SCSI_DH_DEV_OFFLINED; |
| 90 | break; |
| 91 | } |
| 92 | /* Fallthrough */ |
| 93 | default: |
| 94 | sdev_printk(KERN_WARNING, sdev, |
| 95 | "%s: sending tur failed, sense %x/%x/%x\n", |
| 96 | HP_SW_NAME, sshdr.sense_key, sshdr.asc, |
| 97 | sshdr.ascq); |
| 98 | break; |
| 99 | } |
| 100 | |
| 101 | done: |
| 102 | return ret; |
| 103 | } |
| 104 | |
| 105 | /* |
| 106 | * hp_sw_tur - Send TEST UNIT READY |
| 107 | * @sdev: sdev command should be sent to |
| 108 | * |
| 109 | * Use the TEST UNIT READY command to determine |
| 110 | * the path state. |
| 111 | */ |
| 112 | static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h) |
| 113 | { |
| 114 | struct request *req; |
| 115 | int ret; |
| 116 | |
Alan D. Brunelle | febd7a5 | 2008-12-09 15:52:15 +0100 | [diff] [blame] | 117 | retry: |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 118 | req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO); |
Joe Lawrence | a492f07 | 2014-08-28 08:15:21 -0600 | [diff] [blame] | 119 | if (IS_ERR(req)) |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 120 | return SCSI_DH_RES_TEMP_UNAVAIL; |
| 121 | |
Jens Axboe | f27b087 | 2014-06-06 07:57:37 -0600 | [diff] [blame] | 122 | blk_rq_set_block_pc(req); |
Mike Christie | 6000a36 | 2008-08-19 18:45:30 -0500 | [diff] [blame] | 123 | req->cmd_flags |= REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | |
| 124 | REQ_FAILFAST_DRIVER; |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 125 | req->cmd_len = COMMAND_SIZE(TEST_UNIT_READY); |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 126 | req->cmd[0] = TEST_UNIT_READY; |
| 127 | req->timeout = HP_SW_TIMEOUT; |
| 128 | req->sense = h->sense; |
| 129 | memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE); |
| 130 | req->sense_len = 0; |
| 131 | |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 132 | ret = blk_execute_rq(req->q, NULL, req, 1); |
| 133 | if (ret == -EIO) { |
| 134 | if (req->sense_len > 0) { |
| 135 | ret = tur_done(sdev, h->sense); |
| 136 | } else { |
| 137 | sdev_printk(KERN_WARNING, sdev, |
| 138 | "%s: sending tur failed with %x\n", |
| 139 | HP_SW_NAME, req->errors); |
| 140 | ret = SCSI_DH_IO; |
| 141 | } |
| 142 | } else { |
| 143 | h->path_state = HP_SW_PATH_ACTIVE; |
| 144 | ret = SCSI_DH_OK; |
| 145 | } |
Alan D. Brunelle | febd7a5 | 2008-12-09 15:52:15 +0100 | [diff] [blame] | 146 | if (ret == SCSI_DH_IMM_RETRY) { |
| 147 | blk_put_request(req); |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 148 | goto retry; |
Alan D. Brunelle | febd7a5 | 2008-12-09 15:52:15 +0100 | [diff] [blame] | 149 | } |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 150 | if (ret == SCSI_DH_DEV_OFFLINED) { |
| 151 | h->path_state = HP_SW_PATH_PASSIVE; |
| 152 | ret = SCSI_DH_OK; |
| 153 | } |
| 154 | |
| 155 | blk_put_request(req); |
| 156 | |
| 157 | return ret; |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | * start_done - Handle START STOP UNIT return status |
| 162 | * @sdev: sdev the command has been sent to |
| 163 | * @errors: blk error code |
| 164 | */ |
| 165 | static int start_done(struct scsi_device *sdev, unsigned char *sense) |
| 166 | { |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 167 | struct scsi_sense_hdr sshdr; |
| 168 | int rc; |
| 169 | |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 170 | rc = scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, &sshdr); |
| 171 | if (!rc) { |
| 172 | sdev_printk(KERN_WARNING, sdev, |
| 173 | "%s: sending start_stop_unit failed, " |
| 174 | "no sense available\n", |
| 175 | HP_SW_NAME); |
| 176 | return SCSI_DH_IO; |
| 177 | } |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 178 | switch (sshdr.sense_key) { |
| 179 | case NOT_READY: |
| 180 | if ((sshdr.asc == 0x04) && (sshdr.ascq == 3)) { |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 181 | /* |
| 182 | * LUN not ready - manual intervention required |
| 183 | * |
| 184 | * Switch-over in progress, retry. |
| 185 | */ |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 186 | rc = SCSI_DH_RETRY; |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 187 | break; |
| 188 | } |
| 189 | /* fall through */ |
| 190 | default: |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 191 | sdev_printk(KERN_WARNING, sdev, |
| 192 | "%s: sending start_stop_unit failed, sense %x/%x/%x\n", |
| 193 | HP_SW_NAME, sshdr.sense_key, sshdr.asc, |
| 194 | sshdr.ascq); |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 195 | rc = SCSI_DH_IO; |
| 196 | } |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 197 | |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 198 | return rc; |
| 199 | } |
| 200 | |
Chandra Seetharaman | 4e2ef86 | 2009-10-21 09:22:58 -0700 | [diff] [blame] | 201 | static void start_stop_endio(struct request *req, int error) |
| 202 | { |
| 203 | struct hp_sw_dh_data *h = req->end_io_data; |
| 204 | unsigned err = SCSI_DH_OK; |
| 205 | |
| 206 | if (error || host_byte(req->errors) != DID_OK || |
| 207 | msg_byte(req->errors) != COMMAND_COMPLETE) { |
| 208 | sdev_printk(KERN_WARNING, h->sdev, |
| 209 | "%s: sending start_stop_unit failed with %x\n", |
| 210 | HP_SW_NAME, req->errors); |
| 211 | err = SCSI_DH_IO; |
| 212 | goto done; |
| 213 | } |
| 214 | |
| 215 | if (req->sense_len > 0) { |
| 216 | err = start_done(h->sdev, h->sense); |
| 217 | if (err == SCSI_DH_RETRY) { |
| 218 | err = SCSI_DH_IO; |
| 219 | if (--h->retry_cnt) { |
| 220 | blk_put_request(req); |
| 221 | err = hp_sw_start_stop(h); |
| 222 | if (err == SCSI_DH_OK) |
| 223 | return; |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | done: |
Mike Snitzer | 7a1e9d8 | 2011-01-25 11:52:17 -0500 | [diff] [blame] | 228 | req->end_io_data = NULL; |
| 229 | __blk_put_request(req->q, req); |
Chandra Seetharaman | 4e2ef86 | 2009-10-21 09:22:58 -0700 | [diff] [blame] | 230 | if (h->callback_fn) { |
| 231 | h->callback_fn(h->callback_data, err); |
| 232 | h->callback_fn = h->callback_data = NULL; |
| 233 | } |
| 234 | return; |
| 235 | |
| 236 | } |
| 237 | |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 238 | /* |
| 239 | * hp_sw_start_stop - Send START STOP UNIT command |
| 240 | * @sdev: sdev command should be sent to |
| 241 | * |
| 242 | * Sending START STOP UNIT activates the SP. |
| 243 | */ |
Chandra Seetharaman | 4e2ef86 | 2009-10-21 09:22:58 -0700 | [diff] [blame] | 244 | static int hp_sw_start_stop(struct hp_sw_dh_data *h) |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 245 | { |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 246 | struct request *req; |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 247 | |
Chandra Seetharaman | 4e2ef86 | 2009-10-21 09:22:58 -0700 | [diff] [blame] | 248 | req = blk_get_request(h->sdev->request_queue, WRITE, GFP_ATOMIC); |
Joe Lawrence | a492f07 | 2014-08-28 08:15:21 -0600 | [diff] [blame] | 249 | if (IS_ERR(req)) |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 250 | return SCSI_DH_RES_TEMP_UNAVAIL; |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 251 | |
Jens Axboe | f27b087 | 2014-06-06 07:57:37 -0600 | [diff] [blame] | 252 | blk_rq_set_block_pc(req); |
Mike Christie | 6000a36 | 2008-08-19 18:45:30 -0500 | [diff] [blame] | 253 | req->cmd_flags |= REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | |
| 254 | REQ_FAILFAST_DRIVER; |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 255 | req->cmd_len = COMMAND_SIZE(START_STOP); |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 256 | req->cmd[0] = START_STOP; |
| 257 | req->cmd[4] = 1; /* Start spin cycle */ |
| 258 | req->timeout = HP_SW_TIMEOUT; |
| 259 | req->sense = h->sense; |
| 260 | memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE); |
| 261 | req->sense_len = 0; |
Chandra Seetharaman | 4e2ef86 | 2009-10-21 09:22:58 -0700 | [diff] [blame] | 262 | req->end_io_data = h; |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 263 | |
Chandra Seetharaman | 4e2ef86 | 2009-10-21 09:22:58 -0700 | [diff] [blame] | 264 | blk_execute_rq_nowait(req->q, NULL, req, 1, start_stop_endio); |
| 265 | return SCSI_DH_OK; |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | static int hp_sw_prep_fn(struct scsi_device *sdev, struct request *req) |
| 269 | { |
| 270 | struct hp_sw_dh_data *h = get_hp_sw_data(sdev); |
| 271 | int ret = BLKPREP_OK; |
| 272 | |
| 273 | if (h->path_state != HP_SW_PATH_ACTIVE) { |
| 274 | ret = BLKPREP_KILL; |
| 275 | req->cmd_flags |= REQ_QUIET; |
| 276 | } |
| 277 | return ret; |
| 278 | |
| 279 | } |
| 280 | |
| 281 | /* |
| 282 | * hp_sw_activate - Activate a path |
| 283 | * @sdev: sdev on the path to be activated |
| 284 | * |
| 285 | * The HP Active/Passive firmware is pretty simple; |
| 286 | * the passive path reports NOT READY with sense codes |
| 287 | * 0x04/0x02; a START STOP UNIT command will then |
| 288 | * activate the passive path (and deactivate the |
| 289 | * previously active one). |
| 290 | */ |
Chandra Seetharaman | 3ae31f6 | 2009-10-21 09:22:46 -0700 | [diff] [blame] | 291 | static int hp_sw_activate(struct scsi_device *sdev, |
| 292 | activate_complete fn, void *data) |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 293 | { |
| 294 | int ret = SCSI_DH_OK; |
| 295 | struct hp_sw_dh_data *h = get_hp_sw_data(sdev); |
| 296 | |
| 297 | ret = hp_sw_tur(sdev, h); |
| 298 | |
| 299 | if (ret == SCSI_DH_OK && h->path_state == HP_SW_PATH_PASSIVE) { |
Chandra Seetharaman | 4e2ef86 | 2009-10-21 09:22:58 -0700 | [diff] [blame] | 300 | h->retry_cnt = h->retries; |
| 301 | h->callback_fn = fn; |
| 302 | h->callback_data = data; |
| 303 | ret = hp_sw_start_stop(h); |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 304 | if (ret == SCSI_DH_OK) |
Chandra Seetharaman | 4e2ef86 | 2009-10-21 09:22:58 -0700 | [diff] [blame] | 305 | return 0; |
| 306 | h->callback_fn = h->callback_data = NULL; |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 307 | } |
| 308 | |
Chandra Seetharaman | 3ae31f6 | 2009-10-21 09:22:46 -0700 | [diff] [blame] | 309 | if (fn) |
| 310 | fn(data, ret); |
| 311 | return 0; |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 312 | } |
| 313 | |
Christoph Hellwig | a64d01d | 2014-09-13 20:05:04 -0700 | [diff] [blame] | 314 | static const struct { |
| 315 | char *vendor; |
| 316 | char *model; |
| 317 | } hp_sw_dh_data_list[] = { |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 318 | {"COMPAQ", "MSA1000 VOLUME"}, |
| 319 | {"COMPAQ", "HSV110"}, |
| 320 | {"HP", "HSV100"}, |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 321 | {"DEC", "HSG80"}, |
| 322 | {NULL, NULL}, |
| 323 | }; |
| 324 | |
Moger, Babu | a315969 | 2011-12-01 15:01:28 -0500 | [diff] [blame] | 325 | static bool hp_sw_match(struct scsi_device *sdev) |
| 326 | { |
| 327 | int i; |
| 328 | |
| 329 | if (scsi_device_tpgs(sdev)) |
| 330 | return false; |
| 331 | |
| 332 | for (i = 0; hp_sw_dh_data_list[i].vendor; i++) { |
| 333 | if (!strncmp(sdev->vendor, hp_sw_dh_data_list[i].vendor, |
| 334 | strlen(hp_sw_dh_data_list[i].vendor)) && |
| 335 | !strncmp(sdev->model, hp_sw_dh_data_list[i].model, |
| 336 | strlen(hp_sw_dh_data_list[i].model))) { |
| 337 | return true; |
| 338 | } |
| 339 | } |
| 340 | return false; |
| 341 | } |
| 342 | |
Christoph Hellwig | 1d52032 | 2014-09-14 11:08:21 -0700 | [diff] [blame^] | 343 | static struct scsi_dh_data *hp_sw_bus_attach(struct scsi_device *sdev) |
| 344 | { |
| 345 | struct hp_sw_dh_data *h; |
| 346 | int ret; |
| 347 | |
| 348 | h = kzalloc(sizeof(*h), GFP_KERNEL); |
| 349 | if (!h) |
| 350 | return ERR_PTR(-ENOMEM); |
| 351 | h->path_state = HP_SW_PATH_UNINITIALIZED; |
| 352 | h->retries = HP_SW_RETRIES; |
| 353 | h->sdev = sdev; |
| 354 | |
| 355 | ret = hp_sw_tur(sdev, h); |
| 356 | if (ret != SCSI_DH_OK || h->path_state == HP_SW_PATH_UNINITIALIZED) |
| 357 | goto failed; |
| 358 | |
| 359 | sdev_printk(KERN_INFO, sdev, "%s: attached to %s path\n", |
| 360 | HP_SW_NAME, h->path_state == HP_SW_PATH_ACTIVE? |
| 361 | "active":"passive"); |
| 362 | return &h->dh_data; |
| 363 | failed: |
| 364 | kfree(h); |
| 365 | return ERR_PTR(-EINVAL); |
| 366 | } |
| 367 | |
| 368 | static void hp_sw_bus_detach( struct scsi_device *sdev ) |
| 369 | { |
| 370 | struct hp_sw_dh_data *h = get_hp_sw_data(sdev); |
| 371 | |
| 372 | kfree(h); |
| 373 | } |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 374 | |
| 375 | static struct scsi_device_handler hp_sw_dh = { |
| 376 | .name = HP_SW_NAME, |
| 377 | .module = THIS_MODULE, |
Hannes Reinecke | 765cbc6 | 2008-07-17 16:52:51 -0700 | [diff] [blame] | 378 | .attach = hp_sw_bus_attach, |
| 379 | .detach = hp_sw_bus_detach, |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 380 | .activate = hp_sw_activate, |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 381 | .prep_fn = hp_sw_prep_fn, |
Moger, Babu | a315969 | 2011-12-01 15:01:28 -0500 | [diff] [blame] | 382 | .match = hp_sw_match, |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 383 | }; |
| 384 | |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 385 | static int __init hp_sw_init(void) |
| 386 | { |
| 387 | return scsi_register_device_handler(&hp_sw_dh); |
| 388 | } |
| 389 | |
| 390 | static void __exit hp_sw_exit(void) |
| 391 | { |
| 392 | scsi_unregister_device_handler(&hp_sw_dh); |
| 393 | } |
| 394 | |
| 395 | module_init(hp_sw_init); |
| 396 | module_exit(hp_sw_exit); |
| 397 | |
Hannes Reinecke | 2aef6d5 | 2008-07-17 16:53:09 -0700 | [diff] [blame] | 398 | MODULE_DESCRIPTION("HP Active/Passive driver"); |
Mike Christie | f6dd337 | 2008-05-01 14:49:59 -0700 | [diff] [blame] | 399 | MODULE_AUTHOR("Mike Christie <michaelc@cs.wisc.edu"); |
| 400 | MODULE_LICENSE("GPL"); |