Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Do not disable driver and bus shutdown hook when class shutdown hook is set.

As seen from the implementation of the single class shutdown hook this
is not very sound design.

Rename the class shutdown hook to shutdown_pre to make it clear it runs
before the driver shutdown hook.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Michal Suchanek and committed by
Greg Kroah-Hartman
7521621e df44d30d

+9 -15
+5 -4
drivers/base/core.c
··· 2796 2796 pm_runtime_get_noresume(dev); 2797 2797 pm_runtime_barrier(dev); 2798 2798 2799 - if (dev->class && dev->class->shutdown) { 2799 + if (dev->class && dev->class->shutdown_pre) { 2800 2800 if (initcall_debug) 2801 - dev_info(dev, "shutdown\n"); 2802 - dev->class->shutdown(dev); 2803 - } else if (dev->bus && dev->bus->shutdown) { 2801 + dev_info(dev, "shutdown_pre\n"); 2802 + dev->class->shutdown_pre(dev); 2803 + } 2804 + if (dev->bus && dev->bus->shutdown) { 2804 2805 if (initcall_debug) 2805 2806 dev_info(dev, "shutdown\n"); 2806 2807 dev->bus->shutdown(dev);
+2 -9
drivers/char/tpm/tpm-chip.c
··· 164 164 chip->ops = NULL; 165 165 up_write(&chip->ops_sem); 166 166 } 167 - /* Allow bus- and device-specific code to run. Note: since chip->ops 168 - * is NULL, more-specific shutdown code will not be able to issue TPM 169 - * commands. 170 - */ 171 - if (dev->bus && dev->bus->shutdown) 172 - dev->bus->shutdown(dev); 173 - else if (dev->driver && dev->driver->shutdown) 174 - dev->driver->shutdown(dev); 167 + 175 168 return 0; 176 169 } 177 170 ··· 207 214 device_initialize(&chip->devs); 208 215 209 216 chip->dev.class = tpm_class; 210 - chip->dev.class->shutdown = tpm_class_shutdown; 217 + chip->dev.class->shutdown_pre = tpm_class_shutdown; 211 218 chip->dev.release = tpm_dev_release; 212 219 chip->dev.parent = pdev; 213 220 chip->dev.groups = chip->groups;
+2 -2
include/linux/device.h
··· 375 375 * @suspend: Used to put the device to sleep mode, usually to a low power 376 376 * state. 377 377 * @resume: Used to bring the device from the sleep mode. 378 - * @shutdown: Called at shut-down time to quiesce the device. 378 + * @shutdown_pre: Called at shut-down time before driver shutdown. 379 379 * @ns_type: Callbacks so sysfs can detemine namespaces. 380 380 * @namespace: Namespace of the device belongs to this class. 381 381 * @pm: The default device power management operations of this class. ··· 404 404 405 405 int (*suspend)(struct device *dev, pm_message_t state); 406 406 int (*resume)(struct device *dev); 407 - int (*shutdown)(struct device *dev); 407 + int (*shutdown_pre)(struct device *dev); 408 408 409 409 const struct kobj_ns_type_operations *ns_type; 410 410 const void *(*namespace)(struct device *dev);