All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Zimmerman <joshz@google.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	tpmdd-devel@lists.sourceforge.net, gregkh@linuxfoundation.org,
	stable@vger.kernel.org
Cc: Josh Zimmerman <joshz@google.com>
Subject: [PATCH v1 3/4] Add "shutdown" to "struct class".'
Date: Fri, 14 Jul 2017 12:58:02 -0700	[thread overview]
Message-ID: <20170714195803.7035-4-joshz@google.com> (raw)
In-Reply-To: <20170714195803.7035-1-joshz@google.com>

Backport of commit f77af15165847406b15d8f70c382c4cb15846b2a upstream.

The TPM class has some common shutdown code that must be executed for
all drivers. This adds some needed functionality for that.
---
 drivers/base/core.c    | 6 +++++-
 include/linux/device.h | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index f18856f5954b..afe045792796 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2094,7 +2094,11 @@ void device_shutdown(void)
 		pm_runtime_get_noresume(dev);
 		pm_runtime_barrier(dev);
 
-		if (dev->bus && dev->bus->shutdown) {
+		if (dev->class && dev->class->shutdown) {
+			if (initcall_debug)
+				dev_info(dev, "shutdown\n");
+			dev->class->shutdown(dev);
+		} else if (dev->bus && dev->bus->shutdown) {
 			if (initcall_debug)
 				dev_info(dev, "shutdown\n");
 			dev->bus->shutdown(dev);
diff --git a/include/linux/device.h b/include/linux/device.h
index b8f411b57dcb..3656df6cf638 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -368,6 +368,7 @@ int subsys_virtual_register(struct bus_type *subsys,
  * @suspend:	Used to put the device to sleep mode, usually to a low power
  *		state.
  * @resume:	Used to bring the device from the sleep mode.
+ * @shutdown:  Called at shut-down time to quiesce the device.
  * @ns_type:	Callbacks so sysfs can detemine namespaces.
  * @namespace:	Namespace of the device belongs to this class.
  * @pm:		The default device power management operations of this class.
@@ -396,6 +397,7 @@ struct class {
 
 	int (*suspend)(struct device *dev, pm_message_t state);
 	int (*resume)(struct device *dev);
+	int (*shutdown)(struct device *dev);
 
 	const struct kobj_ns_type_operations *ns_type;
 	const void *(*namespace)(struct device *dev);
-- 
2.13.2.932.g7449e964c-goog

  parent reply	other threads:[~2017-07-14 19:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-14 19:57 [PATCH v1 0/2] Run TPM2_Shutdown on system shutdown Josh Zimmerman
2017-07-14 19:58 ` [PATCH v1 1/4] tpm: Get rid of chip->pdev Josh Zimmerman
2017-07-14 19:58 ` [PATCH v1 2/4] tpm: Provide strong locking for device removal Josh Zimmerman
2017-07-14 19:58 ` Josh Zimmerman [this message]
2017-07-18 15:48   ` [PATCH v1 3/4] Add "shutdown" to "struct class".' Greg KH
2017-07-14 19:58 ` [PATCH v1 4/4] tpm: Issue a TPM2_Shutdown for TPM2 devices Josh Zimmerman
2017-07-18 15:49   ` Greg KH
2017-07-18 16:11     ` Josh Zimmerman
2017-07-18 16:29       ` Greg KH
2017-07-18 16:33         ` Josh Zimmerman
2017-07-18 15:50 ` [PATCH v1 0/2] Run TPM2_Shutdown on system shutdown Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170714195803.7035-4-joshz@google.com \
    --to=joshz@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=stable@vger.kernel.org \
    --cc=tpmdd-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.