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

Configure Feed

Select the types of activity you want to include in your feed.

driver core: separate function to shutdown one device

Make a separate function for the part of device_shutdown() that does the
shutown for a single device. This is in preparation for making device
shutdown asynchronous.

Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com>
Signed-off-by: David Jeffery <djeffery@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Tested-by: Keith Busch <kbusch@kernel.org>
Link: https://lore.kernel.org/r/20240822202805.6379-3-stuart.w.hayes@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Stuart Hayes and committed by
Greg Kroah-Hartman
95dc7565 ba635374

+36 -30
+36 -30
drivers/base/core.c
··· 4779 4779 } 4780 4780 EXPORT_SYMBOL_GPL(device_change_owner); 4781 4781 4782 + static void shutdown_one_device(struct device *dev) 4783 + { 4784 + /* hold lock to avoid race with probe/release */ 4785 + if (dev->parent && dev->bus && dev->bus->need_parent_lock) 4786 + device_lock(dev->parent); 4787 + device_lock(dev); 4788 + 4789 + /* Don't allow any more runtime suspends */ 4790 + pm_runtime_get_noresume(dev); 4791 + pm_runtime_barrier(dev); 4792 + 4793 + if (dev->class && dev->class->shutdown_pre) { 4794 + if (initcall_debug) 4795 + dev_info(dev, "shutdown_pre\n"); 4796 + dev->class->shutdown_pre(dev); 4797 + } 4798 + if (dev->bus && dev->bus->shutdown) { 4799 + if (initcall_debug) 4800 + dev_info(dev, "shutdown\n"); 4801 + dev->bus->shutdown(dev); 4802 + } else if (dev->driver && dev->driver->shutdown) { 4803 + if (initcall_debug) 4804 + dev_info(dev, "shutdown\n"); 4805 + dev->driver->shutdown(dev); 4806 + } 4807 + 4808 + device_unlock(dev); 4809 + if (dev->parent && dev->bus && dev->bus->need_parent_lock) 4810 + device_unlock(dev->parent); 4811 + 4812 + put_device(dev); 4813 + if (dev->parent) 4814 + put_device(dev->parent); 4815 + } 4816 + 4782 4817 /** 4783 4818 * device_shutdown - call ->shutdown() on each device to shutdown. 4784 4819 */ ··· 4850 4815 list_del_init(&dev->kobj.entry); 4851 4816 spin_unlock(&devices_kset->list_lock); 4852 4817 4853 - /* hold lock to avoid race with probe/release */ 4854 - if (parent && dev->bus && dev->bus->need_parent_lock) 4855 - device_lock(parent); 4856 - device_lock(dev); 4857 - 4858 - /* Don't allow any more runtime suspends */ 4859 - pm_runtime_get_noresume(dev); 4860 - pm_runtime_barrier(dev); 4861 - 4862 - if (dev->class && dev->class->shutdown_pre) { 4863 - if (initcall_debug) 4864 - dev_info(dev, "shutdown_pre\n"); 4865 - dev->class->shutdown_pre(dev); 4866 - } 4867 - if (dev->bus && dev->bus->shutdown) { 4868 - if (initcall_debug) 4869 - dev_info(dev, "shutdown\n"); 4870 - dev->bus->shutdown(dev); 4871 - } else if (dev->driver && dev->driver->shutdown) { 4872 - if (initcall_debug) 4873 - dev_info(dev, "shutdown\n"); 4874 - dev->driver->shutdown(dev); 4875 - } 4876 - 4877 - device_unlock(dev); 4878 - if (parent && dev->bus && dev->bus->need_parent_lock) 4879 - device_unlock(parent); 4880 - 4881 - put_device(dev); 4882 - put_device(parent); 4818 + shutdown_one_device(dev); 4883 4819 4884 4820 spin_lock(&devices_kset->list_lock); 4885 4821 }