Skip to content

Commit 5c9a297

Browse files
Josh Zimmermangregkh
authored andcommitted
Add "shutdown" to "struct class".
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. Signed-off-by: Josh Zimmerman <joshz@google.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Fixes: 74d6b3c ("tpm: fix suspend/resume paths for TPM 2.0") Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: James Morris <james.l.morris@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5ec5771 commit 5c9a297

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

drivers/base/core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2094,7 +2094,11 @@ void device_shutdown(void)
20942094
pm_runtime_get_noresume(dev);
20952095
pm_runtime_barrier(dev);
20962096

2097-
if (dev->bus && dev->bus->shutdown) {
2097+
if (dev->class && dev->class->shutdown) {
2098+
if (initcall_debug)
2099+
dev_info(dev, "shutdown\n");
2100+
dev->class->shutdown(dev);
2101+
} else if (dev->bus && dev->bus->shutdown) {
20982102
if (initcall_debug)
20992103
dev_info(dev, "shutdown\n");
21002104
dev->bus->shutdown(dev);

include/linux/device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ int subsys_virtual_register(struct bus_type *subsys,
368368
* @suspend: Used to put the device to sleep mode, usually to a low power
369369
* state.
370370
* @resume: Used to bring the device from the sleep mode.
371+
* @shutdown: Called at shut-down time to quiesce the device.
371372
* @ns_type: Callbacks so sysfs can detemine namespaces.
372373
* @namespace: Namespace of the device belongs to this class.
373374
* @pm: The default device power management operations of this class.
@@ -396,6 +397,7 @@ struct class {
396397

397398
int (*suspend)(struct device *dev, pm_message_t state);
398399
int (*resume)(struct device *dev);
400+
int (*shutdown)(struct device *dev);
399401

400402
const struct kobj_ns_type_operations *ns_type;
401403
const void *(*namespace)(struct device *dev);

0 commit comments

Comments
 (0)