^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) =============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) DT Changesets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) =============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) A DT changeset is a method which allows one to apply changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) in the live tree in such a way that either the full set of changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) will be applied, or none of them will be. If an error occurs partway
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) through applying the changeset, then the tree will be rolled back to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) previous state. A changeset can also be removed after it has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) applied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) When a changeset is applied, all of the changes get applied to the tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) at once before emitting OF_RECONFIG notifiers. This is so that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) receiver sees a complete and consistent state of the tree when it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) receives the notifier.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) The sequence of a changeset is as follows.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 1. of_changeset_init() - initializes a changeset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 2. A number of DT tree change calls, of_changeset_attach_node(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) of_changeset_detach_node(), of_changeset_add_property(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) of_changeset_remove_property, of_changeset_update_property() to prepare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) a set of changes. No changes to the active tree are made at this point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) All the change operations are recorded in the of_changeset 'entries'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 3. of_changeset_apply() - Apply the changes to the tree. Either the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) entire changeset will get applied, or if there is an error the tree will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) be restored to the previous state. The core ensures proper serialization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) through locking. An unlocked version __of_changeset_apply is available,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) if needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) If a successfully applied changeset needs to be removed, it can be done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) with of_changeset_revert().