diff options
author | Swen Schillig <swen@vnet.ibm.com> | 2009-08-18 09:43:22 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-09-05 09:49:32 -0400 |
commit | d5a282a1c5084ec7ebd9e6ab9723317f6b3fcd7b (patch) | |
tree | a215cde519ca65b129d35d8d435061b48ab3864c /drivers/s390/scsi/zfcp_qdio.c | |
parent | 5771710bd5edfafcb8656f49b93690a6fae5a4d2 (diff) |
[SCSI] zfcp: introduce _setup, _destroy for qdio and FC
Extract independent data structures and introduce common _setup and
_destroy routines for QDIO and Fibre Channel related data structures
Signed-off-by: Swen Schillig <swen@vnet.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/s390/scsi/zfcp_qdio.c')
-rw-r--r-- | drivers/s390/scsi/zfcp_qdio.c | 68 |
1 files changed, 46 insertions, 22 deletions
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index 84527ebbbe58..2b499e28ff1f 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c | |||
@@ -34,27 +34,6 @@ zfcp_qdio_sbale(struct zfcp_qdio_queue *q, int sbal_idx, int sbale_idx) | |||
34 | return &q->sbal[sbal_idx]->element[sbale_idx]; | 34 | return &q->sbal[sbal_idx]->element[sbale_idx]; |
35 | } | 35 | } |
36 | 36 | ||
37 | /** | ||
38 | * zfcp_qdio_free - free memory used by request- and resposne queue | ||
39 | * @qdio: pointer to the zfcp_qdio structure | ||
40 | */ | ||
41 | void zfcp_qdio_free(struct zfcp_qdio *qdio) | ||
42 | { | ||
43 | struct qdio_buffer **sbal_req, **sbal_resp; | ||
44 | int p; | ||
45 | |||
46 | if (qdio->adapter->ccw_device) | ||
47 | qdio_free(qdio->adapter->ccw_device); | ||
48 | |||
49 | sbal_req = qdio->req_q.sbal; | ||
50 | sbal_resp = qdio->resp_q.sbal; | ||
51 | |||
52 | for (p = 0; p < QDIO_MAX_BUFFERS_PER_Q; p += QBUFF_PER_PAGE) { | ||
53 | free_page((unsigned long) sbal_req[p]); | ||
54 | free_page((unsigned long) sbal_resp[p]); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | static void zfcp_qdio_handler_error(struct zfcp_qdio *qdio, char *id) | 37 | static void zfcp_qdio_handler_error(struct zfcp_qdio *qdio, char *id) |
59 | { | 38 | { |
60 | struct zfcp_adapter *adapter = qdio->adapter; | 39 | struct zfcp_adapter *adapter = qdio->adapter; |
@@ -383,7 +362,7 @@ static void zfcp_qdio_setup_init_data(struct qdio_initialize *id, | |||
383 | * Returns: -ENOMEM on memory allocation error or return value from | 362 | * Returns: -ENOMEM on memory allocation error or return value from |
384 | * qdio_allocate | 363 | * qdio_allocate |
385 | */ | 364 | */ |
386 | int zfcp_qdio_allocate(struct zfcp_qdio *qdio, struct ccw_device *ccw_dev) | 365 | static int zfcp_qdio_allocate(struct zfcp_qdio *qdio) |
387 | { | 366 | { |
388 | struct qdio_initialize init_data; | 367 | struct qdio_initialize init_data; |
389 | 368 | ||
@@ -477,3 +456,48 @@ failed_establish: | |||
477 | "Setting up the QDIO connection to the FCP adapter failed\n"); | 456 | "Setting up the QDIO connection to the FCP adapter failed\n"); |
478 | return -EIO; | 457 | return -EIO; |
479 | } | 458 | } |
459 | |||
460 | void zfcp_qdio_destroy(struct zfcp_qdio *qdio) | ||
461 | { | ||
462 | struct qdio_buffer **sbal_req, **sbal_resp; | ||
463 | int p; | ||
464 | |||
465 | if (!qdio) | ||
466 | return; | ||
467 | |||
468 | if (qdio->adapter->ccw_device) | ||
469 | qdio_free(qdio->adapter->ccw_device); | ||
470 | |||
471 | sbal_req = qdio->req_q.sbal; | ||
472 | sbal_resp = qdio->resp_q.sbal; | ||
473 | |||
474 | for (p = 0; p < QDIO_MAX_BUFFERS_PER_Q; p += QBUFF_PER_PAGE) { | ||
475 | free_page((unsigned long) sbal_req[p]); | ||
476 | free_page((unsigned long) sbal_resp[p]); | ||
477 | } | ||
478 | |||
479 | kfree(qdio); | ||
480 | } | ||
481 | |||
482 | int zfcp_qdio_setup(struct zfcp_adapter *adapter) | ||
483 | { | ||
484 | struct zfcp_qdio *qdio; | ||
485 | |||
486 | qdio = kzalloc(sizeof(struct zfcp_qdio), GFP_KERNEL); | ||
487 | if (!qdio) | ||
488 | return -ENOMEM; | ||
489 | |||
490 | qdio->adapter = adapter; | ||
491 | |||
492 | if (zfcp_qdio_allocate(qdio)) { | ||
493 | zfcp_qdio_destroy(qdio); | ||
494 | return -ENOMEM; | ||
495 | } | ||
496 | |||
497 | spin_lock_init(&qdio->req_q_lock); | ||
498 | spin_lock_init(&qdio->stat_lock); | ||
499 | |||
500 | adapter->qdio = qdio; | ||
501 | return 0; | ||
502 | } | ||
503 | |||