Merge tag 'devicetree-for-linus' of git://git.secretlab.ca/git/linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 14 Aug 2014 15:53:39 +0000 (09:53 -0600)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 14 Aug 2014 15:53:39 +0000 (09:53 -0600)
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
  ...

1  2 
arch/arm/boot/dts/versatile-ab.dts
arch/arm/boot/dts/versatile-pb.dts
arch/powerpc/kernel/prom.c
arch/powerpc/platforms/powermac/feature.c
arch/powerpc/platforms/pseries/setup.c
drivers/crypto/nx/nx-842.c
drivers/of/fdt.c
drivers/tty/serial/pmac_zilog.c
drivers/tty/serial/serial_core.c

index 36c771a2d765de67cb5ccf80c1fcd629db96fd71,88e94c5506a1dbdd76c79f3746f4b68a5fca8ab8..27d0d9c8adf3da724d9e64ba2e5229731a0b38eb
                i2c0 = &i2c0;
        };
  
+       chosen {
+               stdout-path = &uart0;
+       };
        memory {
                reg = <0x0 0x08000000>;
        };
  
 +      xtal24mhz: xtal24mhz@24M {
 +              #clock-cells = <0>;
 +              compatible = "fixed-clock";
 +              clock-frequency = <24000000>;
 +      };
 +
 +      core-module@10000000 {
 +              compatible = "arm,core-module-versatile", "syscon";
 +              reg = <0x10000000 0x200>;
 +
 +              /* OSC1 on AB, OSC4 on PB */
 +              osc1: cm_aux_osc@24M {
 +                      #clock-cells = <0>;
 +                      compatible = "arm,versatile-cm-auxosc";
 +                      clocks = <&xtal24mhz>;
 +              };
 +
 +              /* The timer clock is the 24 MHz oscillator divided to 1MHz */
 +              timclk: timclk@1M {
 +                      #clock-cells = <0>;
 +                      compatible = "fixed-factor-clock";
 +                      clock-div = <24>;
 +                      clock-mult = <1>;
 +                      clocks = <&xtal24mhz>;
 +              };
 +
 +              pclk: pclk@24M {
 +                      #clock-cells = <0>;
 +                      compatible = "fixed-factor-clock";
 +                      clock-div = <1>;
 +                      clock-mult = <1>;
 +                      clocks = <&xtal24mhz>;
 +              };
 +      };
 +
        flash@34000000 {
                compatible = "arm,versatile-flash";
                reg = <0x34000000 0x4000000>;
@@@ -94,8 -63,6 +98,8 @@@
                        interrupt-controller;
                        #interrupt-cells = <1>;
                        reg = <0x10140000 0x1000>;
 +                      clear-mask = <0xffffffff>;
 +                      valid-mask = <0xffffffff>;
                };
  
                sic: intc@10003000 {
                        reg = <0x10003000 0x1000>;
                        interrupt-parent = <&vic>;
                        interrupts = <31>; /* Cascaded to vic */
 +                      clear-mask = <0xffffffff>;
 +                      valid-mask = <0xffc203f8>;
                };
  
                dma@10130000 {
                        compatible = "arm,pl081", "arm,primecell";
                        reg = <0x10130000 0x1000>;
                        interrupts = <17>;
 +                      clocks = <&pclk>;
 +                      clock-names = "apb_pclk";
                };
  
                uart0: uart@101f1000 {
                        compatible = "arm,pl011", "arm,primecell";
                        reg = <0x101f1000 0x1000>;
                        interrupts = <12>;
 +                      clocks = <&xtal24mhz>, <&pclk>;
 +                      clock-names = "uartclk", "apb_pclk";
                };
  
                uart1: uart@101f2000 {
                        compatible = "arm,pl011", "arm,primecell";
                        reg = <0x101f2000 0x1000>;
                        interrupts = <13>;
 +                      clocks = <&xtal24mhz>, <&pclk>;
 +                      clock-names = "uartclk", "apb_pclk";
                };
  
                uart2: uart@101f3000 {
                        compatible = "arm,pl011", "arm,primecell";
                        reg = <0x101f3000 0x1000>;
                        interrupts = <14>;
 +                      clocks = <&xtal24mhz>, <&pclk>;
 +                      clock-names = "uartclk", "apb_pclk";
                };
  
                smc@10100000 {
                        compatible = "arm,primecell";
                        reg = <0x10100000 0x1000>;
 +                      clocks = <&pclk>;
 +                      clock-names = "apb_pclk";
                };
  
                mpmc@10110000 {
                        compatible = "arm,primecell";
                        reg = <0x10110000 0x1000>;
 +                      clocks = <&pclk>;
 +                      clock-names = "apb_pclk";
                };
  
                display@10120000 {
                        compatible = "arm,pl110", "arm,primecell";
                        reg = <0x10120000 0x1000>;
                        interrupts = <16>;
 +                      clocks = <&osc1>, <&pclk>;
 +                      clock-names = "clcd", "apb_pclk";
                };
  
                sctl@101e0000 {
                        compatible = "arm,primecell";
                        reg = <0x101e0000 0x1000>;
 +                      clocks = <&pclk>;
 +                      clock-names = "apb_pclk";
                };
  
                watchdog@101e1000 {
                        compatible = "arm,primecell";
                        reg = <0x101e1000 0x1000>;
                        interrupts = <0>;
 +                      clocks = <&pclk>;
 +                      clock-names = "apb_pclk";
                };
  
                timer@101e2000 {
                        compatible = "arm,sp804", "arm,primecell";
                        reg = <0x101e2000 0x1000>;
                        interrupts = <4>;
 +                      clocks = <&timclk>, <&timclk>, <&pclk>;
 +                      clock-names = "timer0", "timer1", "apb_pclk";
                };
  
                timer@101e3000 {
                        compatible = "arm,sp804", "arm,primecell";
                        reg = <0x101e3000 0x1000>;
                        interrupts = <5>;
 +                      clocks = <&timclk>, <&timclk>, <&pclk>;
 +                      clock-names = "timer0", "timer1", "apb_pclk";
                };
  
                gpio0: gpio@101e4000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
 +                      clocks = <&pclk>;
 +                      clock-names = "apb_pclk";
                };
  
                gpio1: gpio@101e5000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
 +                      clocks = <&pclk>;
 +                      clock-names = "apb_pclk";
                };
  
                rtc@101e8000 {
                        compatible = "arm,pl030", "arm,primecell";
                        reg = <0x101e8000 0x1000>;
                        interrupts = <10>;
 +                      clocks = <&pclk>;
 +                      clock-names = "apb_pclk";
                };
  
                sci@101f0000 {
                        compatible = "arm,primecell";
                        reg = <0x101f0000 0x1000>;
                        interrupts = <15>;
 +                      clocks = <&pclk>;
 +                      clock-names = "apb_pclk";
                };
  
                ssp@101f4000 {
                        compatible = "arm,pl022", "arm,primecell";
                        reg = <0x101f4000 0x1000>;
                        interrupts = <11>;
 +                      clocks = <&xtal24mhz>, <&pclk>;
 +                      clock-names = "SSPCLK", "apb_pclk";
                };
  
                fpga {
                                compatible = "arm,primecell";
                                reg = <0x4000 0x1000>;
                                interrupts = <24>;
 +                              clocks = <&pclk>;
 +                              clock-names = "apb_pclk";
                        };
                        mmc@5000 {
 -                              compatible = "arm,primecell";
 +                              compatible = "arm,pl180", "arm,primecell";
                                reg = < 0x5000 0x1000>;
                                interrupts-extended = <&vic 22 &sic 2>;
 +                              clocks = <&xtal24mhz>, <&pclk>;
 +                              clock-names = "mclk", "apb_pclk";
                        };
                        kmi@6000 {
                                compatible = "arm,pl050", "arm,primecell";
                                reg = <0x6000 0x1000>;
                                interrupt-parent = <&sic>;
                                interrupts = <3>;
 +                              clocks = <&xtal24mhz>, <&pclk>;
 +                              clock-names = "KMIREFCLK", "apb_pclk";
                        };
                        kmi@7000 {
                                compatible = "arm,pl050", "arm,primecell";
                                reg = <0x7000 0x1000>;
                                interrupt-parent = <&sic>;
                                interrupts = <4>;
 +                              clocks = <&xtal24mhz>, <&pclk>;
 +                              clock-names = "KMIREFCLK", "apb_pclk";
                        };
                };
        };
index d025048119d3078ee1730531071a3e3ca5189d37,8d39677b7d4c8922bd285e24d1c2fe82645e9fe1..e36c1e82fea74d62f7efb7cc3c3585597abd78c2
@@@ -13,8 -13,6 +13,8 @@@
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
 +                      clocks = <&pclk>;
 +                      clock-names = "apb_pclk";
                };
  
                gpio3: gpio@101e7000 {
@@@ -25,8 -23,6 +25,8 @@@
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
 +                      clocks = <&pclk>;
 +                      clock-names = "apb_pclk";
                };
  
                fpga {
                                reg = <0x9000 0x1000>;
                                interrupt-parent = <&sic>;
                                interrupts = <6>;
 +                              clocks = <&xtal24mhz>, <&pclk>;
 +                              clock-names = "uartclk", "apb_pclk";
                        };
                        sci@a000 {
                                compatible = "arm,primecell";
                                reg = <0xa000 0x1000>;
                                interrupt-parent = <&sic>;
                                interrupts = <5>;
 +                              clocks = <&xtal24mhz>;
 +                              clock-names = "apb_pclk";
                        };
                        mmc@b000 {
 -                              compatible = "arm,primecell";
 +                              compatible = "arm,pl180", "arm,primecell";
                                reg = <0xb000 0x1000>;
                                interrupts-extended = <&vic 23 &sic 2>;
 +                              clocks = <&xtal24mhz>, <&pclk>;
 +                              clock-names = "mclk", "apb_pclk";
                        };
                };
        };
  };
- #include <testcases.dtsi>
index 1a3b1055f5ebaf423327401c71612b38c184f12d,9e8d8a880d6f47471680fa41ada60b238498342f..4e139f8a69effa0a403a2e6d75b0fe7d7e268e3d
@@@ -155,6 -155,7 +155,6 @@@ static struct ibm_pa_feature 
  } ibm_pa_features[] __initdata = {
        {0, 0, PPC_FEATURE_HAS_MMU,     0, 0, 0},
        {0, 0, PPC_FEATURE_HAS_FPU,     0, 1, 0},
 -      {0, MMU_FTR_SLB, 0,             0, 2, 0},
        {CPU_FTR_CTRL, 0, 0,            0, 3, 0},
        {CPU_FTR_NOEXECUTE, 0, 0,       0, 6, 0},
        {CPU_FTR_NODSISRALIGN, 0, 0,    1, 1, 1},
@@@ -308,10 -309,12 +308,10 @@@ static int __init early_init_dt_scan_cp
  
        /* Get physical cpuid */
        intserv = of_get_flat_dt_prop(node, "ibm,ppc-interrupt-server#s", &len);
 -      if (intserv) {
 -              nthreads = len / sizeof(int);
 -      } else {
 -              intserv = of_get_flat_dt_prop(node, "reg", NULL);
 -              nthreads = 1;
 -      }
 +      if (!intserv)
 +              intserv = of_get_flat_dt_prop(node, "reg", &len);
 +
 +      nthreads = len / sizeof(int);
  
        /*
         * Now see if any of these threads match our boot cpu.
@@@ -818,76 -821,6 +818,6 @@@ int cpu_to_chip_id(int cpu
  }
  EXPORT_SYMBOL(cpu_to_chip_id);
  
- #ifdef CONFIG_PPC_PSERIES
- /*
-  * Fix up the uninitialized fields in a new device node:
-  * name, type and pci-specific fields
-  */
- static int of_finish_dynamic_node(struct device_node *node)
- {
-       struct device_node *parent = of_get_parent(node);
-       int err = 0;
-       const phandle *ibm_phandle;
-       node->name = of_get_property(node, "name", NULL);
-       node->type = of_get_property(node, "device_type", NULL);
-       if (!node->name)
-               node->name = "<NULL>";
-       if (!node->type)
-               node->type = "<NULL>";
-       if (!parent) {
-               err = -ENODEV;
-               goto out;
-       }
-       /* We don't support that function on PowerMac, at least
-        * not yet
-        */
-       if (machine_is(powermac))
-               return -ENODEV;
-       /* fix up new node's phandle field */
-       if ((ibm_phandle = of_get_property(node, "ibm,phandle", NULL)))
-               node->phandle = *ibm_phandle;
- out:
-       of_node_put(parent);
-       return err;
- }
- static int prom_reconfig_notifier(struct notifier_block *nb,
-                                 unsigned long action, void *node)
- {
-       int err;
-       switch (action) {
-       case OF_RECONFIG_ATTACH_NODE:
-               err = of_finish_dynamic_node(node);
-               if (err < 0)
-                       printk(KERN_ERR "finish_node returned %d\n", err);
-               break;
-       default:
-               err = 0;
-               break;
-       }
-       return notifier_from_errno(err);
- }
- static struct notifier_block prom_reconfig_nb = {
-       .notifier_call = prom_reconfig_notifier,
-       .priority = 10, /* This one needs to run first */
- };
- static int __init prom_reconfig_setup(void)
- {
-       return of_reconfig_notifier_register(&prom_reconfig_nb);
- }
- __initcall(prom_reconfig_setup);
- #endif
  bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
  {
        return (int)phys_id == get_hard_smp_processor_id(cpu);
index 1413e72bc2e1489d38f819041fe476f9ad60c2ef,39e1d163c4271dfb1dd12414350a3c6012c33aba..4882bfd90e27c820b42db5307a08d4c271f48ded
@@@ -158,7 -158,7 +158,7 @@@ static inline int simple_feature_tweak(
        return 0;
  }
  
 -#ifndef CONFIG_POWER4
 +#ifndef CONFIG_PPC64
  
  static long ohare_htw_scc_enable(struct device_node *node, long param,
                                 long value)
@@@ -1318,7 -1318,7 +1318,7 @@@ intrepid_aack_delay_enable(struct devic
  }
  
  
 -#endif /* CONFIG_POWER4 */
 +#endif /* CONFIG_PPC64 */
  
  static long
  core99_read_gpio(struct device_node *node, long param, long value)
@@@ -1338,7 -1338,7 +1338,7 @@@ core99_write_gpio(struct device_node *n
        return 0;
  }
  
 -#ifdef CONFIG_POWER4
 +#ifdef CONFIG_PPC64
  static long g5_gmac_enable(struct device_node *node, long param, long value)
  {
        struct macio_chip *macio = &macio_chips[0];
@@@ -1550,9 -1550,9 +1550,9 @@@ void g5_phy_disable_cpu1(void
        if (uninorth_maj == 3)
                UN_OUT(U3_API_PHY_CONFIG_1, 0);
  }
 -#endif /* CONFIG_POWER4 */
 +#endif /* CONFIG_PPC64 */
  
 -#ifndef CONFIG_POWER4
 +#ifndef CONFIG_PPC64
  
  
  #ifdef CONFIG_PM
@@@ -1864,7 -1864,7 +1864,7 @@@ core99_sleep_state(struct device_node *
        return 0;
  }
  
 -#endif /* CONFIG_POWER4 */
 +#endif /* CONFIG_PPC64 */
  
  static long
  generic_dev_can_wake(struct device_node *node, long param, long value)
@@@ -1906,7 -1906,7 +1906,7 @@@ static struct feature_table_entry any_f
        { 0, NULL }
  };
  
 -#ifndef CONFIG_POWER4
 +#ifndef CONFIG_PPC64
  
  /* OHare based motherboards. Currently, we only use these on the
   * 2400,3400 and 3500 series powerbooks. Some older desktops seem
@@@ -2056,7 -2056,7 +2056,7 @@@ static struct feature_table_entry intre
        { 0, NULL }
  };
  
 -#else /* CONFIG_POWER4 */
 +#else /* CONFIG_PPC64 */
  
  /* G5 features
   */
@@@ -2074,10 -2074,10 +2074,10 @@@ static struct feature_table_entry g5_fe
        { 0, NULL }
  };
  
 -#endif /* CONFIG_POWER4 */
 +#endif /* CONFIG_PPC64 */
  
  static struct pmac_mb_def pmac_mb_defs[] = {
 -#ifndef CONFIG_POWER4
 +#ifndef CONFIG_PPC64
        /*
         * Desktops
         */
                PMAC_TYPE_UNKNOWN_INTREPID,     intrepid_features,
                PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
        },
 -#else /* CONFIG_POWER4 */
 +#else /* CONFIG_PPC64 */
        {       "PowerMac7,2",                  "PowerMac G5",
                PMAC_TYPE_POWERMAC_G5,          g5_features,
                0,
                0,
        },
  #endif /* CONFIG_PPC64 */
 -#endif /* CONFIG_POWER4 */
 +#endif /* CONFIG_PPC64 */
  };
  
  /*
@@@ -2441,7 -2441,7 +2441,7 @@@ static int __init probe_motherboard(voi
  
        /* Fallback to selection depending on mac-io chip type */
        switch(macio->type) {
 -#ifndef CONFIG_POWER4
 +#ifndef CONFIG_PPC64
            case macio_grand_central:
                pmac_mb.model_id = PMAC_TYPE_PSURGE;
                pmac_mb.model_name = "Unknown PowerSurge";
                pmac_mb.model_name = "Unknown Intrepid-based";
                pmac_mb.features = intrepid_features;
                break;
 -#else /* CONFIG_POWER4 */
 +#else /* CONFIG_PPC64 */
        case macio_keylargo2:
                pmac_mb.model_id = PMAC_TYPE_UNKNOWN_K2;
                pmac_mb.model_name = "Unknown K2-based";
                pmac_mb.model_name = "Unknown Shasta-based";
                pmac_mb.features = g5_features;
                break;
 -#endif /* CONFIG_POWER4 */
 +#endif /* CONFIG_PPC64 */
        default:
                ret = -ENODEV;
                goto done;
        }
  found:
 -#ifndef CONFIG_POWER4
 +#ifndef CONFIG_PPC64
        /* Fixup Hooper vs. Comet */
        if (pmac_mb.model_id == PMAC_TYPE_HOOPER) {
                u32 __iomem * mach_id_ptr = ioremap(0xf3000034, 4);
         */
        powersave_lowspeed = 1;
  
 -#else /* CONFIG_POWER4 */
 +#else /* CONFIG_PPC64 */
        powersave_nap = 1;
 -#endif  /* CONFIG_POWER4 */
 +#endif  /* CONFIG_PPC64 */
  
        /* Check for "mobile" machine */
        if (model && (strncmp(model, "PowerBook", 9) == 0
@@@ -2786,7 -2786,7 +2786,7 @@@ set_initial_features(void
                MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
        }
  
 -#ifdef CONFIG_POWER4
 +#ifdef CONFIG_PPC64
        if (macio_chips[0].type == macio_keylargo2 ||
            macio_chips[0].type == macio_shasta) {
  #ifndef CONFIG_SMP
                /* Enable GMAC for now for PCI probing. It will be disabled
                 * later on after PCI probe
                 */
-               np = of_find_node_by_name(NULL, "ethernet");
-               while(np) {
+               for_each_node_by_name(np, "ethernet")
                        if (of_device_is_compatible(np, "K2-GMAC"))
                                g5_gmac_enable(np, 0, 1);
-                       np = of_find_node_by_name(np, "ethernet");
-               }
  
                /* Enable FW before PCI probe. Will be disabled later on
                 * Note: We should have a batter way to check that we are
                 * dealing with uninorth internal cell and not a PCI cell
                 * on the external PCI. The code below works though.
                 */
-               np = of_find_node_by_name(NULL, "firewire");
-               while(np) {
+               for_each_node_by_name(np, "firewire") {
                        if (of_device_is_compatible(np, "pci106b,5811")) {
                                macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
                                g5_fw_enable(np, 0, 1);
                        }
-                       np = of_find_node_by_name(np, "firewire");
                }
        }
 -#else /* CONFIG_POWER4 */
 +#else /* CONFIG_PPC64 */
  
        if (macio_chips[0].type == macio_keylargo ||
            macio_chips[0].type == macio_pangea ||
                /* Enable GMAC for now for PCI probing. It will be disabled
                 * later on after PCI probe
                 */
-               np = of_find_node_by_name(NULL, "ethernet");
-               while(np) {
+               for_each_node_by_name(np, "ethernet") {
                        if (np->parent
                            && of_device_is_compatible(np->parent, "uni-north")
                            && of_device_is_compatible(np, "gmac"))
                                core99_gmac_enable(np, 0, 1);
-                       np = of_find_node_by_name(np, "ethernet");
                }
  
                /* Enable FW before PCI probe. Will be disabled later on
                 * dealing with uninorth internal cell and not a PCI cell
                 * on the external PCI. The code below works though.
                 */
-               np = of_find_node_by_name(NULL, "firewire");
-               while(np) {
+               for_each_node_by_name(np, "firewire") {
                        if (np->parent
                            && of_device_is_compatible(np->parent, "uni-north")
                            && (of_device_is_compatible(np, "pci106b,18") ||
                                macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
                                core99_firewire_enable(np, 0, 1);
                        }
-                       np = of_find_node_by_name(np, "firewire");
                }
  
                /* Enable ATA-100 before PCI probe. */
                np = of_find_node_by_name(NULL, "ata-6");
-               while(np) {
+               for_each_node_by_name(np, "ata-6") {
                        if (np->parent
                            && of_device_is_compatible(np->parent, "uni-north")
                            && of_device_is_compatible(np, "kauai-ata")) {
                                core99_ata100_enable(np, 1);
                        }
-                       np = of_find_node_by_name(np, "ata-6");
                }
  
                /* Switch airport off */
                MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N);
        }
  
 -#endif /* CONFIG_POWER4 */
 +#endif /* CONFIG_PPC64 */
  
        /* On all machines, switch modem & serial ports off */
        for_each_node_by_name(np, "ch-a")
index cfe8a6389a513a29b5b49fc720d9682430eebcac,cd6b4cde0de32c5b15b3aedd7737146ffce41d77..e724d3186e739999cc6daf726d073fe035d26739
@@@ -232,8 -232,7 +232,7 @@@ static void __init pseries_discover_pic
        struct device_node *np;
        const char *typep;
  
-       for (np = NULL; (np = of_find_node_by_name(np,
-                                                  "interrupt-controller"));) {
+       for_each_node_by_name(np, "interrupt-controller") {
                typep = of_get_property(np, "compatible", NULL);
                if (strstr(typep, "open-pic")) {
                        pSeries_mpic_node = of_node_get(np);
@@@ -351,7 -350,7 +350,7 @@@ static int alloc_dispatch_log_kmem_cach
  
        return alloc_dispatch_logs();
  }
 -early_initcall(alloc_dispatch_log_kmem_cache);
 +machine_early_initcall(pseries, alloc_dispatch_log_kmem_cache);
  
  static void pseries_lpar_idle(void)
  {
index 544f6d327ede5512d287bcc87e28663200f873a5,c897c3a5ee17947aebc29225c98d76b523afe30c..061407d5952052add3424f2978267d49e949af3a
@@@ -936,28 -936,14 +936,14 @@@ static int nx842_OF_upd(struct propert
                goto error_out;
        }
  
-       /* Set ptr to new property if provided */
-       if (new_prop) {
-               /* Single property */
-               if (!strncmp(new_prop->name, "status", new_prop->length)) {
-                       status = new_prop;
-               } else if (!strncmp(new_prop->name, "ibm,max-sg-len",
-                                       new_prop->length)) {
-                       maxsglen = new_prop;
-               } else if (!strncmp(new_prop->name, "ibm,max-sync-cop",
-                                       new_prop->length)) {
-                       maxsyncop = new_prop;
-               } else {
-                       /*
-                        * Skip the update, the property being updated
-                        * has no impact.
-                        */
-                       goto out;
-               }
-       }
+       /*
+        * If this is a property update, there are only certain properties that
+        * we care about. Bail if it isn't in the below list
+        */
+       if (new_prop && (strncmp(new_prop->name, "status", new_prop->length) ||
+                        strncmp(new_prop->name, "ibm,max-sg-len", new_prop->length) ||
+                        strncmp(new_prop->name, "ibm,max-sync-cop", new_prop->length)))
+               goto out;
  
        /* Perform property updates */
        ret = nx842_OF_upd_status(new_devdata, status);
@@@ -1247,7 -1233,7 +1233,7 @@@ static struct vio_device_id nx842_drive
  static struct vio_driver nx842_driver = {
        .name = MODULE_NAME,
        .probe = nx842_probe,
 -      .remove = nx842_remove,
 +      .remove = __exit_p(nx842_remove),
        .get_desired_dma = nx842_get_desired_dma,
        .id_table = nx842_driver_ids,
  };
diff --combined drivers/of/fdt.c
index 9aa012e6ea0a6ed988150624bacc0eb2b8066c06,b88a68eee86bd2537f8acf0e310b6c73732ee71c..f46a24ffa3fe7be040d488bc49bfba912848fde1
  #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
  #include <asm/page.h>
  
 +/*
 + * of_fdt_limit_memory - limit the number of regions in the /memory node
 + * @limit: maximum entries
 + *
 + * Adjust the flattened device tree to have at most 'limit' number of
 + * memory entries in the /memory node. This function may be called
 + * any time after initial_boot_param is set.
 + */
 +void of_fdt_limit_memory(int limit)
 +{
 +      int memory;
 +      int len;
 +      const void *val;
 +      int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
 +      int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
 +      const uint32_t *addr_prop;
 +      const uint32_t *size_prop;
 +      int root_offset;
 +      int cell_size;
 +
 +      root_offset = fdt_path_offset(initial_boot_params, "/");
 +      if (root_offset < 0)
 +              return;
 +
 +      addr_prop = fdt_getprop(initial_boot_params, root_offset,
 +                              "#address-cells", NULL);
 +      if (addr_prop)
 +              nr_address_cells = fdt32_to_cpu(*addr_prop);
 +
 +      size_prop = fdt_getprop(initial_boot_params, root_offset,
 +                              "#size-cells", NULL);
 +      if (size_prop)
 +              nr_size_cells = fdt32_to_cpu(*size_prop);
 +
 +      cell_size = sizeof(uint32_t)*(nr_address_cells + nr_size_cells);
 +
 +      memory = fdt_path_offset(initial_boot_params, "/memory");
 +      if (memory > 0) {
 +              val = fdt_getprop(initial_boot_params, memory, "reg", &len);
 +              if (len > limit*cell_size) {
 +                      len = limit*cell_size;
 +                      pr_debug("Limiting number of entries to %d\n", limit);
 +                      fdt_setprop(initial_boot_params, memory, "reg", val,
 +                                      len);
 +              }
 +      }
 +}
 +
  /**
   * of_fdt_is_compatible - Return true if given node from the given blob has
   * compat in its compatible list
@@@ -923,24 -875,24 +923,24 @@@ int __init early_init_dt_scan_chosen(un
  }
  
  #ifdef CONFIG_HAVE_MEMBLOCK
+ #define MAX_PHYS_ADDR ((phys_addr_t)~0)
  void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
  {
        const u64 phys_offset = __pa(PAGE_OFFSET);
        base &= PAGE_MASK;
        size &= PAGE_MASK;
  
-       if (sizeof(phys_addr_t) < sizeof(u64)) {
-               if (base > ULONG_MAX) {
-                       pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
-                                       base, base + size);
-                       return;
-               }
+       if (base > MAX_PHYS_ADDR) {
+               pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
+                               base, base + size);
+               return;
+       }
  
-               if (base + size > ULONG_MAX) {
-                       pr_warning("Ignoring memory range 0x%lx - 0x%llx\n",
-                                       ULONG_MAX, base + size);
-                       size = ULONG_MAX - base;
-               }
+       if (base + size > MAX_PHYS_ADDR) {
+               pr_warning("Ignoring memory range 0x%lx - 0x%llx\n",
+                               ULONG_MAX, base + size);
+               size = MAX_PHYS_ADDR - base;
        }
  
        if (base + size < phys_offset) {
@@@ -985,7 -937,7 +985,7 @@@ int __init __weak early_init_dt_reserve
  }
  #endif
  
 -bool __init early_init_dt_scan(void *params)
 +bool __init early_init_dt_verify(void *params)
  {
        if (!params)
                return false;
                return false;
        }
  
 +      return true;
 +}
 +
 +
 +void __init early_init_dt_scan_nodes(void)
 +{
        /* Retrieve various information from the /chosen node */
        of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);
  
  
        /* Setup memory, calling early_init_dt_add_memory_arch */
        of_scan_flat_dt(early_init_dt_scan_memory, NULL);
 +}
 +
 +bool __init early_init_dt_scan(void *params)
 +{
 +      bool status;
 +
 +      status = early_init_dt_verify(params);
 +      if (!status)
 +              return false;
  
 +      early_init_dt_scan_nodes();
        return true;
  }
  
index f7ad5b903055852fad68d2a69a2f826e5f795172,01e180bc6b5d1c27b7120fa5296683c4b865138e..abbfedb84901731793aeddef5a98910c72520b42
@@@ -653,8 -653,6 +653,8 @@@ static void pmz_start_tx(struct uart_po
        } else {
                struct circ_buf *xmit = &port->state->xmit;
  
 +              if (uart_circ_empty(xmit))
 +                      goto out;
                write_zsdata(uap, xmit->buf[xmit->tail]);
                zssync(uap);
                xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
                if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
                        uart_write_wakeup(&uap->port);
        }
 + out:
        pmz_debug("pmz: start_tx() done.\n");
  }
  
@@@ -1653,8 -1650,7 +1653,7 @@@ static int __init pmz_probe(void
        /*
         * Find all escc chips in the system
         */
-       node_p = of_find_node_by_name(NULL, "escc");
-       while (node_p) {
+       for_each_node_by_name(node_p, "escc") {
                /*
                 * First get channel A/B node pointers
                 * 
                        of_node_put(node_b);
                        printk(KERN_ERR "pmac_zilog: missing node %c for escc %s\n",
                                (!node_a) ? 'a' : 'b', node_p->full_name);
-                       goto next;
+                       continue;
                }
  
                /*
                        of_node_put(node_b);
                        memset(&pmz_ports[count], 0, sizeof(struct uart_pmac_port));
                        memset(&pmz_ports[count+1], 0, sizeof(struct uart_pmac_port));
-                       goto next;
+                       continue;
                }
                count += 2;
- next:
-               node_p = of_find_node_by_name(node_p, "escc");
        }
        pmz_ports_count = count;
  
index 8bb19da01639bb51cc2bc88f40cada8f686cc5a2,3ce68f962c9238275c3d8b11aa12a14ea9561a32..29a7be47389a9339fe2c049f7d3ee2cfd6160397
@@@ -26,6 -26,7 +26,7 @@@
  #include <linux/slab.h>
  #include <linux/init.h>
  #include <linux/console.h>
+ #include <linux/of.h>
  #include <linux/proc_fs.h>
  #include <linux/seq_file.h>
  #include <linux/device.h>
@@@ -243,9 -244,6 +244,9 @@@ static void uart_shutdown(struct tty_st
                /*
                 * Turn off DTR and RTS early.
                 */
 +              if (uart_console(uport) && tty)
 +                      uport->cons->cflag = tty->termios.c_cflag;
 +
                if (!tty || (tty->termios.c_cflag & HUPCL))
                        uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
  
@@@ -450,7 -448,6 +451,7 @@@ static void uart_change_speed(struct tt
                return;
  
        termios = &tty->termios;
 +      uport->ops->set_termios(uport, termios, old_termios);
  
        /*
         * Set flags based on termios cflag
                clear_bit(ASYNCB_CHECK_CD, &port->flags);
        else
                set_bit(ASYNCB_CHECK_CD, &port->flags);
 -
 -      uport->ops->set_termios(uport, termios, old_termios);
  }
  
  static inline int __uart_put_char(struct uart_port *port,
@@@ -1052,15 -1051,6 +1053,15 @@@ static int uart_do_autoconfig(struct tt
        return ret;
  }
  
 +static void uart_enable_ms(struct uart_port *uport)
 +{
 +      /*
 +       * Force modem status interrupts on
 +       */
 +      if (uport->ops->enable_ms)
 +              uport->ops->enable_ms(uport);
 +}
 +
  /*
   * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
   * - mask passed in arg for lines of interest
@@@ -1084,7 -1074,11 +1085,7 @@@ uart_wait_modem_status(struct uart_stat
         */
        spin_lock_irq(&uport->lock);
        memcpy(&cprev, &uport->icount, sizeof(struct uart_icount));
 -
 -      /*
 -       * Force modem status interrupts on
 -       */
 -      uport->ops->enable_ms(uport);
 +      uart_enable_ms(uport);
        spin_unlock_irq(&uport->lock);
  
        add_wait_queue(&port->delta_msr_wait, &wait);
@@@ -1281,8 -1275,6 +1282,8 @@@ static void uart_set_termios(struct tty
        }
  
        uart_change_speed(tty, state, old_termios);
 +      /* reload cflag from termios; port driver may have overriden flags */
 +      cflag = tty->termios.c_cflag;
  
        /* Handle transition to B0 status */
        if ((old_termios->c_cflag & CBAUD) && !(cflag & CBAUD))
@@@ -1369,8 -1361,8 +1370,8 @@@ static void uart_close(struct tty_struc
        tty_ldisc_flush(tty);
  
        tty_port_tty_set(port, NULL);
 -      spin_lock_irqsave(&port->lock, flags);
        tty->closing = 0;
 +      spin_lock_irqsave(&port->lock, flags);
  
        if (port->blocked_open) {
                spin_unlock_irqrestore(&port->lock, flags);
@@@ -1517,7 -1509,7 +1518,7 @@@ static int uart_carrier_raised(struct t
        struct uart_port *uport = state->uart_port;
        int mctrl;
        spin_lock_irq(&uport->lock);
 -      uport->ops->enable_ms(uport);
 +      uart_enable_ms(uport);
        mctrl = uport->ops->get_mctrl(uport);
        spin_unlock_irq(&uport->lock);
        if (mctrl & TIOCM_CAR)
@@@ -1584,6 -1576,14 +1585,6 @@@ static int uart_open(struct tty_struct 
                (state->uart_port->flags & UPF_LOW_LATENCY) ? 1 : 0;
        tty_port_tty_set(port, tty);
  
 -      /*
 -       * If the port is in the middle of closing, bail out now.
 -       */
 -      if (tty_hung_up_p(filp)) {
 -              retval = -EAGAIN;
 -              goto err_dec_count;
 -      }
 -
        /*
         * Start up the serial port.
         */
@@@ -2564,6 -2564,12 +2565,6 @@@ static const struct attribute_group tty
        .attrs = tty_dev_attrs,
        };
  
 -static const struct attribute_group *tty_dev_attr_groups[] = {
 -      &tty_dev_attr_group,
 -      NULL
 -      };
 -
 -
  /**
   *    uart_add_one_port - attach a driver-defined port structure
   *    @drv: pointer to the uart low level driver structure for this port
@@@ -2580,7 -2586,6 +2581,7 @@@ int uart_add_one_port(struct uart_drive
        struct tty_port *port;
        int ret = 0;
        struct device *tty_dev;
 +      int num_groups;
  
        BUG_ON(in_interrupt());
  
                spin_lock_init(&uport->lock);
                lockdep_set_class(&uport->lock, &port_lock_key);
        }
+       if (uport->cons && uport->dev)
+               of_console_check(uport->dev->of_node, uport->cons->name, uport->line);
  
        uart_configure_port(drv, state, uport);
  
 +      num_groups = 2;
 +      if (uport->attr_group)
 +              num_groups++;
 +
 +      uport->tty_groups = kcalloc(num_groups, sizeof(*uport->tty_groups),
 +                                  GFP_KERNEL);
 +      if (!uport->tty_groups) {
 +              ret = -ENOMEM;
 +              goto out;
 +      }
 +      uport->tty_groups[0] = &tty_dev_attr_group;
 +      if (uport->attr_group)
 +              uport->tty_groups[1] = uport->attr_group;
 +
        /*
         * Register the port whether it's detected or not.  This allows
         * setserial to be used to alter this port's parameters.
         */
        tty_dev = tty_port_register_device_attr(port, drv->tty_driver,
 -                      uport->line, uport->dev, port, tty_dev_attr_groups);
 +                      uport->line, uport->dev, port, uport->tty_groups);
        if (likely(!IS_ERR(tty_dev))) {
                device_set_wakeup_capable(tty_dev, 1);
        } else {
@@@ -2712,7 -2705,6 +2715,7 @@@ int uart_remove_one_port(struct uart_dr
         */
        if (uport->type != PORT_UNKNOWN)
                uport->ops->release_port(uport);
 +      kfree(uport->tty_groups);
  
        /*
         * Indicate that there isn't a port here anymore.