]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/s390/crypto/ap_queue.c
Merge tag 'platform-drivers-x86-v4.12-2' of git://git.infradead.org/linux-platform...
[karo-tx-linux.git] / drivers / s390 / crypto / ap_queue.c
index b58a917dc5107318b31d5a3805f19c55771e11b7..0f1a5d02acb0e151092504754900a3d889514e17 100644 (file)
@@ -459,9 +459,9 @@ EXPORT_SYMBOL(ap_queue_resume);
 /*
  * AP queue related attributes.
  */
-static ssize_t ap_request_count_show(struct device *dev,
-                                    struct device_attribute *attr,
-                                    char *buf)
+static ssize_t ap_req_count_show(struct device *dev,
+                                struct device_attribute *attr,
+                                char *buf)
 {
        struct ap_queue *aq = to_ap_queue(dev);
        unsigned int req_cnt;
@@ -472,7 +472,20 @@ static ssize_t ap_request_count_show(struct device *dev,
        return snprintf(buf, PAGE_SIZE, "%d\n", req_cnt);
 }
 
-static DEVICE_ATTR(request_count, 0444, ap_request_count_show, NULL);
+static ssize_t ap_req_count_store(struct device *dev,
+                                 struct device_attribute *attr,
+                                 const char *buf, size_t count)
+{
+       struct ap_queue *aq = to_ap_queue(dev);
+
+       spin_lock_bh(&aq->lock);
+       aq->total_request_count = 0;
+       spin_unlock_bh(&aq->lock);
+
+       return count;
+}
+
+static DEVICE_ATTR(request_count, 0644, ap_req_count_show, ap_req_count_store);
 
 static ssize_t ap_requestq_count_show(struct device *dev,
                                      struct device_attribute *attr, char *buf)
@@ -564,14 +577,21 @@ static const struct attribute_group *ap_queue_dev_attr_groups[] = {
        NULL
 };
 
-struct device_type ap_queue_type = {
+static struct device_type ap_queue_type = {
        .name = "ap_queue",
        .groups = ap_queue_dev_attr_groups,
 };
 
 static void ap_queue_device_release(struct device *dev)
 {
-       kfree(to_ap_queue(dev));
+       struct ap_queue *aq = to_ap_queue(dev);
+
+       if (!list_empty(&aq->list)) {
+               spin_lock_bh(&ap_list_lock);
+               list_del_init(&aq->list);
+               spin_unlock_bh(&ap_list_lock);
+       }
+       kfree(aq);
 }
 
 struct ap_queue *ap_queue_create(ap_qid_t qid, int device_type)