diff options
-rw-r--r-- | drivers/s390/crypto/ap_bus.c | 38 | ||||
-rw-r--r-- | drivers/s390/crypto/ap_card.c | 9 | ||||
-rw-r--r-- | drivers/s390/crypto/ap_queue.c | 9 |
3 files changed, 40 insertions, 16 deletions
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index 9be4596d8a08..ea099910b4e9 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c | |||
@@ -668,10 +668,28 @@ static int ap_device_probe(struct device *dev) | |||
668 | struct ap_driver *ap_drv = to_ap_drv(dev->driver); | 668 | struct ap_driver *ap_drv = to_ap_drv(dev->driver); |
669 | int rc; | 669 | int rc; |
670 | 670 | ||
671 | /* Add queue/card to list of active queues/cards */ | ||
672 | spin_lock_bh(&ap_list_lock); | ||
673 | if (is_card_dev(dev)) | ||
674 | list_add(&to_ap_card(dev)->list, &ap_card_list); | ||
675 | else | ||
676 | list_add(&to_ap_queue(dev)->list, | ||
677 | &to_ap_queue(dev)->card->queues); | ||
678 | spin_unlock_bh(&ap_list_lock); | ||
679 | |||
671 | ap_dev->drv = ap_drv; | 680 | ap_dev->drv = ap_drv; |
672 | rc = ap_drv->probe ? ap_drv->probe(ap_dev) : -ENODEV; | 681 | rc = ap_drv->probe ? ap_drv->probe(ap_dev) : -ENODEV; |
673 | if (rc) | 682 | |
683 | if (rc) { | ||
684 | spin_lock_bh(&ap_list_lock); | ||
685 | if (is_card_dev(dev)) | ||
686 | list_del_init(&to_ap_card(dev)->list); | ||
687 | else | ||
688 | list_del_init(&to_ap_queue(dev)->list); | ||
689 | spin_unlock_bh(&ap_list_lock); | ||
674 | ap_dev->drv = NULL; | 690 | ap_dev->drv = NULL; |
691 | } | ||
692 | |||
675 | return rc; | 693 | return rc; |
676 | } | 694 | } |
677 | 695 | ||
@@ -680,14 +698,17 @@ static int ap_device_remove(struct device *dev) | |||
680 | struct ap_device *ap_dev = to_ap_dev(dev); | 698 | struct ap_device *ap_dev = to_ap_dev(dev); |
681 | struct ap_driver *ap_drv = ap_dev->drv; | 699 | struct ap_driver *ap_drv = ap_dev->drv; |
682 | 700 | ||
701 | if (ap_drv->remove) | ||
702 | ap_drv->remove(ap_dev); | ||
703 | |||
704 | /* Remove queue/card from list of active queues/cards */ | ||
683 | spin_lock_bh(&ap_list_lock); | 705 | spin_lock_bh(&ap_list_lock); |
684 | if (is_card_dev(dev)) | 706 | if (is_card_dev(dev)) |
685 | list_del_init(&to_ap_card(dev)->list); | 707 | list_del_init(&to_ap_card(dev)->list); |
686 | else | 708 | else |
687 | list_del_init(&to_ap_queue(dev)->list); | 709 | list_del_init(&to_ap_queue(dev)->list); |
688 | spin_unlock_bh(&ap_list_lock); | 710 | spin_unlock_bh(&ap_list_lock); |
689 | if (ap_drv->remove) | 711 | |
690 | ap_drv->remove(ap_dev); | ||
691 | return 0; | 712 | return 0; |
692 | } | 713 | } |
693 | 714 | ||
@@ -1056,10 +1077,6 @@ static void ap_scan_bus(struct work_struct *unused) | |||
1056 | } | 1077 | } |
1057 | /* get it and thus adjust reference counter */ | 1078 | /* get it and thus adjust reference counter */ |
1058 | get_device(&ac->ap_dev.device); | 1079 | get_device(&ac->ap_dev.device); |
1059 | /* Add card device to card list */ | ||
1060 | spin_lock_bh(&ap_list_lock); | ||
1061 | list_add(&ac->list, &ap_card_list); | ||
1062 | spin_unlock_bh(&ap_list_lock); | ||
1063 | } | 1080 | } |
1064 | /* now create the new queue device */ | 1081 | /* now create the new queue device */ |
1065 | aq = ap_queue_create(qid, type); | 1082 | aq = ap_queue_create(qid, type); |
@@ -1070,10 +1087,6 @@ static void ap_scan_bus(struct work_struct *unused) | |||
1070 | aq->ap_dev.device.parent = &ac->ap_dev.device; | 1087 | aq->ap_dev.device.parent = &ac->ap_dev.device; |
1071 | dev_set_name(&aq->ap_dev.device, | 1088 | dev_set_name(&aq->ap_dev.device, |
1072 | "%02x.%04x", id, dom); | 1089 | "%02x.%04x", id, dom); |
1073 | /* Add queue device to card queue list */ | ||
1074 | spin_lock_bh(&ap_list_lock); | ||
1075 | list_add(&aq->list, &ac->queues); | ||
1076 | spin_unlock_bh(&ap_list_lock); | ||
1077 | /* Start with a device reset */ | 1090 | /* Start with a device reset */ |
1078 | spin_lock_bh(&aq->lock); | 1091 | spin_lock_bh(&aq->lock); |
1079 | ap_wait(ap_sm_event(aq, AP_EVENT_POLL)); | 1092 | ap_wait(ap_sm_event(aq, AP_EVENT_POLL)); |
@@ -1081,9 +1094,6 @@ static void ap_scan_bus(struct work_struct *unused) | |||
1081 | /* Register device */ | 1094 | /* Register device */ |
1082 | rc = device_register(&aq->ap_dev.device); | 1095 | rc = device_register(&aq->ap_dev.device); |
1083 | if (rc) { | 1096 | if (rc) { |
1084 | spin_lock_bh(&ap_list_lock); | ||
1085 | list_del_init(&aq->list); | ||
1086 | spin_unlock_bh(&ap_list_lock); | ||
1087 | put_device(&aq->ap_dev.device); | 1097 | put_device(&aq->ap_dev.device); |
1088 | continue; | 1098 | continue; |
1089 | } | 1099 | } |
diff --git a/drivers/s390/crypto/ap_card.c b/drivers/s390/crypto/ap_card.c index cfa161ccc74e..836efac96813 100644 --- a/drivers/s390/crypto/ap_card.c +++ b/drivers/s390/crypto/ap_card.c | |||
@@ -160,7 +160,14 @@ static struct device_type ap_card_type = { | |||
160 | 160 | ||
161 | static void ap_card_device_release(struct device *dev) | 161 | static void ap_card_device_release(struct device *dev) |
162 | { | 162 | { |
163 | kfree(to_ap_card(dev)); | 163 | struct ap_card *ac = to_ap_card(dev); |
164 | |||
165 | if (!list_empty(&ac->list)) { | ||
166 | spin_lock_bh(&ap_list_lock); | ||
167 | list_del_init(&ac->list); | ||
168 | spin_unlock_bh(&ap_list_lock); | ||
169 | } | ||
170 | kfree(ac); | ||
164 | } | 171 | } |
165 | 172 | ||
166 | struct ap_card *ap_card_create(int id, int queue_depth, int device_type, | 173 | struct ap_card *ap_card_create(int id, int queue_depth, int device_type, |
diff --git a/drivers/s390/crypto/ap_queue.c b/drivers/s390/crypto/ap_queue.c index 480c58a63769..0f1a5d02acb0 100644 --- a/drivers/s390/crypto/ap_queue.c +++ b/drivers/s390/crypto/ap_queue.c | |||
@@ -584,7 +584,14 @@ static struct device_type ap_queue_type = { | |||
584 | 584 | ||
585 | static void ap_queue_device_release(struct device *dev) | 585 | static void ap_queue_device_release(struct device *dev) |
586 | { | 586 | { |
587 | kfree(to_ap_queue(dev)); | 587 | struct ap_queue *aq = to_ap_queue(dev); |
588 | |||
589 | if (!list_empty(&aq->list)) { | ||
590 | spin_lock_bh(&ap_list_lock); | ||
591 | list_del_init(&aq->list); | ||
592 | spin_unlock_bh(&ap_list_lock); | ||
593 | } | ||
594 | kfree(aq); | ||
588 | } | 595 | } |
589 | 596 | ||
590 | struct ap_queue *ap_queue_create(ap_qid_t qid, int device_type) | 597 | struct ap_queue *ap_queue_create(ap_qid_t qid, int device_type) |