@@ -426,6 +426,35 @@ static ssize_t coredump_store(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_WO(coredump);
+static ssize_t coredump_disabled_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ return sysfs_emit(buf, "%d\n", dev->coredump_disabled);
+}
+
+static ssize_t coredump_disabled_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ bool disabled;
+
+ if (kstrtobool(buf, &disabled) < 0)
+ return -EINVAL;
+
+ dev->coredump_disabled = disabled;
+
+ return count;
+}
+static DEVICE_ATTR_RW(coredump_disabled);
+
+static struct attribute *dev_coredump_attrs[] = {
+ &dev_attr_coredump.attr,
+ &dev_attr_coredump_disabled.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(dev_coredump);
+
static int driver_sysfs_add(struct device *dev)
{
int ret;
@@ -447,7 +476,7 @@ static int driver_sysfs_add(struct device *dev)
if (!IS_ENABLED(CONFIG_DEV_COREDUMP) || !dev->driver->coredump)
return 0;
- ret = device_create_file(dev, &dev_attr_coredump);
+ ret = device_add_groups(dev, dev_coredump_groups);
if (!ret)
return 0;
@@ -467,7 +496,7 @@ static void driver_sysfs_remove(struct device *dev)
if (drv) {
if (drv->coredump)
- device_remove_file(dev, &dev_attr_coredump);
+ device_remove_groups(dev, dev_coredump_groups);
sysfs_remove_link(&drv->p->kobj, kobject_name(&dev->kobj));
sysfs_remove_link(&dev->kobj, "driver");
}
@@ -255,7 +255,7 @@ void dev_coredumpm(struct device *dev, struct module *owner,
struct devcd_entry *devcd;
struct device *existing;
- if (devcd_disabled)
+ if (devcd_disabled || dev->coredump_disabled)
goto free;
existing = class_find_device(&devcd_class, NULL, dev,
@@ -526,6 +526,8 @@ struct device_physical_location {
* should be set by the subsystem / bus driver that discovered
* the device.
*
+ * @coredump_disabled: Can be used to selectively enable/disable the coredump
+ * functionality for a particular device via sysfs entry.
* @offline_disabled: If set, the device is permanently online.
* @offline: Set after successful invocation of bus type's .offline().
* @of_node_reused: Set if the device-tree node is shared with an ancestor
@@ -637,6 +639,7 @@ struct device {
enum device_removable removable;
+ bool coredump_disabled:1;
bool offline_disabled:1;
bool offline:1;
bool of_node_reused:1;