FROMLIST: devcoredump: Add per device sysfs entry to enable/disable coredump

The /sys/class/devcoredump/disabled provides only one-way disable
functionality. Also, disabling devcoredump using it disables the
devcoredump functionality for everyone who is using it.

Provide a way to selectively enable/disable devcoredump for the device
which is bound to a driver that implements the '.coredump()' callback.

This adds the 'coredump_disabled' driver attribute. When the driver
implements the '.coredump()' callback, 'coredump_disabled' file is added
along with the 'coredump' file in the sysfs folder of the device upon
driver binding. The file is removed when the driver is unbound.

Drivers can use this attribute to enable/disable devcoredump and the
userspace can write 0 or 1 to /sys/devices/.../coredump_disabled sysfs
entry to control enabling/disabling of devcoredump for that device.

Signed-off-by: Manish Mandlik <mmandlik@google.com>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
(am from https://patchwork.kernel.org/patch/12940741)

BUG=b:154866409
TEST=Build

Change-Id: Ief1110784c6c1c3ac0ee5677c2d28d785af8686d
Signed-off-by: Manish Mandlik <mmandlik@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3760827
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@google.com>
Tested-by: Manish Mandlik <mmandlik@chromium.org>
Reviewed-by: Sean Paul <sean@poorly.run>
Commit-Queue: Manish Mandlik <mmandlik@chromium.org>
3 files changed