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.
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -54,6 +54,13 @@ void attribute_container_device_trigger(struct device *dev, · 53 unmodified lines | |||
| 54 | int (*fn)(struct attribute_container *, | 54 | int (*fn)(struct attribute_container *, |
| 55 | struct device *, | 55 | struct device *, |
| 56 | struct device *)); | 56 | struct device *)); |
| 57 | int attribute_container_device_trigger_safe(struct device *dev, | ||
| 58 | int (*fn)(struct attribute_container *, | ||
| 59 | struct device *, | ||
| 60 | struct device *), | ||
| 61 | int (*undo)(struct attribute_container *, | ||
| 62 | struct device *, | ||
| 63 | struct device *)); | ||
| 57 | void attribute_container_trigger(struct device *dev, | 64 | void attribute_container_trigger(struct device *dev, |
| 58 | int (*fn)(struct attribute_container *, | 65 | int (*fn)(struct attribute_container *, |
| 59 | struct device *)); | 66 | struct device *)); |