From 7c1ef338705fb5c53e6f574ae5eb19fdfacb3d26 Mon Sep 17 00:00:00 2001 From: Gabriel Krisman Bertazi Date: Mon, 6 Jan 2020 13:58:15 -0500 Subject: scsi: drivers: base: Support atomic version of attribute_container_device_trigger attribute_container_device_trigger invokes callbacks that may fail for one or more classdevs, for instance, the transport_add_class_device callback, called during transport creation, does memory allocation. This information, though, is not propagated to upper layers, and any driver using the attribute_container_device_trigger API will not know whether any, some, or all callbacks succeeded. This patch implements a safe version of this dispatcher, to either succeed all the callbacks or revert to the original state. Link: https://lore.kernel.org/r/20200106185817.640331-2-krisman@collabora.com Reviewed-by: Greg Kroah-Hartman Signed-off-by: Gabriel Krisman Bertazi Signed-off-by: Martin K. Petersen --- include/linux/attribute_container.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/linux/attribute_container.h b/include/linux/attribute_container.h index d12bb2153cd6..e4004d1e6725 100644 --- a/include/linux/attribute_container.h +++ b/include/linux/attribute_container.h @@ -54,6 +54,13 @@ void attribute_container_device_trigger(struct device *dev, int (*fn)(struct attribute_container *, struct device *, struct device *)); +int attribute_container_device_trigger_safe(struct device *dev, + int (*fn)(struct attribute_container *, + struct device *, + struct device *), + int (*undo)(struct attribute_container *, + struct device *, + struct device *)); void attribute_container_trigger(struct device *dev, int (*fn)(struct attribute_container *, struct device *)); -- cgit v1.2.3-59-g8ed1b