stm class: Plug stm device's unlink callback
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>
Mon, 15 Feb 2016 17:12:09 +0000 (19:12 +0200)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Wed, 1 Jun 2016 21:28:48 +0000 (15:28 -0600)
STM device's unlink callback is never actually called from anywhere in
the stm class code.

This patch adds calls to stm driver's unlink method after the unlinking
has succeeded.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit cc8424074e51355e0c6ba717d8edc50d408f2802)

drivers/hwtracing/stm/core.c
include/linux/stm.h

index e072652d9646dfc63b8fff93a5175ef53e9e5b94..0dd8f4c996f142aaa00d6a5c4d9b4ddb5918deba 100644 (file)
@@ -376,14 +376,19 @@ err_free:
 static int stm_char_release(struct inode *inode, struct file *file)
 {
        struct stm_file *stmf = file->private_data;
+       struct stm_device *stm = stmf->stm;
+
+       if (stm->data->unlink)
+               stm->data->unlink(stm->data, stmf->output.master,
+                                 stmf->output.channel);
 
-       stm_output_free(stmf->stm, &stmf->output);
+       stm_output_free(stm, &stmf->output);
 
        /*
         * matches the stm_char_open()'s
         * class_find_device() + try_module_get()
         */
-       stm_put_device(stmf->stm);
+       stm_put_device(stm);
        kfree(stmf);
 
        return 0;
@@ -865,8 +870,18 @@ unlock:
        spin_unlock(&src->link_lock);
        spin_unlock(&stm->link_lock);
 
-       if (!ret && src->data->unlink)
-               src->data->unlink(src->data);
+       /*
+        * Call the unlink callbacks for both source and stm, when we know
+        * that we have actually performed the unlinking.
+        */
+       if (!ret) {
+               if (src->data->unlink)
+                       src->data->unlink(src->data);
+
+               if (stm->data->unlink)
+                       stm->data->unlink(stm->data, src->output.master,
+                                         src->output.channel);
+       }
 
        return ret;
 }
index ab8ceca4f5705aaeadda9ed8798559c450637d06..1a79ed8e43dadcb8d5884d17d73b2cd15e3a11d4 100644 (file)
@@ -74,6 +74,9 @@ struct stm_device;
  *      it must return zero;
  *   3) if it does not support the requested packet type/flag combination,
  *      it must return -ENOTSUPP.
+ *
+ * The @unlink callback is called when there are no more active writers so
+ * that the master/channel can be quiesced.
  */
 struct stm_data {
        const char              *name;