diff options
| -rw-r--r-- | drivers/scsi/esp_scsi.c | 30 | ||||
| -rw-r--r-- | drivers/scsi/esp_scsi.h | 1 |
2 files changed, 20 insertions, 11 deletions
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index 305eddef5ca1..59fbef08d690 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c | |||
| @@ -2359,6 +2359,24 @@ void scsi_esp_unregister(struct esp *esp) | |||
| 2359 | } | 2359 | } |
| 2360 | EXPORT_SYMBOL(scsi_esp_unregister); | 2360 | EXPORT_SYMBOL(scsi_esp_unregister); |
| 2361 | 2361 | ||
| 2362 | static int esp_target_alloc(struct scsi_target *starget) | ||
| 2363 | { | ||
| 2364 | struct esp *esp = shost_priv(dev_to_shost(&starget->dev)); | ||
| 2365 | struct esp_target_data *tp = &esp->target[starget->id]; | ||
| 2366 | |||
| 2367 | tp->starget = starget; | ||
| 2368 | |||
| 2369 | return 0; | ||
| 2370 | } | ||
| 2371 | |||
| 2372 | static void esp_target_destroy(struct scsi_target *starget) | ||
| 2373 | { | ||
| 2374 | struct esp *esp = shost_priv(dev_to_shost(&starget->dev)); | ||
| 2375 | struct esp_target_data *tp = &esp->target[starget->id]; | ||
| 2376 | |||
| 2377 | tp->starget = NULL; | ||
| 2378 | } | ||
| 2379 | |||
| 2362 | static int esp_slave_alloc(struct scsi_device *dev) | 2380 | static int esp_slave_alloc(struct scsi_device *dev) |
| 2363 | { | 2381 | { |
| 2364 | struct esp *esp = shost_priv(dev->host); | 2382 | struct esp *esp = shost_priv(dev->host); |
| @@ -2370,9 +2388,6 @@ static int esp_slave_alloc(struct scsi_device *dev) | |||
| 2370 | return -ENOMEM; | 2388 | return -ENOMEM; |
| 2371 | dev->hostdata = lp; | 2389 | dev->hostdata = lp; |
| 2372 | 2390 | ||
| 2373 | tp->starget = dev->sdev_target; | ||
| 2374 | tp->starget_ref++; | ||
| 2375 | |||
| 2376 | spi_min_period(tp->starget) = esp->min_period; | 2391 | spi_min_period(tp->starget) = esp->min_period; |
| 2377 | spi_max_offset(tp->starget) = 15; | 2392 | spi_max_offset(tp->starget) = 15; |
| 2378 | 2393 | ||
| @@ -2426,17 +2441,10 @@ static int esp_slave_configure(struct scsi_device *dev) | |||
| 2426 | 2441 | ||
| 2427 | static void esp_slave_destroy(struct scsi_device *dev) | 2442 | static void esp_slave_destroy(struct scsi_device *dev) |
| 2428 | { | 2443 | { |
| 2429 | struct esp *esp = shost_priv(dev->host); | ||
| 2430 | struct esp_target_data *tp = &esp->target[dev->id]; | ||
| 2431 | struct esp_lun_data *lp = dev->hostdata; | 2444 | struct esp_lun_data *lp = dev->hostdata; |
| 2432 | 2445 | ||
| 2433 | kfree(lp); | 2446 | kfree(lp); |
| 2434 | dev->hostdata = NULL; | 2447 | dev->hostdata = NULL; |
| 2435 | |||
| 2436 | BUG_ON(tp->starget_ref <= 0); | ||
| 2437 | |||
| 2438 | if (!--tp->starget_ref) | ||
| 2439 | tp->starget = NULL; | ||
| 2440 | } | 2448 | } |
| 2441 | 2449 | ||
| 2442 | static int esp_eh_abort_handler(struct scsi_cmnd *cmd) | 2450 | static int esp_eh_abort_handler(struct scsi_cmnd *cmd) |
| @@ -2616,6 +2624,8 @@ struct scsi_host_template scsi_esp_template = { | |||
| 2616 | .name = "esp", | 2624 | .name = "esp", |
| 2617 | .info = esp_info, | 2625 | .info = esp_info, |
| 2618 | .queuecommand = esp_queuecommand, | 2626 | .queuecommand = esp_queuecommand, |
| 2627 | .target_alloc = esp_target_alloc, | ||
| 2628 | .target_destroy = esp_target_destroy, | ||
| 2619 | .slave_alloc = esp_slave_alloc, | 2629 | .slave_alloc = esp_slave_alloc, |
| 2620 | .slave_configure = esp_slave_configure, | 2630 | .slave_configure = esp_slave_configure, |
| 2621 | .slave_destroy = esp_slave_destroy, | 2631 | .slave_destroy = esp_slave_destroy, |
diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h index 655e0b2240bf..bb43a1388188 100644 --- a/drivers/scsi/esp_scsi.h +++ b/drivers/scsi/esp_scsi.h | |||
| @@ -322,7 +322,6 @@ struct esp_target_data { | |||
| 322 | u8 nego_goal_tags; | 322 | u8 nego_goal_tags; |
| 323 | 323 | ||
| 324 | struct scsi_target *starget; | 324 | struct scsi_target *starget; |
| 325 | int starget_ref; | ||
| 326 | }; | 325 | }; |
| 327 | 326 | ||
| 328 | struct esp_event_ent { | 327 | struct esp_event_ent { |
