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