Skip to content

Commit ae36e95

Browse files
committed
Merge tag 'devicetree-for-linus' of git://git.secretlab.ca/git/linux
Pull device tree updates from Grant Likely: "The branch contains the following device tree changes the v3.17 merge window: Group changes to the device tree. In preparation for adding device tree overlay support, OF_DYNAMIC is reworked so that a set of device tree changes can be prepared and applied to the tree all at once. OF_RECONFIG notifiers see the most significant change here so that users always get a consistent view of the tree. Notifiers generation is moved from before a change to after it, and notifiers for a group of changes are emitted after the entire block of changes have been applied Automatic console selection from DT. Console drivers can now use of_console_check() to see if the device node is specified as a console device. If so then it gets added as a preferred console. UART devices get this support automatically when uart_add_one_port() is called. DT unit tests no longer depend on pre-loaded data in the device tree. Data is loaded dynamically at the start of unit tests, and then unloaded again when the tests have completed. Also contains a few bugfixes for reserved regions and early memory setup" * tag 'devicetree-for-linus' of git://git.secretlab.ca/git/linux: (21 commits) of: Fixing OF Selftest build error drivers: of: add automated assignment of reserved regions to client devices of: Use proper types for checking memory overflow of: typo fix in __of_prop_dup() Adding selftest testdata dynamically into live tree of: Add todo tasklist for Devicetree of: Transactional DT support. of: Reorder device tree changes and notifiers of: Move dynamic node fixups out of powerpc and into common code of: Make sure attached nodes don't carry along extra children of: Make devicetree sysfs update functions consistent. of: Create unlocked versions of node and property add/remove functions OF: Utility helper functions for dynamic nodes of: Move CONFIG_OF_DYNAMIC code into a separate file of: rename of_aliases_mutex to just of_mutex of/platform: Fix of_platform_device_destroy iteration of devices of: Migrate of_find_node_by_name() users to for_each_node_by_name() tty: Update hypervisor tty drivers to use core stdout parsing code. arm/versatile: Add the uart as the stdout device. of: Enable console on serial ports specified by /chosen/stdout-path ...
2 parents cc8a44c + 663d3f7 commit ae36e95

36 files changed

Lines changed: 1382 additions & 581 deletions
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
A DT changeset is a method which allows one to apply changes
2+
in the live tree in such a way that either the full set of changes
3+
will be applied, or none of them will be. If an error occurs partway
4+
through applying the changeset, then the tree will be rolled back to the
5+
previous state. A changeset can also be removed after it has been
6+
applied.
7+
8+
When a changeset is applied, all of the changes get applied to the tree
9+
at once before emitting OF_RECONFIG notifiers. This is so that the
10+
receiver sees a complete and consistent state of the tree when it
11+
receives the notifier.
12+
13+
The sequence of a changeset is as follows.
14+
15+
1. of_changeset_init() - initializes a changeset
16+
17+
2. A number of DT tree change calls, of_changeset_attach_node(),
18+
of_changeset_detach_node(), of_changeset_add_property(),
19+
of_changeset_remove_property, of_changeset_update_property() to prepare
20+
a set of changes. No changes to the active tree are made at this point.
21+
All the change operations are recorded in the of_changeset 'entries'
22+
list.
23+
24+
3. mutex_lock(of_mutex) - starts a changeset; The global of_mutex
25+
ensures there can only be one editor at a time.
26+
27+
4. of_changeset_apply() - Apply the changes to the tree. Either the
28+
entire changeset will get applied, or if there is an error the tree will
29+
be restored to the previous state
30+
31+
5. mutex_unlock(of_mutex) - All operations complete, release the mutex
32+
33+
If a successfully applied changeset needs to be removed, it can be done
34+
with the following sequence.
35+
36+
1. mutex_lock(of_mutex)
37+
38+
2. of_changeset_revert()
39+
40+
3. mutex_unlock(of_mutex)

‎Documentation/devicetree/todo.txt‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Todo list for devicetree:
2+
3+
=== General structure ===
4+
- Switch from custom lists to (h)list_head for nodes and properties structure
5+
- Remove of_allnodes list and iterate using list of child nodes alone
6+
7+
=== CONFIG_OF_DYNAMIC ===
8+
- Switch to RCU for tree updates and get rid of global spinlock
9+
- Document node lifecycle for CONFIG_OF_DYNAMIC
10+
- Always set ->full_name at of_attach_node() time
11+
- pseries: Get rid of open-coded tree modification from arch/powerpc/platforms/pseries/dlpar.c

‎arch/arm/boot/dts/versatile-ab.dts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
i2c0 = &i2c0;
1616
};
1717

18+
chosen {
19+
stdout-path = &uart0;
20+
};
21+
1822
memory {
1923
reg = <0x0 0x08000000>;
2024
};

‎arch/arm/boot/dts/versatile-pb.dts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,3 @@
5656
};
5757
};
5858
};
59-
60-
#include <testcases.dtsi>

‎arch/powerpc/kernel/prom.c‎

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -818,76 +818,6 @@ int cpu_to_chip_id(int cpu)
818818
}
819819
EXPORT_SYMBOL(cpu_to_chip_id);
820820

821-
#ifdef CONFIG_PPC_PSERIES
822-
/*
823-
* Fix up the uninitialized fields in a new device node:
824-
* name, type and pci-specific fields
825-
*/
826-
827-
static int of_finish_dynamic_node(struct device_node *node)
828-
{
829-
struct device_node *parent = of_get_parent(node);
830-
int err = 0;
831-
const phandle *ibm_phandle;
832-
833-
node->name = of_get_property(node, "name", NULL);
834-
node->type = of_get_property(node, "device_type", NULL);
835-
836-
if (!node->name)
837-
node->name = "<NULL>";
838-
if (!node->type)
839-
node->type = "<NULL>";
840-
841-
if (!parent) {
842-
err = -ENODEV;
843-
goto out;
844-
}
845-
846-
/* We don't support that function on PowerMac, at least
847-
* not yet
848-
*/
849-
if (machine_is(powermac))
850-
return -ENODEV;
851-
852-
/* fix up new node's phandle field */
853-
if ((ibm_phandle = of_get_property(node, "ibm,phandle", NULL)))
854-
node->phandle = *ibm_phandle;
855-
856-
out:
857-
of_node_put(parent);
858-
return err;
859-
}
860-
861-
static int prom_reconfig_notifier(struct notifier_block *nb,
862-
unsigned long action, void *node)
863-
{
864-
int err;
865-
866-
switch (action) {
867-
case OF_RECONFIG_ATTACH_NODE:
868-
err = of_finish_dynamic_node(node);
869-
if (err < 0)
870-
printk(KERN_ERR "finish_node returned %d\n", err);
871-
break;
872-
default:
873-
err = 0;
874-
break;
875-
}
876-
return notifier_from_errno(err);
877-
}
878-
879-
static struct notifier_block prom_reconfig_nb = {
880-
.notifier_call = prom_reconfig_notifier,
881-
.priority = 10, /* This one needs to run first */
882-
};
883-
884-
static int __init prom_reconfig_setup(void)
885-
{
886-
return of_reconfig_notifier_register(&prom_reconfig_nb);
887-
}
888-
__initcall(prom_reconfig_setup);
889-
#endif
890-
891821
bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
892822
{
893823
return (int)phys_id == get_hard_smp_processor_id(cpu);

‎arch/powerpc/platforms/powermac/feature.c‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,25 +2805,20 @@ set_initial_features(void)
28052805
/* Enable GMAC for now for PCI probing. It will be disabled
28062806
* later on after PCI probe
28072807
*/
2808-
np = of_find_node_by_name(NULL, "ethernet");
2809-
while(np) {
2808+
for_each_node_by_name(np, "ethernet")
28102809
if (of_device_is_compatible(np, "K2-GMAC"))
28112810
g5_gmac_enable(np, 0, 1);
2812-
np = of_find_node_by_name(np, "ethernet");
2813-
}
28142811

28152812
/* Enable FW before PCI probe. Will be disabled later on
28162813
* Note: We should have a batter way to check that we are
28172814
* dealing with uninorth internal cell and not a PCI cell
28182815
* on the external PCI. The code below works though.
28192816
*/
2820-
np = of_find_node_by_name(NULL, "firewire");
2821-
while(np) {
2817+
for_each_node_by_name(np, "firewire") {
28222818
if (of_device_is_compatible(np, "pci106b,5811")) {
28232819
macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
28242820
g5_fw_enable(np, 0, 1);
28252821
}
2826-
np = of_find_node_by_name(np, "firewire");
28272822
}
28282823
}
28292824
#else /* CONFIG_PPC64 */
@@ -2834,22 +2829,19 @@ set_initial_features(void)
28342829
/* Enable GMAC for now for PCI probing. It will be disabled
28352830
* later on after PCI probe
28362831
*/
2837-
np = of_find_node_by_name(NULL, "ethernet");
2838-
while(np) {
2832+
for_each_node_by_name(np, "ethernet") {
28392833
if (np->parent
28402834
&& of_device_is_compatible(np->parent, "uni-north")
28412835
&& of_device_is_compatible(np, "gmac"))
28422836
core99_gmac_enable(np, 0, 1);
2843-
np = of_find_node_by_name(np, "ethernet");
28442837
}
28452838

28462839
/* Enable FW before PCI probe. Will be disabled later on
28472840
* Note: We should have a batter way to check that we are
28482841
* dealing with uninorth internal cell and not a PCI cell
28492842
* on the external PCI. The code below works though.
28502843
*/
2851-
np = of_find_node_by_name(NULL, "firewire");
2852-
while(np) {
2844+
for_each_node_by_name(np, "firewire") {
28532845
if (np->parent
28542846
&& of_device_is_compatible(np->parent, "uni-north")
28552847
&& (of_device_is_compatible(np, "pci106b,18") ||
@@ -2858,18 +2850,16 @@ set_initial_features(void)
28582850
macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
28592851
core99_firewire_enable(np, 0, 1);
28602852
}
2861-
np = of_find_node_by_name(np, "firewire");
28622853
}
28632854

28642855
/* Enable ATA-100 before PCI probe. */
28652856
np = of_find_node_by_name(NULL, "ata-6");
2866-
while(np) {
2857+
for_each_node_by_name(np, "ata-6") {
28672858
if (np->parent
28682859
&& of_device_is_compatible(np->parent, "uni-north")
28692860
&& of_device_is_compatible(np, "kauai-ata")) {
28702861
core99_ata100_enable(np, 1);
28712862
}
2872-
np = of_find_node_by_name(np, "ata-6");
28732863
}
28742864

28752865
/* Switch airport off */

‎arch/powerpc/platforms/powermac/pci.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ static void __init fixup_nec_usb2(void)
698698
{
699699
struct device_node *nec;
700700

701-
for (nec = NULL; (nec = of_find_node_by_name(nec, "usb")) != NULL;) {
701+
for_each_node_by_name(nec, "usb") {
702702
struct pci_controller *hose;
703703
u32 data;
704704
const u32 *prop;

‎arch/powerpc/platforms/powermac/smp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ static void __init smp_core99_setup_i2c_hwsync(int ncpus)
577577
int ok;
578578

579579
/* Look for the clock chip */
580-
while ((cc = of_find_node_by_name(cc, "i2c-hwclock")) != NULL) {
580+
for_each_node_by_name(cc, "i2c-hwclock") {
581581
p = of_get_parent(cc);
582582
ok = p && of_device_is_compatible(p, "uni-n-i2c");
583583
of_node_put(p);

‎arch/powerpc/platforms/powermac/udbg_adb.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ int __init udbg_adb_init(int force_btext)
191191
* of type "adb". If not, we return a failure, but we keep the
192192
* bext output set for now
193193
*/
194-
for (np = NULL; (np = of_find_node_by_name(np, "keyboard")) != NULL;) {
194+
for_each_node_by_name(np, "keyboard") {
195195
struct device_node *parent = of_get_parent(np);
196196
int found = (parent && strcmp(parent->type, "adb") == 0);
197197
of_node_put(parent);

‎arch/powerpc/platforms/pseries/hotplug-memory.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static int pseries_update_drconf_memory(struct of_prop_reconfig *pr)
194194
if (!memblock_size)
195195
return -EINVAL;
196196

197-
p = (u32 *)of_get_property(pr->dn, "ibm,dynamic-memory", NULL);
197+
p = (u32 *) pr->old_prop->value;
198198
if (!p)
199199
return -EINVAL;
200200

0 commit comments

Comments
 (0)