Merge branch 'merge'
Paul Mackerras [Tue, 8 Aug 2006 07:09:11 +0000 (17:09 +1000)]
1  2 
arch/powerpc/kernel/rtas.c
arch/powerpc/platforms/pseries/setup.c
arch/powerpc/platforms/pseries/xics.c
drivers/char/hvsi.c
sound/aoa/core/snd-aoa-gpio-feature.c
sound/ppc/tumbler.c

@@@ -177,12 -177,10 +177,12 @@@ void __init udbg_init_rtas_console(void
  void rtas_progress(char *s, unsigned short hex)
  {
        struct device_node *root;
 -      int width, *p;
 +      int width;
 +      const int *p;
        char *os;
        static int display_character, set_indicator;
 -      static int display_width, display_lines, *row_width, form_feed;
 +      static int display_width, display_lines, form_feed;
 +      const static int *row_width;
        static DEFINE_SPINLOCK(progress_lock);
        static int current_line;
        static int pending_newline = 0;  /* did last write end with unprinted newline? */
        if (display_width == 0) {
                display_width = 0x10;
                if ((root = find_path_device("/rtas"))) {
 -                      if ((p = (unsigned int *)get_property(root,
 +                      if ((p = get_property(root,
                                        "ibm,display-line-length", NULL)))
                                display_width = *p;
 -                      if ((p = (unsigned int *)get_property(root,
 +                      if ((p = get_property(root,
                                        "ibm,form-feed", NULL)))
                                form_feed = *p;
 -                      if ((p = (unsigned int *)get_property(root,
 +                      if ((p = get_property(root,
                                        "ibm,display-number-of-lines", NULL)))
                                display_lines = *p;
 -                      row_width = (unsigned int *)get_property(root,
 +                      row_width = get_property(root,
                                        "ibm,display-truncation-length", NULL);
                }
                display_character = rtas_token("display-character");
@@@ -295,10 -293,10 +295,10 @@@ EXPORT_SYMBOL(rtas_progress);           /* neede
  
  int rtas_token(const char *service)
  {
 -      int *tokp;
 +      const int *tokp;
        if (rtas.dev == NULL)
                return RTAS_UNKNOWN_SERVICE;
 -      tokp = (int *) get_property(rtas.dev, service, NULL);
 +      tokp = get_property(rtas.dev, service, NULL);
        return tokp ? *tokp : RTAS_UNKNOWN_SERVICE;
  }
  EXPORT_SYMBOL(rtas_token);
@@@ -571,6 -569,27 +571,27 @@@ int rtas_set_indicator(int indicator, i
  }
  EXPORT_SYMBOL(rtas_set_indicator);
  
+ /*
+  * Ignoring RTAS extended delay
+  */
+ int rtas_set_indicator_fast(int indicator, int index, int new_value)
+ {
+       int rc;
+       int token = rtas_token("set-indicator");
+       if (token == RTAS_UNKNOWN_SERVICE)
+               return -ENOENT;
+       rc = rtas_call(token, 3, 1, NULL, indicator, index, new_value);
+       WARN_ON(rc == -2 || (rc >= 9900 && rc <= 9905));
+       if (rc < 0)
+               return rtas_error_rc(rc);
+       return rc;
+ }
  void rtas_restart(char *cmd)
  {
        if (rtas_flash_term_hook)
@@@ -668,14 -687,15 +689,14 @@@ static int rtas_ibm_suspend_me(struct r
        int i;
        long state;
        long rc;
 -      unsigned long dummy;
 -
 +      unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
        struct rtas_suspend_me_data data;
  
        /* Make sure the state is valid */
 -      rc = plpar_hcall(H_VASI_STATE,
 -                       ((u64)args->args[0] << 32) | args->args[1],
 -                       0, 0, 0,
 -                       &state, &dummy, &dummy);
 +      rc = plpar_hcall(H_VASI_STATE, retbuf,
 +                       ((u64)args->args[0] << 32) | args->args[1]);
 +
 +      state = retbuf[0];
  
        if (rc) {
                printk(KERN_ERR "rtas_ibm_suspend_me: vasi_state returned %ld\n",rc);
@@@ -825,15 -845,15 +846,15 @@@ void __init rtas_initialize(void
         */
        rtas.dev = of_find_node_by_name(NULL, "rtas");
        if (rtas.dev) {
 -              u32 *basep, *entryp;
 -              u32 *sizep;
 +              const u32 *basep, *entryp, *sizep;
  
 -              basep = (u32 *)get_property(rtas.dev, "linux,rtas-base", NULL);
 -              sizep = (u32 *)get_property(rtas.dev, "rtas-size", NULL);
 +              basep = get_property(rtas.dev, "linux,rtas-base", NULL);
 +              sizep = get_property(rtas.dev, "rtas-size", NULL);
                if (basep != NULL && sizep != NULL) {
                        rtas.base = *basep;
                        rtas.size = *sizep;
 -                      entryp = (u32 *)get_property(rtas.dev, "linux,rtas-entry", NULL);
 +                      entryp = get_property(rtas.dev,
 +                                      "linux,rtas-entry", NULL);
                        if (entryp == NULL) /* Ugh */
                                rtas.entry = rtas.base;
                        else
@@@ -133,9 -133,9 +133,9 @@@ void pseries_8259_cascade(unsigned int 
  static void __init pseries_mpic_init_IRQ(void)
  {
        struct device_node *np, *old, *cascade = NULL;
 -        unsigned int *addrp;
 +        const unsigned int *addrp;
        unsigned long intack = 0;
 -      unsigned int *opprop;
 +      const unsigned int *opprop;
        unsigned long openpic_addr = 0;
        unsigned int cascade_irq;
        int naddr, n, i, opplen;
  
        np = of_find_node_by_path("/");
        naddr = prom_n_addr_cells(np);
 -      opprop = (unsigned int *) get_property(np, "platform-open-pic", &opplen);
 +      opprop = get_property(np, "platform-open-pic", &opplen);
        if (opprop != 0) {
                openpic_addr = of_read_number(opprop, naddr);
                printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
                        break;
                if (strcmp(np->name, "pci") != 0)
                        continue;
 -              addrp = (u32 *)get_property(np, "8259-interrupt-acknowledge",
 +              addrp = get_property(np, "8259-interrupt-acknowledge",
                                            NULL);
                if (addrp == NULL)
                        continue;
@@@ -213,8 -213,6 +213,6 @@@ static void pseries_lpar_enable_pmcs(vo
  {
        unsigned long set, reset;
  
-       power4_enable_pmcs();
        set = 1UL << 63;
        reset = 0;
        plpar_hcall_norets(H_PERFMON, set, reset);
@@@ -234,17 -232,9 +232,17 @@@ static void pseries_kexec_cpu_down_xics
  {
        /* Don't risk a hypervisor call if we're crashing */
        if (firmware_has_feature(FW_FEATURE_SPLPAR) && !crash_shutdown) {
 -              unsigned long vpa = __pa(get_lppaca());
 +              unsigned long addr;
  
 -              if (unregister_vpa(hard_smp_processor_id(), vpa)) {
 +              addr = __pa(get_slb_shadow());
 +              if (unregister_slb_shadow(hard_smp_processor_id(), addr))
 +                      printk("SLB shadow buffer deregistration of "
 +                             "cpu %u (hw_cpu_id %d) failed\n",
 +                             smp_processor_id(),
 +                             hard_smp_processor_id());
 +
 +              addr = __pa(get_lppaca());
 +              if (unregister_vpa(hard_smp_processor_id(), addr)) {
                        printk("VPA deregistration of cpu %u (hw_cpu_id %d) "
                                        "failed\n", smp_processor_id(),
                                        hard_smp_processor_id());
  static void __init pseries_discover_pic(void)
  {
        struct device_node *np;
 -      char *typep;
 +      const char *typep;
  
        for (np = NULL; (np = of_find_node_by_name(np,
                                                   "interrupt-controller"));) {
 -              typep = (char *)get_property(np, "compatible", NULL);
 +              typep = get_property(np, "compatible", NULL);
                if (strstr(typep, "open-pic")) {
                        pSeries_mpic_node = of_node_get(np);
                        ppc_md.init_IRQ       = pseries_mpic_init_IRQ;
@@@ -34,7 -34,6 +34,7 @@@
  #include <asm/i8259.h>
  
  #include "xics.h"
 +#include "plpar_wrappers.h"
  
  #define XICS_IPI              2
  #define XICS_IRQ_SPURIOUS     0
@@@ -111,6 -110,27 +111,6 @@@ static inline void direct_qirr_info(in
  /* LPAR low level accessors */
  
  
 -static inline long plpar_eoi(unsigned long xirr)
 -{
 -      return plpar_hcall_norets(H_EOI, xirr);
 -}
 -
 -static inline long plpar_cppr(unsigned long cppr)
 -{
 -      return plpar_hcall_norets(H_CPPR, cppr);
 -}
 -
 -static inline long plpar_ipi(unsigned long servernum, unsigned long mfrr)
 -{
 -      return plpar_hcall_norets(H_IPI, servernum, mfrr);
 -}
 -
 -static inline long plpar_xirr(unsigned long *xirr_ret)
 -{
 -      unsigned long dummy;
 -      return plpar_hcall(H_XIRR, 0, 0, 0, 0, xirr_ret, &dummy, &dummy);
 -}
 -
  static inline unsigned int lpar_xirr_info_get(int n_cpu)
  {
        unsigned long lpar_rc;
@@@ -447,7 -467,7 +447,7 @@@ void xics_setup_cpu(void
         *
         * XXX: undo of teardown on kexec needs this too, as may hotplug
         */
-       rtas_set_indicator(GLOBAL_INTERRUPT_QUEUE,
+       rtas_set_indicator_fast(GLOBAL_INTERRUPT_QUEUE,
                (1UL << interrupt_server_size) - 1 - default_distrib_server, 1);
  }
  
@@@ -570,14 -590,14 +570,14 @@@ static void __init xics_init_one_node(s
                                      unsigned int *indx)
  {
        unsigned int ilen;
 -      u32 *ireg;
 +      const u32 *ireg;
  
        /* This code does the theorically broken assumption that the interrupt
         * server numbers are the same as the hard CPU numbers.
         * This happens to be the case so far but we are playing with fire...
         * should be fixed one of these days. -BenH.
         */
 -      ireg = (u32 *)get_property(np, "ibm,interrupt-server-ranges", NULL);
 +      ireg = get_property(np, "ibm,interrupt-server-ranges", NULL);
  
        /* Do that ever happen ? we'll know soon enough... but even good'old
         * f80 does have that property ..
                 */
                *indx = *ireg;
        }
 -      ireg = (u32 *)get_property(np, "reg", &ilen);
 +      ireg = get_property(np, "reg", &ilen);
        if (!ireg)
                panic("xics_init_IRQ: can't find interrupt reg property");
  
@@@ -615,7 -635,7 +615,7 @@@ static void __init xics_setup_8259_casc
  {
        struct device_node *np, *old, *found = NULL;
        int cascade, naddr;
 -      u32 *addrp;
 +      const u32 *addrp;
        unsigned long intack = 0;
  
        for_each_node_by_type(np, "interrupt-controller")
                        break;
                if (strcmp(np->name, "pci") != 0)
                        continue;
 -              addrp = (u32 *)get_property(np, "8259-interrupt-acknowledge", NULL);
 +              addrp = get_property(np, "8259-interrupt-acknowledge", NULL);
                if (addrp == NULL)
                        continue;
                naddr = prom_n_addr_cells(np);
@@@ -660,8 -680,7 +660,8 @@@ void __init xics_init_IRQ(void
  {
        int i;
        struct device_node *np;
 -      u32 *ireg, ilen, indx = 0;
 +      u32 ilen, indx = 0;
 +      const u32 *ireg;
        int found = 0;
  
        ppc64_boot_msg(0x20, "XICS Init");
        for (np = of_find_node_by_type(NULL, "cpu");
             np;
             np = of_find_node_by_type(np, "cpu")) {
 -              ireg = (u32 *)get_property(np, "reg", &ilen);
 +              ireg = get_property(np, "reg", &ilen);
                if (ireg && ireg[0] == get_hard_smp_processor_id(boot_cpuid)) {
 -                      ireg = (u32 *)get_property(np,
 -                                                "ibm,ppc-interrupt-gserver#s",
 -                                                 &ilen);
 +                      ireg = get_property(np,
 +                                      "ibm,ppc-interrupt-gserver#s", &ilen);
                        i = ilen / sizeof(int);
                        if (ireg && i > 0) {
                                default_server = ireg[0];
                                /* take last element */
                                default_distrib_server = ireg[i-1];
                        }
 -                      ireg = (u32 *)get_property(np,
 +                      ireg = get_property(np,
                                        "ibm,interrupt-server#-size", NULL);
                        if (ireg)
                                interrupt_server_size = *ireg;
@@@ -776,7 -796,7 +776,7 @@@ void xics_teardown_cpu(int secondary
         * so leave the master cpu in the group.
         */
        if (secondary)
-               rtas_set_indicator(GLOBAL_INTERRUPT_QUEUE,
+               rtas_set_indicator_fast(GLOBAL_INTERRUPT_QUEUE,
                                   (1UL << interrupt_server_size) - 1 -
                                   default_distrib_server, 0);
  }
@@@ -793,7 -813,7 +793,7 @@@ void xics_migrate_irqs_away(void
        xics_set_cpu_priority(cpu, 0);
  
        /* remove ourselves from the global interrupt queue */
-       status = rtas_set_indicator(GLOBAL_INTERRUPT_QUEUE,
+       status = rtas_set_indicator_fast(GLOBAL_INTERRUPT_QUEUE,
                (1UL << interrupt_server_size) - 1 - default_distrib_server, 0);
        WARN_ON(status < 0);
  
diff --combined drivers/char/hvsi.c
@@@ -311,7 -311,8 +311,8 @@@ static void hvsi_recv_control(struct hv
                                /* CD went away; no more connection */
                                pr_debug("hvsi%i: CD dropped\n", hp->index);
                                hp->mctrl &= TIOCM_CD;
-                               if (!(hp->tty->flags & CLOCAL))
+                               /* If userland hasn't done an open(2) yet, hp->tty is NULL. */
+                               if (hp->tty && !(hp->tty->flags & CLOCAL))
                                        *to_hangup = hp->tty;
                        }
                        break;
@@@ -986,10 -987,7 +987,7 @@@ static void hvsi_write_worker(void *arg
                start_j = 0;
  #endif /* DEBUG */
                wake_up_all(&hp->emptyq);
-               if (test_bit(TTY_DO_WRITE_WAKEUP, &hp->tty->flags)
-                               && hp->tty->ldisc.write_wakeup)
-                       hp->tty->ldisc.write_wakeup(hp->tty);
-               wake_up_interruptible(&hp->tty->write_wait);
+               tty_wakeup(hp->tty);
        }
  
  out:
@@@ -1276,10 -1274,11 +1274,10 @@@ static int __init hvsi_console_init(voi
                        vty != NULL;
                        vty = of_find_compatible_node(vty, "serial", "hvterm-protocol")) {
                struct hvsi_struct *hp;
 -              uint32_t *vtermno;
 -              uint32_t *irq;
 +              const uint32_t *vtermno, *irq;
  
 -              vtermno = (uint32_t *)get_property(vty, "reg", NULL);
 -              irq = (uint32_t *)get_property(vty, "interrupts", NULL);
 +              vtermno = get_property(vty, "reg", NULL);
 +              irq = get_property(vty, "interrupts", NULL);
                if (!vtermno || !irq)
                        continue;
  
@@@ -56,7 -56,7 +56,7 @@@ static struct device_node *get_gpio(cha
  {
        struct device_node *np, *gpio;
        u32 *reg;
 -      char *audio_gpio;
 +      const char *audio_gpio;
  
        *gpioptr = -1;
  
  
  static void get_irq(struct device_node * np, int *irqptr)
  {
-       *irqptr = irq_of_parse_and_map(np, 0);
+       if (np)
+               *irqptr = irq_of_parse_and_map(np, 0);
+       else
+               *irqptr = NO_IRQ;
  }
  
  /* 0x4 is outenable, 0x1 is out, thus 4 or 5 */
@@@ -322,7 -325,7 +325,7 @@@ static int ftr_set_notify(struct gpio_r
                return -EINVAL;
        }
  
-       if (irq == -1)
+       if (irq == NO_IRQ)
                return -ENODEV;
  
        mutex_lock(&notif->mutex);
diff --combined sound/ppc/tumbler.c
@@@ -1035,7 -1035,7 +1035,7 @@@ static struct device_node *find_audio_d
                return NULL;
    
        for (np = np->child; np; np = np->sibling) {
 -              char *property = get_property(np, "audio-gpio", NULL);
 +              const char *property = get_property(np, "audio-gpio", NULL);
                if (property && strcmp(property, name) == 0)
                        return np;
        }  
@@@ -1062,8 -1062,7 +1062,8 @@@ static long tumbler_find_device(const c
                                struct pmac_gpio *gp, int is_compatible)
  {
        struct device_node *node;
 -      u32 *base, addr;
 +      const u32 *base;
 +      u32 addr;
  
        if (is_compatible)
                node = find_compatible_audio_device(device);
                return -ENODEV;
        }
  
 -      base = (u32 *)get_property(node, "AAPL,address", NULL);
 +      base = get_property(node, "AAPL,address", NULL);
        if (! base) {
 -              base = (u32 *)get_property(node, "reg", NULL);
 +              base = get_property(node, "reg", NULL);
                if (!base) {
                        DBG("(E) cannot find address for device %s !\n", device);
                        snd_printd("cannot find address for device %s\n", device);
  
        gp->addr = addr & 0x0000ffff;
        /* Try to find the active state, default to 0 ! */
 -      base = (u32 *)get_property(node, "audio-gpio-active-state", NULL);
 +      base = get_property(node, "audio-gpio-active-state", NULL);
        if (base) {
                gp->active_state = *base;
                gp->active_val = (*base) ? 0x5 : 0x4;
                gp->inactive_val = (*base) ? 0x4 : 0x5;
        } else {
 -              u32 *prop = NULL;
 +              const u32 *prop = NULL;
                gp->active_state = 0;
                gp->active_val = 0x4;
                gp->inactive_val = 0x5;
                 * as we don't yet have an interpreter for these things
                 */
                if (platform)
 -                      prop = (u32 *)get_property(node, platform, NULL);
 +                      prop = get_property(node, platform, NULL);
                if (prop) {
                        if (prop[3] == 0x9 && prop[4] == 0x9) {
                                gp->active_val = 0xd;
@@@ -1317,10 -1316,9 +1317,9 @@@ int __init snd_pmac_tumbler_init(struc
                request_module("i2c-powermac");
  #endif /* CONFIG_KMOD */      
  
-       mix = kmalloc(sizeof(*mix), GFP_KERNEL);
+       mix = kzalloc(sizeof(*mix), GFP_KERNEL);
        if (! mix)
                return -ENOMEM;
-       memset(mix, 0, sizeof(*mix));
        mix->headphone_irq = -1;
  
        chip->mixer_data = mix;