162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci=====================
462306a36Sopenharmony_ciDevicetree Changesets
562306a36Sopenharmony_ci=====================
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciA Devicetree changeset is a method which allows one to apply changes
862306a36Sopenharmony_ciin the live tree in such a way that either the full set of changes
962306a36Sopenharmony_ciwill be applied, or none of them will be. If an error occurs partway
1062306a36Sopenharmony_cithrough applying the changeset, then the tree will be rolled back to the
1162306a36Sopenharmony_ciprevious state. A changeset can also be removed after it has been
1262306a36Sopenharmony_ciapplied.
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciWhen a changeset is applied, all of the changes get applied to the tree
1562306a36Sopenharmony_ciat once before emitting OF_RECONFIG notifiers. This is so that the
1662306a36Sopenharmony_cireceiver sees a complete and consistent state of the tree when it
1762306a36Sopenharmony_cireceives the notifier.
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciThe sequence of a changeset is as follows.
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci1. of_changeset_init() - initializes a changeset
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci2. A number of DT tree change calls, of_changeset_attach_node(),
2462306a36Sopenharmony_ci   of_changeset_detach_node(), of_changeset_add_property(),
2562306a36Sopenharmony_ci   of_changeset_remove_property, of_changeset_update_property() to prepare
2662306a36Sopenharmony_ci   a set of changes. No changes to the active tree are made at this point.
2762306a36Sopenharmony_ci   All the change operations are recorded in the of_changeset 'entries'
2862306a36Sopenharmony_ci   list.
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci3. of_changeset_apply() - Apply the changes to the tree. Either the
3162306a36Sopenharmony_ci   entire changeset will get applied, or if there is an error the tree will
3262306a36Sopenharmony_ci   be restored to the previous state. The core ensures proper serialization
3362306a36Sopenharmony_ci   through locking. An unlocked version __of_changeset_apply is available,
3462306a36Sopenharmony_ci   if needed.
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ciIf a successfully applied changeset needs to be removed, it can be done
3762306a36Sopenharmony_ciwith of_changeset_revert().
38