提交 a83f8dc1 编写于 作者: Y Yang Yingliang 提交者: Xie XiuQi

device: add device_shutdown_by_driver() helper

euler inclusion
category: bugfix
bugzilla: 5452
CVE: NA

This patchset is add a kernel parameter to avoid kdump
problem on Hi1620ES. It will be revert when we have better
solution on Hi1620CS.

[PATCH 1/4] Revert "iommu/arm-smmu-v3: Abort all transactions if SMMU is enabled in kdump kernel"
[PATCH 2/4] device: add device_shutdown_one() helper
[PATCH 3/4] device: add device_shutdown_by_driver() helper
[PATCH 4/4] kexec: add kexec_device_shutdown()

------------------------------------------------

Add device_shutdown_by_driver() helper that shutdown
the devices through driver name
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 caaba929
...@@ -2929,6 +2929,36 @@ void device_shutdown(void) ...@@ -2929,6 +2929,36 @@ void device_shutdown(void)
spin_unlock(&devices_kset->list_lock); spin_unlock(&devices_kset->list_lock);
} }
void device_shutdown_by_driver(char *drv_name)
{
struct device *dev, *parent, *next;
int len = 0;
if (!drv_name)
return;
len = strlen(drv_name);
if (!len)
return;
wait_for_device_probe();
device_block_probing();
spin_lock(&devices_kset->list_lock);
list_for_each_entry_safe(dev, next, &devices_kset->list, kobj.entry) {
if (dev->driver && len == strlen(dev->driver->name) &&
!strncmp(dev->driver->name, drv_name, len)) {
parent = get_device(dev->parent);
get_device(dev);
list_del(&dev->kobj.entry);
spin_unlock(&devices_kset->list_lock);
device_shutdown_one(dev, parent);
spin_lock(&devices_kset->list_lock);
}
}
spin_unlock(&devices_kset->list_lock);
}
/* /*
* Device logging functions * Device logging functions
*/ */
......
...@@ -1321,6 +1321,7 @@ static inline int devtmpfs_mount(const char *mountpoint) { return 0; } ...@@ -1321,6 +1321,7 @@ static inline int devtmpfs_mount(const char *mountpoint) { return 0; }
/* drivers/base/power/shutdown.c */ /* drivers/base/power/shutdown.c */
extern void device_shutdown(void); extern void device_shutdown(void);
extern void device_shutdown_by_driver(char *drv_name);
/* debugging and troubleshooting/diagnostic helpers. */ /* debugging and troubleshooting/diagnostic helpers. */
extern const char *dev_driver_string(const struct device *dev); extern const char *dev_driver_string(const struct device *dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册