Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
David S. Miller [Sat, 11 Oct 2008 19:39:35 +0000 (12:39 -0700)]
Conflicts:

sound/core/memalloc.c

21 files changed:
1  2 
Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
arch/sparc/kernel/sun4d_smp.c
arch/sparc/kernel/sun4m_smp.c
arch/sparc64/kernel/irq.c
arch/sparc64/kernel/of_device.c
arch/sparc64/kernel/pci.c
arch/sparc64/kernel/traps.c
drivers/ata/Kconfig
drivers/hwmon/Kconfig
drivers/hwmon/Makefile
drivers/leds/Kconfig
drivers/leds/Makefile
drivers/net/myri_sbus.c
drivers/net/sunbmac.c
drivers/scsi/qlogicpti.c
include/sound/core.h
include/sound/memalloc.h
sound/core/memalloc.c
sound/sparc/amd7930.c
sound/sparc/cs4231.c
sound/sparc/dbri.c

@@@ -5073,7 -5073,8 +5073,7 @@@ struct _snd_pcm_runtime 
        with <constant>SNDRV_DMA_TYPE_CONTINUOUS</constant> type and the
        <function>snd_dma_continuous_data(GFP_KERNEL)</function> device pointer,
        where <constant>GFP_KERNEL</constant> is the kernel allocation flag to
 -      use.  For the SBUS, <constant>SNDRV_DMA_TYPE_SBUS</constant> and
 -      <function>snd_dma_sbus_data(sbus_dev)</function> are used instead.
 +      use.
        For the PCI scatter-gather buffers, use
        <constant>SNDRV_DMA_TYPE_DEV_SG</constant> with
        <function>snd_dma_pci_data(pci)</function>
        </para>
      </section>
  
-     <section id="useful-functions-snd-assert">
-       <title><function>snd_assert()</function></title>
+     <section id="useful-functions-snd-bug">
+       <title><function>snd_BUG()</function></title>
        <para>
-         <function>snd_assert()</function> macro is similar with the
-       normal <function>assert()</function> macro. For example,  
+         It shows the <computeroutput>BUG?</computeroutput> message and
+       stack trace as well as <function>snd_BUG_ON</function> at the point.
+       It's useful to show that a fatal error happens there. 
+       </para>
+       <para>
+        When no debug flag is set, this macro is ignored. 
+       </para>
+     </section>
+     <section id="useful-functions-snd-bug-on">
+       <title><function>snd_BUG_ON()</function></title>
+       <para>
+         <function>snd_BUG_ON()</function> macro is similar with
+       <function>WARN_ON()</function> macro. For example,  
  
          <informalexample>
            <programlisting>
  <![CDATA[
-   snd_assert(pointer != NULL, return -EINVAL);
+   snd_BUG_ON(!pointer);
  ]]>
            </programlisting>
          </informalexample>
-       </para>
  
-       <para>
-         The first argument is the expression to evaluate, and the
-       second argument is the action if it fails. When
-       <constant>CONFIG_SND_DEBUG</constant>, is set, it will show an
-       error message such as <computeroutput>BUG? (xxx)</computeroutput>
-       together with stack trace.
-       </para>
-       <para>
-        When no debug flag is set, this macro is ignored. 
-       </para>
-     </section>
+       or it can be used as the condition,
+         <informalexample>
+           <programlisting>
+ <![CDATA[
+   if (snd_BUG_ON(non_zero_is_bug))
+           return -EINVAL;
+ ]]>
+           </programlisting>
+         </informalexample>
  
-     <section id="useful-functions-snd-bug">
-       <title><function>snd_BUG()</function></title>
-       <para>
-         It shows the <computeroutput>BUG?</computeroutput> message and
-       stack trace as well as <function>snd_assert</function> at the point.
-       It's useful to show that a fatal error happens there. 
        </para>
        <para>
-        When no debug flag is set, this macro is ignored. 
+         The macro takes an conditional expression to evaluate.
+       When <constant>CONFIG_SND_DEBUG</constant>, is set, the
+       expression is actually evaluated. If it's non-zero, it shows
+       the warning message such as
+       <computeroutput>BUG? (xxx)</computeroutput>
+       normally followed by stack trace.  It returns the evaluated
+       value.
+       When no <constant>CONFIG_SND_DEBUG</constant> is set, this
+       macro always returns zero.
        </para>
      </section>
    </chapter>
  
  
@@@ -30,6 -30,7 +30,6 @@@
  #include <asm/pgalloc.h>
  #include <asm/pgtable.h>
  #include <asm/oplib.h>
 -#include <asm/sbus.h>
  #include <asm/sbi.h>
  #include <asm/tlbflush.h>
  #include <asm/cacheflush.h>
@@@ -71,17 -72,6 +71,17 @@@ static void smp_setup_percpu_timer(void
  extern void cpu_probe(void);
  extern void sun4d_distribute_irqs(void);
  
 +static unsigned char cpu_leds[32];
 +
 +static inline void show_leds(int cpuid)
 +{
 +      cpuid &= 0x1e;
 +      __asm__ __volatile__ ("stba %0, [%1] %2" : :
 +                            "r" ((cpu_leds[cpuid] << 4) | cpu_leds[cpuid+1]),
 +                            "r" (ECSR_BASE(cpuid) | BB_LEDS),
 +                            "i" (ASI_M_CTL));
 +}
 +
  void __init smp4d_callin(void)
  {
        int cpuid = hard_smp4d_processor_id();
@@@ -98,6 -88,7 +98,7 @@@
        local_flush_cache_all();
        local_flush_tlb_all();
  
+       notify_cpu_starting(cpuid);
        /*
         * Unblock the master CPU _only_ when the scheduler state
         * of all secondary CPUs will be up-to-date, so after
@@@ -71,6 -71,8 +71,8 @@@ void __cpuinit smp4m_callin(void
        local_flush_cache_all();
        local_flush_tlb_all();
  
+       notify_cpu_starting(cpuid);
        /* Get our local ticker going. */
        smp_setup_percpu_timer();
  
@@@ -313,8 -315,6 +315,8 @@@ void smp4m_cross_call_irq(void
        ccall_info.processors_out[i] = 1;
  }
  
 +extern void sun4m_clear_profile_irq(int cpu);
 +
  void smp4m_percpu_timer_interrupt(struct pt_regs *regs)
  {
        struct pt_regs *old_regs;
  
        old_regs = set_irq_regs(regs);
  
 -      clear_profile_irq(cpu);
 +      sun4m_clear_profile_irq(cpu);
  
        profile_tick(CPU_PROFILING);
  
@@@ -7,6 -7,7 +7,7 @@@
  
  #include <linux/module.h>
  #include <linux/sched.h>
+ #include <linux/linkage.h>
  #include <linux/ptrace.h>
  #include <linux/errno.h>
  #include <linux/kernel_stat.h>
@@@ -28,6 -29,7 +29,6 @@@
  #include <asm/system.h>
  #include <asm/irq.h>
  #include <asm/io.h>
 -#include <asm/sbus.h>
  #include <asm/iommu.h>
  #include <asm/upa.h>
  #include <asm/oplib.h>
@@@ -865,7 -867,7 +866,7 @@@ static void kill_prom_timer(void
        : "g1", "g2");
  }
  
- void init_irqwork_curcpu(void)
+ void notrace init_irqwork_curcpu(void)
  {
        int cpu = hard_smp_processor_id();
  
@@@ -896,7 -898,7 +897,7 @@@ static void __cpuinit register_one_mond
        }
  }
  
- void __cpuinit sun4v_register_mondo_queues(int this_cpu)
+ void __cpuinit notrace sun4v_register_mondo_queues(int this_cpu)
  {
        struct trap_per_cpu *tb = &trap_block[this_cpu];
  
@@@ -55,38 -55,15 +55,38 @@@ struct of_device *of_find_device_by_nod
  }
  EXPORT_SYMBOL(of_find_device_by_node);
  
 -#ifdef CONFIG_PCI
 -struct bus_type ebus_bus_type;
 -EXPORT_SYMBOL(ebus_bus_type);
 -#endif
 +unsigned int irq_of_parse_and_map(struct device_node *node, int index)
 +{
 +      struct of_device *op = of_find_device_by_node(node);
 +
 +      if (!op || index >= op->num_irqs)
 +              return 0;
 +
 +      return op->irqs[index];
 +}
 +EXPORT_SYMBOL(irq_of_parse_and_map);
 +
 +/* Take the archdata values for IOMMU, STC, and HOSTDATA found in
 + * BUS and propagate to all child of_device objects.
 + */
 +void of_propagate_archdata(struct of_device *bus)
 +{
 +      struct dev_archdata *bus_sd = &bus->dev.archdata;
 +      struct device_node *bus_dp = bus->node;
 +      struct device_node *dp;
  
 -#ifdef CONFIG_SBUS
 -struct bus_type sbus_bus_type;
 -EXPORT_SYMBOL(sbus_bus_type);
 -#endif
 +      for (dp = bus_dp->child; dp; dp = dp->sibling) {
 +              struct of_device *op = of_find_device_by_node(dp);
 +
 +              op->dev.archdata.iommu = bus_sd->iommu;
 +              op->dev.archdata.stc = bus_sd->stc;
 +              op->dev.archdata.host_controller = bus_sd->host_controller;
 +              op->dev.archdata.numa_node = bus_sd->numa_node;
 +
 +              if (dp->child)
 +                      of_propagate_archdata(op);
 +      }
 +}
  
  struct bus_type of_platform_bus_type;
  EXPORT_SYMBOL(of_platform_bus_type);
@@@ -192,7 -169,7 +192,7 @@@ static unsigned long of_bus_default_get
  
  static int of_bus_pci_match(struct device_node *np)
  {
-       if (!strcmp(np->type, "pci") || !strcmp(np->type, "pciex")) {
+       if (!strcmp(np->name, "pci")) {
                const char *model = of_get_property(np, "model", NULL);
  
                if (model && !strcmp(model, "SUNW,simba"))
@@@ -223,7 -200,7 +223,7 @@@ static int of_bus_simba_match(struct de
        /* Treat PCI busses lacking ranges property just like
         * simba.
         */
-       if (!strcmp(np->type, "pci") || !strcmp(np->type, "pciex")) {
+       if (!strcmp(np->name, "pci")) {
                if (!of_find_property(np, "ranges", NULL))
                        return 1;
        }
@@@ -401,7 -378,8 +401,7 @@@ static int __init build_one_resource(st
                                     int na, int ns, int pna)
  {
        const u32 *ranges;
 -      unsigned int rlen;
 -      int rone;
 +      int rone, rlen;
  
        ranges = of_get_property(parent, "ranges", &rlen);
        if (ranges == NULL || rlen == 0) {
@@@ -443,24 -421,15 +443,24 @@@ static int __init use_1to1_mapping(stru
  
        /* If the parent is the dma node of an ISA bus, pass
         * the translation up to the root.
 +       *
 +       * Some SBUS devices use intermediate nodes to express
 +       * hierarchy within the device itself.  These aren't
 +       * real bus nodes, and don't have a 'ranges' property.
 +       * But, we should still pass the translation work up
 +       * to the SBUS itself.
         */
 -      if (!strcmp(pp->name, "dma"))
 +      if (!strcmp(pp->name, "dma") ||
 +          !strcmp(pp->name, "espdma") ||
 +          !strcmp(pp->name, "ledma") ||
 +          !strcmp(pp->name, "lebuffer"))
                return 0;
  
        /* Similarly for all PCI bridges, if we get this far
         * it lacks a ranges property, and this will include
         * cases like Simba.
         */
-       if (!strcmp(pp->type, "pci") || !strcmp(pp->type, "pciex"))
+       if (!strcmp(pp->name, "pci"))
                return 0;
  
        return 1;
@@@ -745,8 -714,7 +745,7 @@@ static unsigned int __init build_one_de
                                break;
                        }
                } else {
-                       if (!strcmp(pp->type, "pci") ||
-                           !strcmp(pp->type, "pciex")) {
+                       if (!strcmp(pp->name, "pci")) {
                                unsigned int this_orig_irq = irq;
  
                                irq = pci_irq_swizzle(dp, pp, irq);
@@@ -876,6 -844,15 +875,6 @@@ static int __init of_bus_driver_init(vo
        int err;
  
        err = of_bus_type_init(&of_platform_bus_type, "of");
 -#ifdef CONFIG_PCI
 -      if (!err)
 -              err = of_bus_type_init(&ebus_bus_type, "ebus");
 -#endif
 -#ifdef CONFIG_SBUS
 -      if (!err)
 -              err = of_bus_type_init(&sbus_bus_type, "sbus");
 -#endif
 -
        if (!err)
                scan_of_devices();
  
  #include <linux/msi.h>
  #include <linux/irq.h>
  #include <linux/init.h>
 +#include <linux/of.h>
 +#include <linux/of_device.h>
  
  #include <asm/uaccess.h>
  #include <asm/pgtable.h>
  #include <asm/irq.h>
 -#include <asm/ebus.h>
  #include <asm/prom.h>
  #include <asm/apb.h>
  
  #include "pci_impl.h"
  
 -#ifndef CONFIG_PCI
 -/* A "nop" PCI implementation. */
 -asmlinkage int sys_pciconfig_read(unsigned long bus, unsigned long dfn,
 -                                unsigned long off, unsigned long len,
 -                                unsigned char *buf)
 -{
 -      return 0;
 -}
 -asmlinkage int sys_pciconfig_write(unsigned long bus, unsigned long dfn,
 -                                 unsigned long off, unsigned long len,
 -                                 unsigned char *buf)
 -{
 -      return 0;
 -}
 -#else
 -
  /* List of all PCI controllers found in the system. */
  struct pci_pbm_info *pci_pbm_root = NULL;
  
@@@ -164,6 -179,97 +164,6 @@@ void pci_config_write32(u32 *addr, u32 
        spin_unlock_irqrestore(&pci_poke_lock, flags);
  }
  
 -/* Probe for all PCI controllers in the system. */
 -extern void sabre_init(struct device_node *, const char *);
 -extern void psycho_init(struct device_node *, const char *);
 -extern void schizo_init(struct device_node *, const char *);
 -extern void schizo_plus_init(struct device_node *, const char *);
 -extern void tomatillo_init(struct device_node *, const char *);
 -extern void sun4v_pci_init(struct device_node *, const char *);
 -extern void fire_pci_init(struct device_node *, const char *);
 -
 -static struct {
 -      char *model_name;
 -      void (*init)(struct device_node *, const char *);
 -} pci_controller_table[] __initdata = {
 -      { "SUNW,sabre", sabre_init },
 -      { "pci108e,a000", sabre_init },
 -      { "pci108e,a001", sabre_init },
 -      { "SUNW,psycho", psycho_init },
 -      { "pci108e,8000", psycho_init },
 -      { "SUNW,schizo", schizo_init },
 -      { "pci108e,8001", schizo_init },
 -      { "SUNW,schizo+", schizo_plus_init },
 -      { "pci108e,8002", schizo_plus_init },
 -      { "SUNW,tomatillo", tomatillo_init },
 -      { "pci108e,a801", tomatillo_init },
 -      { "SUNW,sun4v-pci", sun4v_pci_init },
 -      { "pciex108e,80f0", fire_pci_init },
 -};
 -#define PCI_NUM_CONTROLLER_TYPES      ARRAY_SIZE(pci_controller_table)
 -
 -static int __init pci_controller_init(const char *model_name, int namelen, struct device_node *dp)
 -{
 -      int i;
 -
 -      for (i = 0; i < PCI_NUM_CONTROLLER_TYPES; i++) {
 -              if (!strncmp(model_name,
 -                           pci_controller_table[i].model_name,
 -                           namelen)) {
 -                      pci_controller_table[i].init(dp, model_name);
 -                      return 1;
 -              }
 -      }
 -
 -      return 0;
 -}
 -
 -static int __init pci_controller_scan(int (*handler)(const char *, int, struct device_node *))
 -{
 -      struct device_node *dp;
 -      int count = 0;
 -
 -      for_each_node_by_name(dp, "pci") {
 -              struct property *prop;
 -              int len;
 -
 -              prop = of_find_property(dp, "model", &len);
 -              if (!prop)
 -                      prop = of_find_property(dp, "compatible", &len);
 -
 -              if (prop) {
 -                      const char *model = prop->value;
 -                      int item_len = 0;
 -
 -                      /* Our value may be a multi-valued string in the
 -                       * case of some compatible properties. For sanity,
 -                       * only try the first one.
 -                       */
 -                      while (model[item_len] && len) {
 -                              len--;
 -                              item_len++;
 -                      }
 -
 -                      if (handler(model, item_len, dp))
 -                              count++;
 -              }
 -      }
 -
 -      return count;
 -}
 -
 -/* Find each controller in the system, attach and initialize
 - * software state structure for each and link into the
 - * pci_pbm_root.  Setup the controller enough such
 - * that bus scanning can be done.
 - */
 -static void __init pci_controller_probe(void)
 -{
 -      printk("PCI: Probing for controllers.\n");
 -
 -      pci_controller_scan(pci_controller_init);
 -}
 -
  static int ofpci_verbose;
  
  static int __init ofpci_debug(char *str)
@@@ -242,12 -348,11 +242,12 @@@ static void pci_parse_of_addrs(struct o
        }
  }
  
 -struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
 -                                struct device_node *node,
 -                                struct pci_bus *bus, int devfn)
 +static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
 +                                       struct device_node *node,
 +                                       struct pci_bus *bus, int devfn)
  {
        struct dev_archdata *sd;
 +      struct of_device *op;
        struct pci_dev *dev;
        const char *type;
        u32 class;
        sd->stc = &pbm->stc;
        sd->host_controller = pbm;
        sd->prom_node = node;
 -      sd->op = of_find_device_by_node(node);
 +      sd->op = op = of_find_device_by_node(node);
        sd->numa_node = pbm->numa_node;
  
 -      sd = &sd->op->dev.archdata;
 +      sd = &op->dev.archdata;
        sd->iommu = pbm->iommu;
        sd->stc = &pbm->stc;
        sd->numa_node = pbm->numa_node;
  
 +      if (!strcmp(node->name, "ebus"))
 +              of_propagate_archdata(op);
 +
        type = of_get_property(node, "device_type", NULL);
        if (type == NULL)
                type = "";
        dev->current_state = 4;         /* unknown power state */
        dev->error_state = pci_channel_io_normal;
  
-       if (!strcmp(type, "pci") || !strcmp(type, "pciex")) {
+       if (!strcmp(node->name, "pci")) {
                /* a PCI-PCI bridge */
                dev->hdr_type = PCI_HEADER_TYPE_BRIDGE;
                dev->rom_base_reg = PCI_ROM_ADDRESS1;
@@@ -673,15 -775,15 +673,15 @@@ static void __devinit pci_bus_register_
                pci_bus_register_of_sysfs(child_bus);
  }
  
 -struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm)
 +struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm,
 +                                          struct device *parent)
  {
 -      struct device_node *node = pbm->prom_node;
 +      struct device_node *node = pbm->op->node;
        struct pci_bus *bus;
  
        printk("PCI: Scanning PBM %s\n", node->full_name);
  
 -      /* XXX parent device? XXX */
 -      bus = pci_create_bus(NULL, pbm->pci_first_busno, pbm->pci_ops, pbm);
 +      bus = pci_create_bus(parent, pbm->pci_first_busno, pbm->pci_ops, pbm);
        if (!bus) {
                printk(KERN_ERR "Failed to create bus for %s\n",
                       node->full_name);
        return bus;
  }
  
 -static void __init pci_scan_each_controller_bus(void)
 -{
 -      struct pci_pbm_info *pbm;
 -
 -      for (pbm = pci_pbm_root; pbm; pbm = pbm->next)
 -              pbm->scan_bus(pbm);
 -}
 -
 -extern void power_init(void);
 -
 -static int __init pcibios_init(void)
 -{
 -      pci_controller_probe();
 -      if (pci_pbm_root == NULL)
 -              return 0;
 -
 -      pci_scan_each_controller_bus();
 -
 -      ebus_init();
 -      power_init();
 -
 -      return 0;
 -}
 -
 -subsys_initcall(pcibios_init);
 -
  void __devinit pcibios_fixup_bus(struct pci_bus *pbus)
  {
        struct pci_pbm_info *pbm = pbus->sysdata;
@@@ -977,14 -1105,14 +977,14 @@@ int pcibus_to_node(struct pci_bus *pbus
  EXPORT_SYMBOL(pcibus_to_node);
  #endif
  
 -/* Return the domain nuber for this pci bus */
 +/* Return the domain number for this pci bus */
  
  int pci_domain_nr(struct pci_bus *pbus)
  {
        struct pci_pbm_info *pbm = pbus->sysdata;
        int ret;
  
 -      if (pbm == NULL || pbm->parent == NULL) {
 +      if (!pbm) {
                ret = -ENXIO;
        } else {
                ret = pbm->index;
@@@ -998,7 -1126,7 +998,7 @@@ EXPORT_SYMBOL(pci_domain_nr)
  int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
  {
        struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller;
 -      int virt_irq;
 +      unsigned int virt_irq;
  
        if (!pbm->setup_msi_irq)
                return -EINVAL;
@@@ -1012,8 -1140,10 +1012,8 @@@ void arch_teardown_msi_irq(unsigned in
        struct pci_dev *pdev = entry->dev;
        struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller;
  
 -      if (!pbm->teardown_msi_irq)
 -              return;
 -
 -      return pbm->teardown_msi_irq(virt_irq, pdev);
 +      if (pbm->teardown_msi_irq)
 +              pbm->teardown_msi_irq(virt_irq, pdev);
  }
  #endif /* !(CONFIG_PCI_MSI) */
  
@@@ -1085,3 -1215,5 +1085,3 @@@ void pci_resource_to_user(const struct 
        *start = rp->start - offset;
        *end = rp->end - offset;
  }
 -
 -#endif /* !(CONFIG_PCI) */
@@@ -10,6 -10,7 +10,7 @@@
  
  #include <linux/module.h>
  #include <linux/sched.h>
+ #include <linux/linkage.h>
  #include <linux/kernel.h>
  #include <linux/signal.h>
  #include <linux/smp.h>
@@@ -37,7 -38,6 +38,7 @@@
  #include <asm/timer.h>
  #include <asm/head.h>
  #include <asm/prom.h>
 +#include <asm/memctrl.h>
  
  #include "entry.h"
  #include "kstack.h"
@@@ -129,56 -129,6 +130,56 @@@ void do_BUG(const char *file, int line
  }
  #endif
  
 +static DEFINE_SPINLOCK(dimm_handler_lock);
 +static dimm_printer_t dimm_handler;
 +
 +static int sprintf_dimm(int synd_code, unsigned long paddr, char *buf, int buflen)
 +{
 +      unsigned long flags;
 +      int ret = -ENODEV;
 +
 +      spin_lock_irqsave(&dimm_handler_lock, flags);
 +      if (dimm_handler) {
 +              ret = dimm_handler(synd_code, paddr, buf, buflen);
 +      } else if (tlb_type == spitfire) {
 +              if (prom_getunumber(synd_code, paddr, buf, buflen) == -1)
 +                      ret = -EINVAL;
 +              else
 +                      ret = 0;
 +      } else
 +              ret = -ENODEV;
 +      spin_unlock_irqrestore(&dimm_handler_lock, flags);
 +
 +      return ret;
 +}
 +
 +int register_dimm_printer(dimm_printer_t func)
 +{
 +      unsigned long flags;
 +      int ret = 0;
 +
 +      spin_lock_irqsave(&dimm_handler_lock, flags);
 +      if (!dimm_handler)
 +              dimm_handler = func;
 +      else
 +              ret = -EEXIST;
 +      spin_unlock_irqrestore(&dimm_handler_lock, flags);
 +
 +      return ret;
 +}
 +EXPORT_SYMBOL_GPL(register_dimm_printer);
 +
 +void unregister_dimm_printer(dimm_printer_t func)
 +{
 +      unsigned long flags;
 +
 +      spin_lock_irqsave(&dimm_handler_lock, flags);
 +      if (dimm_handler == func)
 +              dimm_handler = NULL;
 +      spin_unlock_irqrestore(&dimm_handler_lock, flags);
 +}
 +EXPORT_SYMBOL_GPL(unregister_dimm_printer);
 +
  void spitfire_insn_access_exception(struct pt_regs *regs, unsigned long sfsr, unsigned long sfar)
  {
        siginfo_t info;
@@@ -341,7 -291,10 +342,7 @@@ void sun4v_data_access_exception_tl1(st
  }
  
  #ifdef CONFIG_PCI
 -/* This is really pathetic... */
 -extern volatile int pci_poke_in_progress;
 -extern volatile int pci_poke_cpu;
 -extern volatile int pci_poke_faulted;
 +#include "pci_impl.h"
  #endif
  
  /* When access exceptions happen, we must do this. */
@@@ -423,7 -376,8 +424,7 @@@ static void spitfire_log_udb_syndrome(u
  
        if (udbl & bit) {
                scode = ecc_syndrome_table[udbl & 0xff];
 -              if (prom_getunumber(scode, afar,
 -                                  memmod_str, sizeof(memmod_str)) == -1)
 +              if (sprintf_dimm(scode, afar, memmod_str, sizeof(memmod_str)) < 0)
                        p = syndrome_unknown;
                else
                        p = memmod_str;
  
        if (udbh & bit) {
                scode = ecc_syndrome_table[udbh & 0xff];
 -              if (prom_getunumber(scode, afar,
 -                                  memmod_str, sizeof(memmod_str)) == -1)
 +              if (sprintf_dimm(scode, afar, memmod_str, sizeof(memmod_str)) < 0)
                        p = syndrome_unknown;
                else
                        p = memmod_str;
@@@ -1107,6 -1062,8 +1108,6 @@@ static const char *cheetah_get_string(u
        return "???";
  }
  
 -extern int chmc_getunumber(int, unsigned long, char *, int);
 -
  static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *info,
                               unsigned long afsr, unsigned long afar, int recoverable)
  {
  
                syndrome = (afsr & CHAFSR_E_SYNDROME) >> CHAFSR_E_SYNDROME_SHIFT;
                syndrome = cheetah_ecc_syntab[syndrome];
 -              ret = chmc_getunumber(syndrome, afar, unum, sizeof(unum));
 +              ret = sprintf_dimm(syndrome, afar, unum, sizeof(unum));
                if (ret != -1)
                        printk("%s" "ERROR(%d): AFAR E-syndrome [%s]\n",
                               (recoverable ? KERN_WARNING : KERN_CRIT),
  
                syndrome = (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT;
                syndrome = cheetah_mtag_syntab[syndrome];
 -              ret = chmc_getunumber(syndrome, afar, unum, sizeof(unum));
 +              ret = sprintf_dimm(syndrome, afar, unum, sizeof(unum));
                if (ret != -1)
                        printk("%s" "ERROR(%d): AFAR M-syndrome [%s]\n",
                               (recoverable ? KERN_WARNING : KERN_CRIT),
@@@ -2267,6 -2224,7 +2268,6 @@@ void die_if_kernel(char *str, struct pt
  
  extern int handle_popc(u32 insn, struct pt_regs *regs);
  extern int handle_ldf_stq(u32 insn, struct pt_regs *regs);
 -extern int vis_emul(struct pt_regs *, unsigned int);
  
  void do_illegal_instruction(struct pt_regs *regs)
  {
@@@ -2496,7 -2454,7 +2497,7 @@@ struct trap_per_cpu trap_block[NR_CPUS]
  /* This can get invoked before sched_init() so play it super safe
   * and use hard_smp_processor_id().
   */
- void init_cur_cpu_trap(struct thread_info *t)
+ void notrace init_cur_cpu_trap(struct thread_info *t)
  {
        int cpu = hard_smp_processor_id();
        struct trap_per_cpu *p = &trap_block[cpu];
diff --combined drivers/ata/Kconfig
@@@ -7,6 -7,7 +7,6 @@@ menuconfig AT
        depends on HAS_IOMEM
        depends on BLOCK
        depends on !(M32R || M68K) || BROKEN
 -      depends on !SUN4 || BROKEN
        select SCSI
        ---help---
          If you want to use a ATA hard disk, ATA tape drive, ATA CD-ROM or
@@@ -662,7 -663,7 +662,7 @@@ config HAVE_PATA_PLATFOR
  
  config PATA_PLATFORM
        tristate "Generic platform device PATA support"
-       depends on EMBEDDED || ARCH_RPC || PPC || HAVE_PATA_PLATFORM
+       depends on EMBEDDED || PPC || HAVE_PATA_PLATFORM
        help
          This option enables support for generic directly connected ATA
          devices commonly found on embedded systems.
diff --combined drivers/hwmon/Kconfig
@@@ -540,6 -540,15 +540,15 @@@ config SENSORS_LM9
          This driver can also be built as a module.  If so, the module
          will be called lm93.
  
+ config SENSORS_MAX1111
+       tristate "Maxim MAX1111 Multichannel, Serial 8-bit ADC chip"
+       depends on SPI_MASTER
+       help
+         Say y here to support Maxim's MAX1111 ADC chips.
+         This driver can also be built as a module.  If so, the module
+         will be called max1111.
  config SENSORS_MAX1619
        tristate "Maxim MAX1619 sensor chip"
        depends on I2C
@@@ -791,13 -800,6 +800,13 @@@ config SENSORS_W83627EH
          This driver can also be built as a module.  If so, the module
          will be called w83627ehf.
  
 +config SENSORS_ULTRA45
 +      tristate "Sun Ultra45 PIC16F747"
 +      depends on SPARC64
 +      help
 +        This driver provides support for the Ultra45 workstation environmental
 +        sensors.
 +
  config SENSORS_HDAPS
        tristate "IBM Hard Drive Active Protection System (hdaps)"
        depends on INPUT && X86
diff --combined drivers/hwmon/Makefile
@@@ -41,7 -41,6 +41,7 @@@ obj-$(CONFIG_SENSORS_FSCHMD)  += fschmd.
  obj-$(CONFIG_SENSORS_FSCPOS)  += fscpos.o
  obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
  obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
 +obj-$(CONFIG_SENSORS_ULTRA45) += ultra45_env.o
  obj-$(CONFIG_SENSORS_HDAPS)   += hdaps.o
  obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o
  obj-$(CONFIG_SENSORS_IBMAEM)  += ibmaem.o
@@@ -60,6 -59,7 +60,7 @@@ obj-$(CONFIG_SENSORS_LM87)    += lm87.
  obj-$(CONFIG_SENSORS_LM90)    += lm90.o
  obj-$(CONFIG_SENSORS_LM92)    += lm92.o
  obj-$(CONFIG_SENSORS_LM93)    += lm93.o
+ obj-$(CONFIG_SENSORS_MAX1111) += max1111.o
  obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
  obj-$(CONFIG_SENSORS_MAX6650) += max6650.o
  obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
diff --combined drivers/leds/Kconfig
@@@ -24,13 -24,6 +24,6 @@@ config LEDS_ATMEL_PW
          This option enables support for LEDs driven using outputs
          of the dedicated PWM controller found on newer Atmel SOCs.
  
- config LEDS_CORGI
-       tristate "LED Support for the Sharp SL-C7x0 series"
-       depends on LEDS_CLASS && PXA_SHARP_C7xx
-       help
-         This option enables support for the LEDs on Sharp Zaurus
-         SL-C7x0 series (C700, C750, C760, C860).
  config LEDS_LOCOMO
        tristate "LED Support for Locomo device"
        depends on LEDS_CLASS && SHARP_LOCOMO
          This option enables support for the LEDs on Sharp Locomo.
          Zaurus models SL-5500 and SL-5600.
  
- config LEDS_SPITZ
-       tristate "LED Support for the Sharp SL-Cxx00 series"
-       depends on LEDS_CLASS && PXA_SHARP_Cxx00
-       help
-         This option enables support for the LEDs on Sharp Zaurus
-         SL-Cxx00 series (C1000, C3000, C3100).
  config LEDS_S3C24XX
        tristate "LED Support for Samsung S3C24XX GPIO LEDs"
        depends on LEDS_CLASS && ARCH_S3C2410
@@@ -96,14 -82,6 +82,14 @@@ config LEDS_COBALT_RA
        help
          This option enables support for the Cobalt Raq series LEDs.
  
 +config LEDS_SUNFIRE
 +      tristate "LED support for SunFire servers."
 +      depends on LEDS_CLASS && SPARC64
 +      select LEDS_TRIGGERS
 +      help
 +        This option enables support for the Left, Middle, and Right
 +        LEDs on the I/O and CPU boards of SunFire UltraSPARC servers.
 +
  config LEDS_HP6XX
        tristate "LED Support for the HP Jornada 6xx"
        depends on LEDS_CLASS && SH_HP6XX
diff --combined drivers/leds/Makefile
@@@ -6,9 -6,7 +6,7 @@@ obj-$(CONFIG_LEDS_TRIGGERS)              += led-tri
  
  # LED Platform Drivers
  obj-$(CONFIG_LEDS_ATMEL_PWM)          += leds-atmel-pwm.o
- obj-$(CONFIG_LEDS_CORGI)              += leds-corgi.o
  obj-$(CONFIG_LEDS_LOCOMO)             += leds-locomo.o
- obj-$(CONFIG_LEDS_SPITZ)              += leds-spitz.o
  obj-$(CONFIG_LEDS_S3C24XX)            += leds-s3c24xx.o
  obj-$(CONFIG_LEDS_AMS_DELTA)          += leds-ams-delta.o
  obj-$(CONFIG_LEDS_NET48XX)            += leds-net48xx.o
@@@ -16,7 -14,6 +14,7 @@@ obj-$(CONFIG_LEDS_WRAP)                       += leds-wrap.
  obj-$(CONFIG_LEDS_H1940)              += leds-h1940.o
  obj-$(CONFIG_LEDS_COBALT_QUBE)                += leds-cobalt-qube.o
  obj-$(CONFIG_LEDS_COBALT_RAQ)         += leds-cobalt-raq.o
 +obj-$(CONFIG_LEDS_SUNFIRE)            += leds-sunfire.o
  obj-$(CONFIG_LEDS_PCA9532)            += leds-pca9532.o
  obj-$(CONFIG_LEDS_GPIO)                       += leds-gpio.o
  obj-$(CONFIG_LEDS_CM_X270)              += leds-cm-x270.o
diff --combined drivers/net/myri_sbus.c
@@@ -1,6 -1,6 +1,6 @@@
  /* myri_sbus.c: MyriCOM MyriNET SBUS card driver.
   *
 - * Copyright (C) 1996, 1999, 2006 David S. Miller (davem@davemloft.net)
 + * Copyright (C) 1996, 1999, 2006, 2008 David S. Miller (davem@davemloft.net)
   */
  
  static char version[] =
@@@ -22,9 -22,6 +22,9 @@@
  #include <linux/etherdevice.h>
  #include <linux/skbuff.h>
  #include <linux/bitops.h>
 +#include <linux/dma-mapping.h>
 +#include <linux/of.h>
 +#include <linux/of_device.h>
  
  #include <net/dst.h>
  #include <net/arp.h>
@@@ -36,6 -33,7 +36,6 @@@
  #include <asm/dma.h>
  #include <asm/byteorder.h>
  #include <asm/idprom.h>
 -#include <asm/sbus.h>
  #include <asm/openprom.h>
  #include <asm/oplib.h>
  #include <asm/auxio.h>
@@@ -245,8 -243,7 +245,8 @@@ static void myri_clean_rings(struct myr
                        u32 dma_addr;
  
                        dma_addr = sbus_readl(&rxd->myri_scatters[0].addr);
 -                      sbus_unmap_single(mp->myri_sdev, dma_addr, RX_ALLOC_SIZE, SBUS_DMA_FROMDEVICE);
 +                      dma_unmap_single(&mp->myri_op->dev, dma_addr,
 +                                       RX_ALLOC_SIZE, DMA_FROM_DEVICE);
                        dev_kfree_skb(mp->rx_skbs[i]);
                        mp->rx_skbs[i] = NULL;
                }
                        u32 dma_addr;
  
                        dma_addr = sbus_readl(&txd->myri_gathers[0].addr);
 -                      sbus_unmap_single(mp->myri_sdev, dma_addr, (skb->len + 3) & ~3, SBUS_DMA_TODEVICE);
 +                      dma_unmap_single(&mp->myri_op->dev, dma_addr,
 +                                       (skb->len + 3) & ~3,
 +                                       DMA_TO_DEVICE);
                        dev_kfree_skb(mp->tx_skbs[i]);
                        mp->tx_skbs[i] = NULL;
                }
@@@ -293,9 -288,7 +293,9 @@@ static void myri_init_rings(struct myri
                skb->dev = dev;
                skb_put(skb, RX_ALLOC_SIZE);
  
 -              dma_addr = sbus_map_single(mp->myri_sdev, skb->data, RX_ALLOC_SIZE, SBUS_DMA_FROMDEVICE);
 +              dma_addr = dma_map_single(&mp->myri_op->dev,
 +                                        skb->data, RX_ALLOC_SIZE,
 +                                        DMA_FROM_DEVICE);
                sbus_writel(dma_addr, &rxd[i].myri_scatters[0].addr);
                sbus_writel(RX_ALLOC_SIZE, &rxd[i].myri_scatters[0].len);
                sbus_writel(i, &rxd[i].ctx);
@@@ -351,8 -344,7 +351,8 @@@ static void myri_tx(struct myri_eth *mp
  
                DTX(("SKB[%d] ", entry));
                dma_addr = sbus_readl(&sq->myri_txd[entry].myri_gathers[0].addr);
 -              sbus_unmap_single(mp->myri_sdev, dma_addr, skb->len, SBUS_DMA_TODEVICE);
 +              dma_unmap_single(&mp->myri_op->dev, dma_addr,
 +                               skb->len, DMA_TO_DEVICE);
                dev_kfree_skb(skb);
                mp->tx_skbs[entry] = NULL;
                dev->stats.tx_packets++;
@@@ -431,9 -423,9 +431,9 @@@ static void myri_rx(struct myri_eth *mp
  
                /* Check for errors. */
                DRX(("rxd[%d]: %p len[%d] csum[%08x] ", entry, rxd, len, csum));
 -              sbus_dma_sync_single_for_cpu(mp->myri_sdev,
 -                                           sbus_readl(&rxd->myri_scatters[0].addr),
 -                                           RX_ALLOC_SIZE, SBUS_DMA_FROMDEVICE);
 +              dma_sync_single_for_cpu(&mp->myri_op->dev,
 +                                      sbus_readl(&rxd->myri_scatters[0].addr),
 +                                      RX_ALLOC_SIZE, DMA_FROM_DEVICE);
                if (len < (ETH_HLEN + MYRI_PAD_LEN) || (skb->data[0] != MYRI_PAD_LEN)) {
                        DRX(("ERROR["));
                        dev->stats.rx_errors++;
                        drops++;
                        DRX(("DROP "));
                        dev->stats.rx_dropped++;
 -                      sbus_dma_sync_single_for_device(mp->myri_sdev,
 -                                                      sbus_readl(&rxd->myri_scatters[0].addr),
 -                                                      RX_ALLOC_SIZE,
 -                                                      SBUS_DMA_FROMDEVICE);
 +                      dma_sync_single_for_device(&mp->myri_op->dev,
 +                                                 sbus_readl(&rxd->myri_scatters[0].addr),
 +                                                 RX_ALLOC_SIZE,
 +                                                 DMA_FROM_DEVICE);
                        sbus_writel(RX_ALLOC_SIZE, &rxd->myri_scatters[0].len);
                        sbus_writel(index, &rxd->ctx);
                        sbus_writel(1, &rxd->num_sg);
                                DRX(("skb_alloc(FAILED) "));
                                goto drop_it;
                        }
 -                      sbus_unmap_single(mp->myri_sdev,
 -                                        sbus_readl(&rxd->myri_scatters[0].addr),
 -                                        RX_ALLOC_SIZE,
 -                                        SBUS_DMA_FROMDEVICE);
 +                      dma_unmap_single(&mp->myri_op->dev,
 +                                       sbus_readl(&rxd->myri_scatters[0].addr),
 +                                       RX_ALLOC_SIZE,
 +                                       DMA_FROM_DEVICE);
                        mp->rx_skbs[index] = new_skb;
                        new_skb->dev = dev;
                        skb_put(new_skb, RX_ALLOC_SIZE);
 -                      dma_addr = sbus_map_single(mp->myri_sdev,
 -                                                 new_skb->data,
 -                                                 RX_ALLOC_SIZE,
 -                                                 SBUS_DMA_FROMDEVICE);
 +                      dma_addr = dma_map_single(&mp->myri_op->dev,
 +                                                new_skb->data,
 +                                                RX_ALLOC_SIZE,
 +                                                DMA_FROM_DEVICE);
                        sbus_writel(dma_addr, &rxd->myri_scatters[0].addr);
                        sbus_writel(RX_ALLOC_SIZE, &rxd->myri_scatters[0].len);
                        sbus_writel(index, &rxd->ctx);
  
                        /* Reuse original ring buffer. */
                        DRX(("reuse "));
 -                      sbus_dma_sync_single_for_device(mp->myri_sdev,
 -                                                      sbus_readl(&rxd->myri_scatters[0].addr),
 -                                                      RX_ALLOC_SIZE,
 -                                                      SBUS_DMA_FROMDEVICE);
 +                      dma_sync_single_for_device(&mp->myri_op->dev,
 +                                                 sbus_readl(&rxd->myri_scatters[0].addr),
 +                                                 RX_ALLOC_SIZE,
 +                                                 DMA_FROM_DEVICE);
                        sbus_writel(RX_ALLOC_SIZE, &rxd->myri_scatters[0].len);
                        sbus_writel(index, &rxd->ctx);
                        sbus_writel(1, &rxd->num_sg);
@@@ -660,8 -652,7 +660,8 @@@ static int myri_start_xmit(struct sk_bu
                sbus_writew((skb->data[4] << 8) | skb->data[5], &txd->addr[3]);
        }
  
 -      dma_addr = sbus_map_single(mp->myri_sdev, skb->data, len, SBUS_DMA_TODEVICE);
 +      dma_addr = dma_map_single(&mp->myri_op->dev, skb->data,
 +                                len, DMA_TO_DEVICE);
        sbus_writel(dma_addr, &txd->myri_gathers[0].addr);
        sbus_writel(len, &txd->myri_gathers[0].len);
        sbus_writel(1, &txd->num_sg);
@@@ -900,30 -891,30 +900,30 @@@ static const struct header_ops myri_hea
        .cache_update   = myri_header_cache_update,
  };
  
 -static int __devinit myri_ether_init(struct sbus_dev *sdev)
 +static int __devinit myri_sbus_probe(struct of_device *op, const struct of_device_id *match)
  {
 -      static int num;
 +      struct device_node *dp = op->node;
        static unsigned version_printed;
        struct net_device *dev;
 -      struct myri_eth *mp;
 -      unsigned char prop_buf[32];
 -      int i;
        DECLARE_MAC_BUF(mac);
 +      struct myri_eth *mp;
 +      const void *prop;
 +      static int num;
 +      int i, len;
  
 -      DET(("myri_ether_init(%p,%d):\n", sdev, num));
 +      DET(("myri_ether_init(%p,%d):\n", op, num));
        dev = alloc_etherdev(sizeof(struct myri_eth));
 -
        if (!dev)
                return -ENOMEM;
  
        if (version_printed++ == 0)
                printk(version);
  
 -      SET_NETDEV_DEV(dev, &sdev->ofdev.dev);
 +      SET_NETDEV_DEV(dev, &op->dev);
  
 -      mp = (struct myri_eth *) dev->priv;
 +      mp = netdev_priv(dev);
        spin_lock_init(&mp->irq_lock);
 -      mp->myri_sdev = sdev;
 +      mp->myri_op = op;
  
        /* Clean out skb arrays. */
        for (i = 0; i < (RX_RING_SIZE + 1); i++)
                mp->tx_skbs[i] = NULL;
  
        /* First check for EEPROM information. */
 -      i = prom_getproperty(sdev->prom_node, "myrinet-eeprom-info",
 -                           (char *)&mp->eeprom, sizeof(struct myri_eeprom));
 -      DET(("prom_getprop(myrinet-eeprom-info) returns %d\n", i));
 -      if (i == 0 || i == -1) {
 +      prop = of_get_property(dp, "myrinet-eeprom-info", &len);
 +
 +      if (prop)
 +              memcpy(&mp->eeprom, prop, sizeof(struct myri_eeprom));
 +      if (!prop) {
                /* No eeprom property, must cook up the values ourselves. */
                DET(("No EEPROM: "));
                mp->eeprom.bus_type = BUS_TYPE_SBUS;
 -              mp->eeprom.cpuvers = prom_getintdefault(sdev->prom_node,"cpu_version",0);
 -              mp->eeprom.cval = prom_getintdefault(sdev->prom_node,"clock_value",0);
 -              mp->eeprom.ramsz = prom_getintdefault(sdev->prom_node,"sram_size",0);
 -              DET(("cpuvers[%d] cval[%d] ramsz[%d]\n", mp->eeprom.cpuvers,
 -                   mp->eeprom.cval, mp->eeprom.ramsz));
 -              if (mp->eeprom.cpuvers == 0) {
 -                      DET(("EEPROM: cpuvers was zero, setting to %04x\n",CPUVERS_2_3));
 +              mp->eeprom.cpuvers =
 +                      of_getintprop_default(dp, "cpu_version", 0);
 +              mp->eeprom.cval =
 +                      of_getintprop_default(dp, "clock_value", 0);
 +              mp->eeprom.ramsz = of_getintprop_default(dp, "sram_size", 0);
 +              if (!mp->eeprom.cpuvers)
                        mp->eeprom.cpuvers = CPUVERS_2_3;
 -              }
 -              if (mp->eeprom.cpuvers < CPUVERS_3_0) {
 -                      DET(("EEPROM: cpuvers < CPUVERS_3_0, clockval set to zero.\n"));
 +              if (mp->eeprom.cpuvers < CPUVERS_3_0)
                        mp->eeprom.cval = 0;
 -              }
 -              if (mp->eeprom.ramsz == 0) {
 -                      DET(("EEPROM: ramsz == 0, setting to 128k\n"));
 +              if (!mp->eeprom.ramsz)
                        mp->eeprom.ramsz = (128 * 1024);
 -              }
 -              i = prom_getproperty(sdev->prom_node, "myrinet-board-id",
 -                                   &prop_buf[0], 10);
 -              DET(("EEPROM: prom_getprop(myrinet-board-id) returns %d\n", i));
 -              if ((i != 0) && (i != -1))
 -                      memcpy(&mp->eeprom.id[0], &prop_buf[0], 6);
 +
 +              prop = of_get_property(dp, "myrinet-board-id", &len);
 +              if (prop)
 +                      memcpy(&mp->eeprom.id[0], prop, 6);
                else
                        set_boardid_from_idprom(mp, num);
 -              i = prom_getproperty(sdev->prom_node, "fpga_version",
 -                                   &mp->eeprom.fvers[0], 32);
 -              DET(("EEPROM: prom_getprop(fpga_version) returns %d\n", i));
 -              if (i == 0 || i == -1)
 +
 +              prop = of_get_property(dp, "fpga_version", &len);
 +              if (prop)
 +                      memcpy(&mp->eeprom.fvers[0], prop, 32);
 +              else
                        memset(&mp->eeprom.fvers[0], 0, 32);
  
                if (mp->eeprom.cpuvers == CPUVERS_4_1) {
 -                      DET(("EEPROM: cpuvers CPUVERS_4_1, "));
 -                      if (mp->eeprom.ramsz == (128 * 1024)) {
 -                              DET(("ramsize 128k, setting to 256k, "));
 +                      if (mp->eeprom.ramsz == (128 * 1024))
                                mp->eeprom.ramsz = (256 * 1024);
 -                      }
 -                      if ((mp->eeprom.cval==0x40414041)||(mp->eeprom.cval==0x90449044)){
 -                              DET(("changing cval from %08x to %08x ",
 -                                   mp->eeprom.cval, 0x50e450e4));
 +                      if ((mp->eeprom.cval == 0x40414041) ||
 +                          (mp->eeprom.cval == 0x90449044))
                                mp->eeprom.cval = 0x50e450e4;
 -                      }
 -                      DET(("\n"));
                }
        }
  #ifdef DEBUG_DETECT
                 * XXX only a valid version for PCI cards?  Ask feldy...
                 */
                DET(("Mapping regs for cpuvers < CPUVERS_4_0\n"));
 -              mp->regs = sbus_ioremap(&sdev->resource[0], 0,
 -                                      mp->reg_size, "MyriCOM Regs");
 +              mp->regs = of_ioremap(&op->resource[0], 0,
 +                                    mp->reg_size, "MyriCOM Regs");
                if (!mp->regs) {
                        printk("MyriCOM: Cannot map MyriCOM registers.\n");
                        goto err;
                mp->lregs = mp->lanai + (0x10000 * 2);
        } else {
                DET(("Mapping regs for cpuvers >= CPUVERS_4_0\n"));
 -              mp->cregs = sbus_ioremap(&sdev->resource[0], 0,
 -                                       PAGE_SIZE, "MyriCOM Control Regs");
 -              mp->lregs = sbus_ioremap(&sdev->resource[0], (256 * 1024),
 +              mp->cregs = of_ioremap(&op->resource[0], 0,
 +                                     PAGE_SIZE, "MyriCOM Control Regs");
 +              mp->lregs = of_ioremap(&op->resource[0], (256 * 1024),
                                         PAGE_SIZE, "MyriCOM LANAI Regs");
 -              mp->lanai =
 -                      sbus_ioremap(&sdev->resource[0], (512 * 1024),
 -                                   mp->eeprom.ramsz, "MyriCOM SRAM");
 +              mp->lanai = of_ioremap(&op->resource[0], (512 * 1024),
 +                                     mp->eeprom.ramsz, "MyriCOM SRAM");
        }
        DET(("Registers mapped: cregs[%p] lregs[%p] lanai[%p]\n",
             mp->cregs, mp->lregs, mp->lanai));
        myri_reset_on(mp->cregs);
  
        /* Get the supported DVMA burst sizes from our SBUS. */
 -      mp->myri_bursts = prom_getintdefault(mp->myri_sdev->bus->prom_node,
 -                                           "burst-sizes", 0x00);
 -
 -      if (!sbus_can_burst64(sdev))
 +      mp->myri_bursts = of_getintprop_default(dp->parent,
 +                                              "burst-sizes", 0x00);
 +      if (!sbus_can_burst64())
                mp->myri_bursts &= ~(DMA_BURST64);
  
        DET(("MYRI bursts %02x\n", mp->myri_bursts));
  
        /* Encode SBUS interrupt level in second control register. */
 -      i = prom_getint(sdev->prom_node, "interrupts");
 +      i = of_getintprop_default(dp, "interrupts", 0);
        if (i == 0)
                i = 4;
        DET(("prom_getint(interrupts)==%d, irqlvl set to %04x\n",
        dev->tx_timeout = &myri_tx_timeout;
        dev->watchdog_timeo = 5*HZ;
        dev->set_multicast_list = &myri_set_multicast;
 -      dev->irq = sdev->irqs[0];
 +      dev->irq = op->irqs[0];
  
        /* Register interrupt handler now. */
        DET(("Requesting MYRIcom IRQ line.\n"));
                goto err_free_irq;
        }
  
 -      dev_set_drvdata(&sdev->ofdev.dev, mp);
 +      dev_set_drvdata(&op->dev, mp);
  
        num++;
  
        return -ENODEV;
  }
  
 -
 -static int __devinit myri_sbus_probe(struct of_device *dev, const struct of_device_id *match)
 -{
 -      struct sbus_dev *sdev = to_sbus_device(&dev->dev);
 -
 -      return myri_ether_init(sdev);
 -}
 -
 -static int __devexit myri_sbus_remove(struct of_device *dev)
 +static int __devexit myri_sbus_remove(struct of_device *op)
  {
 -      struct myri_eth *mp = dev_get_drvdata(&dev->dev);
 +      struct myri_eth *mp = dev_get_drvdata(&op->dev);
        struct net_device *net_dev = mp->dev;
  
-       unregister_netdevice(net_dev);
+       unregister_netdev(net_dev);
  
        free_irq(net_dev->irq, net_dev);
  
        if (mp->eeprom.cpuvers < CPUVERS_4_0) {
 -              sbus_iounmap(mp->regs, mp->reg_size);
 +              of_iounmap(&op->resource[0], mp->regs, mp->reg_size);
        } else {
 -              sbus_iounmap(mp->cregs, PAGE_SIZE);
 -              sbus_iounmap(mp->lregs, (256 * 1024));
 -              sbus_iounmap(mp->lanai, (512 * 1024));
 +              of_iounmap(&op->resource[0], mp->cregs, PAGE_SIZE);
 +              of_iounmap(&op->resource[0], mp->lregs, (256 * 1024));
 +              of_iounmap(&op->resource[0], mp->lanai, (512 * 1024));
        }
  
        free_netdev(net_dev);
  
 -      dev_set_drvdata(&dev->dev, NULL);
 +      dev_set_drvdata(&op->dev, NULL);
  
        return 0;
  }
  
 -static struct of_device_id myri_sbus_match[] = {
 +static const struct of_device_id myri_sbus_match[] = {
        {
                .name = "MYRICOM,mlanai",
        },
@@@ -1146,7 -1158,7 +1146,7 @@@ static struct of_platform_driver myri_s
  
  static int __init myri_sbus_init(void)
  {
 -      return of_register_driver(&myri_sbus_driver, &sbus_bus_type);
 +      return of_register_driver(&myri_sbus_driver, &of_bus_type);
  }
  
  static void __exit myri_sbus_exit(void)
diff --combined drivers/net/sunbmac.c
@@@ -1,6 -1,7 +1,6 @@@
 -/* $Id: sunbmac.c,v 1.30 2002/01/15 06:48:55 davem Exp $
 - * sunbmac.c: Driver for Sparc BigMAC 100baseT ethernet adapters.
 +/* sunbmac.c: Driver for Sparc BigMAC 100baseT ethernet adapters.
   *
 - * Copyright (C) 1997, 1998, 1999, 2003 David S. Miller (davem@redhat.com)
 + * Copyright (C) 1997, 1998, 1999, 2003, 2008 David S. Miller (davem@davemloft.net)
   */
  
  #include <linux/module.h>
@@@ -22,9 -23,6 +22,9 @@@
  #include <linux/etherdevice.h>
  #include <linux/skbuff.h>
  #include <linux/bitops.h>
 +#include <linux/dma-mapping.h>
 +#include <linux/of.h>
 +#include <linux/of_device.h>
  
  #include <asm/auxio.h>
  #include <asm/byteorder.h>
  #include <asm/openprom.h>
  #include <asm/oplib.h>
  #include <asm/pgtable.h>
 -#include <asm/sbus.h>
  #include <asm/system.h>
  
  #include "sunbmac.h"
  
  #define DRV_NAME      "sunbmac"
 -#define DRV_VERSION   "2.0"
 -#define DRV_RELDATE   "11/24/03"
 -#define DRV_AUTHOR    "David S. Miller (davem@redhat.com)"
 +#define DRV_VERSION   "2.1"
 +#define DRV_RELDATE   "August 26, 2008"
 +#define DRV_AUTHOR    "David S. Miller (davem@davemloft.net)"
  
  static char version[] =
        DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
@@@ -97,8 -96,8 +97,8 @@@ static int qec_global_reset(void __iome
  
  static void qec_init(struct bigmac *bp)
  {
 +      struct of_device *qec_op = bp->qec_op;
        void __iomem *gregs = bp->gregs;
 -      struct sbus_dev *qec_sdev = bp->qec_sdev;
        u8 bsizes = bp->bigmac_bursts;
        u32 regval;
  
        sbus_writel(GLOB_PSIZE_2048, gregs + GLOB_PSIZE);
  
        /* All of memsize is given to bigmac. */
 -      sbus_writel(qec_sdev->reg_addrs[1].reg_size,
 +      sbus_writel(resource_size(&qec_op->resource[1]),
                    gregs + GLOB_MSIZE);
  
        /* Half to the transmitter, half to the receiver. */
 -      sbus_writel(qec_sdev->reg_addrs[1].reg_size >> 1,
 +      sbus_writel(resource_size(&qec_op->resource[1]) >> 1,
                    gregs + GLOB_TSIZE);
 -      sbus_writel(qec_sdev->reg_addrs[1].reg_size >> 1,
 +      sbus_writel(resource_size(&qec_op->resource[1]) >> 1,
                    gregs + GLOB_RSIZE);
  }
  
@@@ -240,10 -239,9 +240,10 @@@ static void bigmac_init_rings(struct bi
                skb_reserve(skb, 34);
  
                bb->be_rxd[i].rx_addr =
 -                      sbus_map_single(bp->bigmac_sdev, skb->data,
 -                                      RX_BUF_ALLOC_SIZE - 34,
 -                                      SBUS_DMA_FROMDEVICE);
 +                      dma_map_single(&bp->bigmac_op->dev,
 +                                     skb->data,
 +                                     RX_BUF_ALLOC_SIZE - 34,
 +                                     DMA_FROM_DEVICE);
                bb->be_rxd[i].rx_flags =
                        (RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH));
        }
@@@ -778,9 -776,9 +778,9 @@@ static void bigmac_tx(struct bigmac *bp
                skb = bp->tx_skbs[elem];
                bp->enet_stats.tx_packets++;
                bp->enet_stats.tx_bytes += skb->len;
 -              sbus_unmap_single(bp->bigmac_sdev,
 -                                this->tx_addr, skb->len,
 -                                SBUS_DMA_TODEVICE);
 +              dma_unmap_single(&bp->bigmac_op->dev,
 +                               this->tx_addr, skb->len,
 +                               DMA_TO_DEVICE);
  
                DTX(("skb(%p) ", skb));
                bp->tx_skbs[elem] = NULL;
@@@ -833,19 -831,18 +833,19 @@@ static void bigmac_rx(struct bigmac *bp
                                drops++;
                                goto drop_it;
                        }
 -                      sbus_unmap_single(bp->bigmac_sdev,
 -                                        this->rx_addr,
 -                                        RX_BUF_ALLOC_SIZE - 34,
 -                                        SBUS_DMA_FROMDEVICE);
 +                      dma_unmap_single(&bp->bigmac_op->dev,
 +                                       this->rx_addr,
 +                                       RX_BUF_ALLOC_SIZE - 34,
 +                                       DMA_FROM_DEVICE);
                        bp->rx_skbs[elem] = new_skb;
                        new_skb->dev = bp->dev;
                        skb_put(new_skb, ETH_FRAME_LEN);
                        skb_reserve(new_skb, 34);
 -                      this->rx_addr = sbus_map_single(bp->bigmac_sdev,
 -                                                      new_skb->data,
 -                                                      RX_BUF_ALLOC_SIZE - 34,
 -                                                      SBUS_DMA_FROMDEVICE);
 +                      this->rx_addr =
 +                              dma_map_single(&bp->bigmac_op->dev,
 +                                             new_skb->data,
 +                                             RX_BUF_ALLOC_SIZE - 34,
 +                                             DMA_FROM_DEVICE);
                        this->rx_flags =
                                (RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH));
  
                        }
                        skb_reserve(copy_skb, 2);
                        skb_put(copy_skb, len);
 -                      sbus_dma_sync_single_for_cpu(bp->bigmac_sdev,
 -                                                   this->rx_addr, len,
 -                                                   SBUS_DMA_FROMDEVICE);
 +                      dma_sync_single_for_cpu(&bp->bigmac_op->dev,
 +                                              this->rx_addr, len,
 +                                              DMA_FROM_DEVICE);
                        skb_copy_to_linear_data(copy_skb, (unsigned char *)skb->data, len);
 -                      sbus_dma_sync_single_for_device(bp->bigmac_sdev,
 -                                                      this->rx_addr, len,
 -                                                      SBUS_DMA_FROMDEVICE);
 +                      dma_sync_single_for_device(&bp->bigmac_op->dev,
 +                                                 this->rx_addr, len,
 +                                                 DMA_FROM_DEVICE);
  
                        /* Reuse original ring buffer. */
                        this->rx_flags =
@@@ -962,8 -959,7 +962,8 @@@ static int bigmac_start_xmit(struct sk_
        u32 mapping;
  
        len = skb->len;
 -      mapping = sbus_map_single(bp->bigmac_sdev, skb->data, len, SBUS_DMA_TODEVICE);
 +      mapping = dma_map_single(&bp->bigmac_op->dev, skb->data,
 +                               len, DMA_TO_DEVICE);
  
        /* Avoid a race... */
        spin_lock_irq(&bp->lock);
@@@ -1055,8 -1051,12 +1055,8 @@@ static void bigmac_set_multicast(struc
  /* Ethtool support... */
  static void bigmac_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
  {
 -      struct bigmac *bp = dev->priv;
 -
        strcpy(info->driver, "sunbmac");
        strcpy(info->version, "2.0");
 -      sprintf(info->bus_info, "SBUS:%d",
 -              bp->qec_sdev->slot);
  }
  
  static u32 bigmac_get_link(struct net_device *dev)
@@@ -1075,15 -1075,14 +1075,15 @@@ static const struct ethtool_ops bigmac_
        .get_link               = bigmac_get_link,
  };
  
 -static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev)
 +static int __devinit bigmac_ether_init(struct of_device *op,
 +                                     struct of_device *qec_op)
  {
 -      struct net_device *dev;
        static int version_printed;
 -      struct bigmac *bp;
 +      struct net_device *dev;
        u8 bsizes, bsizes_more;
 -      int i;
        DECLARE_MAC_BUF(mac);
 +      struct bigmac *bp;
 +      int i;
  
        /* Get a new device struct for this interface. */
        dev = alloc_etherdev(sizeof(struct bigmac));
        if (version_printed++ == 0)
                printk(KERN_INFO "%s", version);
  
 -      dev->base_addr = (long) qec_sdev;
        for (i = 0; i < 6; i++)
                dev->dev_addr[i] = idprom->id_ethaddr[i];
  
        /* Setup softc, with backpointers to QEC and BigMAC SBUS device structs. */
 -      bp = dev->priv;
 -      bp->qec_sdev = qec_sdev;
 -      bp->bigmac_sdev = qec_sdev->child;
 +      bp = netdev_priv(dev);
 +      bp->qec_op = qec_op;
 +      bp->bigmac_op = op;
  
 -      SET_NETDEV_DEV(dev, &bp->bigmac_sdev->ofdev.dev);
 +      SET_NETDEV_DEV(dev, &op->dev);
  
        spin_lock_init(&bp->lock);
  
 -      /* Verify the registers we expect, are actually there. */
 -      if ((bp->bigmac_sdev->num_registers != 3) ||
 -         (bp->qec_sdev->num_registers != 2)) {
 -              printk(KERN_ERR "BIGMAC: Device does not have 2 and 3 regs, it has %d and %d.\n",
 -                     bp->qec_sdev->num_registers,
 -                     bp->bigmac_sdev->num_registers);
 -              printk(KERN_ERR "BIGMAC: Would you like that for here or to go?\n");
 -              goto fail_and_cleanup;
 -      }
 -
        /* Map in QEC global control registers. */
 -      bp->gregs = sbus_ioremap(&bp->qec_sdev->resource[0], 0,
 -                               GLOB_REG_SIZE, "BigMAC QEC GLobal Regs");
 +      bp->gregs = of_ioremap(&qec_op->resource[0], 0,
 +                             GLOB_REG_SIZE, "BigMAC QEC GLobal Regs");
        if (!bp->gregs) {
                printk(KERN_ERR "BIGMAC: Cannot map QEC global registers.\n");
                goto fail_and_cleanup;
                goto fail_and_cleanup;
  
        /* Get supported SBUS burst sizes. */
 -      bsizes = prom_getintdefault(bp->qec_sdev->prom_node,
 -                                  "burst-sizes",
 -                                  0xff);
 -
 -      bsizes_more = prom_getintdefault(bp->qec_sdev->bus->prom_node,
 -                                       "burst-sizes",
 -                                       0xff);
 +      bsizes = of_getintprop_default(qec_op->node, "burst-sizes", 0xff);
 +      bsizes_more = of_getintprop_default(qec_op->node, "burst-sizes", 0xff);
  
        bsizes &= 0xff;
        if (bsizes_more != 0xff)
        qec_init(bp);
  
        /* Map in the BigMAC channel registers. */
 -      bp->creg = sbus_ioremap(&bp->bigmac_sdev->resource[0], 0,
 -                              CREG_REG_SIZE, "BigMAC QEC Channel Regs");
 +      bp->creg = of_ioremap(&op->resource[0], 0,
 +                            CREG_REG_SIZE, "BigMAC QEC Channel Regs");
        if (!bp->creg) {
                printk(KERN_ERR "BIGMAC: Cannot map QEC channel registers.\n");
                goto fail_and_cleanup;
        }
  
        /* Map in the BigMAC control registers. */
 -      bp->bregs = sbus_ioremap(&bp->bigmac_sdev->resource[1], 0,
 -                               BMAC_REG_SIZE, "BigMAC Primary Regs");
 +      bp->bregs = of_ioremap(&op->resource[1], 0,
 +                             BMAC_REG_SIZE, "BigMAC Primary Regs");
        if (!bp->bregs) {
                printk(KERN_ERR "BIGMAC: Cannot map BigMAC primary registers.\n");
                goto fail_and_cleanup;
        /* Map in the BigMAC transceiver registers, this is how you poke at
         * the BigMAC's PHY.
         */
 -      bp->tregs = sbus_ioremap(&bp->bigmac_sdev->resource[2], 0,
 -                               TCVR_REG_SIZE, "BigMAC Transceiver Regs");
 +      bp->tregs = of_ioremap(&op->resource[2], 0,
 +                             TCVR_REG_SIZE, "BigMAC Transceiver Regs");
        if (!bp->tregs) {
                printk(KERN_ERR "BIGMAC: Cannot map BigMAC transceiver registers.\n");
                goto fail_and_cleanup;
        bigmac_stop(bp);
  
        /* Allocate transmit/receive descriptor DVMA block. */
 -      bp->bmac_block = sbus_alloc_consistent(bp->bigmac_sdev,
 -                                             PAGE_SIZE,
 -                                             &bp->bblock_dvma);
 +      bp->bmac_block = dma_alloc_coherent(&bp->bigmac_op->dev,
 +                                          PAGE_SIZE,
 +                                          &bp->bblock_dvma, GFP_ATOMIC);
        if (bp->bmac_block == NULL || bp->bblock_dvma == 0) {
                printk(KERN_ERR "BIGMAC: Cannot allocate consistent DMA.\n");
                goto fail_and_cleanup;
        }
  
        /* Get the board revision of this BigMAC. */
 -      bp->board_rev = prom_getintdefault(bp->bigmac_sdev->prom_node,
 -                                         "board-version", 1);
 +      bp->board_rev = of_getintprop_default(bp->bigmac_op->node,
 +                                            "board-version", 1);
  
        /* Init auto-negotiation timer state. */
        init_timer(&bp->bigmac_timer);
        dev->watchdog_timeo = 5*HZ;
  
        /* Finish net device registration. */
 -      dev->irq = bp->bigmac_sdev->irqs[0];
 +      dev->irq = bp->bigmac_op->irqs[0];
        dev->dma = 0;
  
        if (register_netdev(dev)) {
                goto fail_and_cleanup;
        }
  
 -      dev_set_drvdata(&bp->bigmac_sdev->ofdev.dev, bp);
 +      dev_set_drvdata(&bp->bigmac_op->dev, bp);
  
        printk(KERN_INFO "%s: BigMAC 100baseT Ethernet %s\n",
               dev->name, print_mac(mac, dev->dev_addr));
@@@ -1221,67 -1236,66 +1221,67 @@@ fail_and_cleanup
        /* Something went wrong, undo whatever we did so far. */
        /* Free register mappings if any. */
        if (bp->gregs)
 -              sbus_iounmap(bp->gregs, GLOB_REG_SIZE);
 +              of_iounmap(&qec_op->resource[0], bp->gregs, GLOB_REG_SIZE);
        if (bp->creg)
 -              sbus_iounmap(bp->creg, CREG_REG_SIZE);
 +              of_iounmap(&op->resource[0], bp->creg, CREG_REG_SIZE);
        if (bp->bregs)
 -              sbus_iounmap(bp->bregs, BMAC_REG_SIZE);
 +              of_iounmap(&op->resource[1], bp->bregs, BMAC_REG_SIZE);
        if (bp->tregs)
 -              sbus_iounmap(bp->tregs, TCVR_REG_SIZE);
 +              of_iounmap(&op->resource[2], bp->tregs, TCVR_REG_SIZE);
  
        if (bp->bmac_block)
 -              sbus_free_consistent(bp->bigmac_sdev,
 -                                   PAGE_SIZE,
 -                                   bp->bmac_block,
 -                                   bp->bblock_dvma);
 +              dma_free_coherent(&bp->bigmac_op->dev,
 +                                PAGE_SIZE,
 +                                bp->bmac_block,
 +                                bp->bblock_dvma);
  
        /* This also frees the co-located 'dev->priv' */
        free_netdev(dev);
        return -ENODEV;
  }
  
 -/* QEC can be the parent of either QuadEthernet or
 - * a BigMAC.  We want the latter.
 +/* QEC can be the parent of either QuadEthernet or a BigMAC.  We want
 + * the latter.
   */
 -static int __devinit bigmac_sbus_probe(struct of_device *dev, const struct of_device_id *match)
 +static int __devinit bigmac_sbus_probe(struct of_device *op,
 +                                     const struct of_device_id *match)
  {
 -      struct sbus_dev *sdev = to_sbus_device(&dev->dev);
 -      struct device_node *dp = dev->node;
 +      struct device *parent = op->dev.parent;
 +      struct of_device *qec_op;
  
 -      if (!strcmp(dp->name, "be"))
 -              sdev = sdev->parent;
 +      qec_op = to_of_device(parent);
  
 -      return bigmac_ether_init(sdev);
 +      return bigmac_ether_init(op, qec_op);
  }
  
 -static int __devexit bigmac_sbus_remove(struct of_device *dev)
 +static int __devexit bigmac_sbus_remove(struct of_device *op)
  {
 -      struct bigmac *bp = dev_get_drvdata(&dev->dev);
 +      struct bigmac *bp = dev_get_drvdata(&op->dev);
 +      struct device *parent = op->dev.parent;
        struct net_device *net_dev = bp->dev;
 +      struct of_device *qec_op;
 +
 +      qec_op = to_of_device(parent);
  
-       unregister_netdevice(net_dev);
+       unregister_netdev(net_dev);
  
 -      sbus_iounmap(bp->gregs, GLOB_REG_SIZE);
 -      sbus_iounmap(bp->creg, CREG_REG_SIZE);
 -      sbus_iounmap(bp->bregs, BMAC_REG_SIZE);
 -      sbus_iounmap(bp->tregs, TCVR_REG_SIZE);
 -      sbus_free_consistent(bp->bigmac_sdev,
 -                           PAGE_SIZE,
 -                           bp->bmac_block,
 -                           bp->bblock_dvma);
 +      of_iounmap(&qec_op->resource[0], bp->gregs, GLOB_REG_SIZE);
 +      of_iounmap(&op->resource[0], bp->creg, CREG_REG_SIZE);
 +      of_iounmap(&op->resource[1], bp->bregs, BMAC_REG_SIZE);
 +      of_iounmap(&op->resource[2], bp->tregs, TCVR_REG_SIZE);
 +      dma_free_coherent(&op->dev,
 +                        PAGE_SIZE,
 +                        bp->bmac_block,
 +                        bp->bblock_dvma);
  
        free_netdev(net_dev);
  
 -      dev_set_drvdata(&dev->dev, NULL);
 +      dev_set_drvdata(&op->dev, NULL);
  
        return 0;
  }
  
 -static struct of_device_id bigmac_sbus_match[] = {
 -      {
 -              .name = "qec",
 -      },
 +static const struct of_device_id bigmac_sbus_match[] = {
        {
                .name = "be",
        },
@@@ -1299,7 -1313,7 +1299,7 @@@ static struct of_platform_driver bigmac
  
  static int __init bigmac_init(void)
  {
 -      return of_register_driver(&bigmac_sbus_driver, &sbus_bus_type);
 +      return of_register_driver(&bigmac_sbus_driver, &of_bus_type);
  }
  
  static void __exit bigmac_exit(void)
diff --combined drivers/scsi/qlogicpti.c
@@@ -1,6 -1,6 +1,6 @@@
  /* qlogicpti.c: Performance Technologies QlogicISP sbus card driver.
   *
 - * Copyright (C) 1996, 2006 David S. Miller (davem@davemloft.net)
 + * Copyright (C) 1996, 2006, 2008 David S. Miller (davem@davemloft.net)
   *
   * A lot of this driver was directly stolen from Erik H. Moe's PCI
   * Qlogic ISP driver.  Mucho kudos to him for this code.
  #include <linux/interrupt.h>
  #include <linux/module.h>
  #include <linux/jiffies.h>
 +#include <linux/dma-mapping.h>
 +#include <linux/of.h>
 +#include <linux/of_device.h>
  
  #include <asm/byteorder.h>
  
  #include "qlogicpti.h"
  
 -#include <asm/sbus.h>
  #include <asm/dma.h>
  #include <asm/system.h>
  #include <asm/ptrace.h>
@@@ -159,7 -157,7 +159,7 @@@ static inline void set_sbus_cfg1(struc
         * is a nop and the chip ends up using the smallest burst
         * size. -DaveM
         */
 -      if (sbus_can_burst64(qpti->sdev) && (bursts & DMA_BURST64)) {
 +      if (sbus_can_burst64() && (bursts & DMA_BURST64)) {
                val = (SBUS_CFG1_BENAB | SBUS_CFG1_B64);
        } else
  #endif
@@@ -686,19 -684,19 +686,19 @@@ static void __devexit qpti_chain_del(st
  
  static int __devinit qpti_map_regs(struct qlogicpti *qpti)
  {
 -      struct sbus_dev *sdev = qpti->sdev;
 +      struct of_device *op = qpti->op;
  
 -      qpti->qregs = sbus_ioremap(&sdev->resource[0], 0,
 -                                 sdev->reg_addrs[0].reg_size,
 -                                 "PTI Qlogic/ISP");
 +      qpti->qregs = of_ioremap(&op->resource[0], 0,
 +                               resource_size(&op->resource[0]),
 +                               "PTI Qlogic/ISP");
        if (!qpti->qregs) {
                printk("PTI: Qlogic/ISP registers are unmappable\n");
                return -1;
        }
        if (qpti->is_pti) {
 -              qpti->sreg = sbus_ioremap(&sdev->resource[0], (16 * 4096),
 -                                        sizeof(unsigned char),
 -                                        "PTI Qlogic/ISP statreg");
 +              qpti->sreg = of_ioremap(&op->resource[0], (16 * 4096),
 +                                      sizeof(unsigned char),
 +                                      "PTI Qlogic/ISP statreg");
                if (!qpti->sreg) {
                        printk("PTI: Qlogic/ISP status register is unmappable\n");
                        return -1;
  
  static int __devinit qpti_register_irq(struct qlogicpti *qpti)
  {
 -      struct sbus_dev *sdev = qpti->sdev;
 +      struct of_device *op = qpti->op;
  
 -      qpti->qhost->irq = qpti->irq = sdev->irqs[0];
 +      qpti->qhost->irq = qpti->irq = op->irqs[0];
  
        /* We used to try various overly-clever things to
         * reduce the interrupt processing overhead on
@@@ -734,19 -732,17 +734,19 @@@ fail
  
  static void __devinit qpti_get_scsi_id(struct qlogicpti *qpti)
  {
 -      qpti->scsi_id = prom_getintdefault(qpti->prom_node,
 -                                         "initiator-id",
 -                                         -1);
 +      struct of_device *op = qpti->op;
 +      struct device_node *dp;
 +
 +      dp = op->node;
 +
 +      qpti->scsi_id = of_getintprop_default(dp, "initiator-id", -1);
        if (qpti->scsi_id == -1)
 -              qpti->scsi_id = prom_getintdefault(qpti->prom_node,
 -                                                 "scsi-initiator-id",
 -                                                 -1);
 +              qpti->scsi_id = of_getintprop_default(dp, "scsi-initiator-id",
 +                                                    -1);
        if (qpti->scsi_id == -1)
                qpti->scsi_id =
 -                      prom_getintdefault(qpti->sdev->bus->prom_node,
 -                                         "scsi-initiator-id", 7);
 +                      of_getintprop_default(dp->parent,
 +                                            "scsi-initiator-id", 7);
        qpti->qhost->this_id = qpti->scsi_id;
        qpti->qhost->max_sectors = 64;
  
  
  static void qpti_get_bursts(struct qlogicpti *qpti)
  {
 -      struct sbus_dev *sdev = qpti->sdev;
 +      struct of_device *op = qpti->op;
        u8 bursts, bmask;
  
 -      bursts = prom_getintdefault(qpti->prom_node, "burst-sizes", 0xff);
 -      bmask = prom_getintdefault(sdev->bus->prom_node,
 -                                 "burst-sizes", 0xff);
 +      bursts = of_getintprop_default(op->node, "burst-sizes", 0xff);
 +      bmask = of_getintprop_default(op->node->parent, "burst-sizes", 0xff);
        if (bmask != 0xff)
                bursts &= bmask;
        if (bursts == 0xff ||
@@@ -788,25 -785,25 +788,25 @@@ static void qpti_get_clock(struct qlogi
   */
  static int __devinit qpti_map_queues(struct qlogicpti *qpti)
  {
 -      struct sbus_dev *sdev = qpti->sdev;
 +      struct of_device *op = qpti->op;
  
  #define QSIZE(entries)        (((entries) + 1) * QUEUE_ENTRY_LEN)
 -      qpti->res_cpu = sbus_alloc_consistent(sdev,
 -                                            QSIZE(RES_QUEUE_LEN),
 -                                            &qpti->res_dvma);
 +      qpti->res_cpu = dma_alloc_coherent(&op->dev,
 +                                         QSIZE(RES_QUEUE_LEN),
 +                                         &qpti->res_dvma, GFP_ATOMIC);
        if (qpti->res_cpu == NULL ||
            qpti->res_dvma == 0) {
                printk("QPTI: Cannot map response queue.\n");
                return -1;
        }
  
 -      qpti->req_cpu = sbus_alloc_consistent(sdev,
 -                                            QSIZE(QLOGICPTI_REQ_QUEUE_LEN),
 -                                            &qpti->req_dvma);
 +      qpti->req_cpu = dma_alloc_coherent(&op->dev,
 +                                         QSIZE(QLOGICPTI_REQ_QUEUE_LEN),
 +                                         &qpti->req_dvma, GFP_ATOMIC);
        if (qpti->req_cpu == NULL ||
            qpti->req_dvma == 0) {
 -              sbus_free_consistent(sdev, QSIZE(RES_QUEUE_LEN),
 -                                   qpti->res_cpu, qpti->res_dvma);
 +              dma_free_coherent(&op->dev, QSIZE(RES_QUEUE_LEN),
 +                                qpti->res_cpu, qpti->res_dvma);
                printk("QPTI: Cannot map request queue.\n");
                return -1;
        }
@@@ -878,9 -875,8 +878,9 @@@ static inline int load_cmd(struct scsi_
                int sg_count;
  
                sg = scsi_sglist(Cmnd);
 -              sg_count = sbus_map_sg(qpti->sdev, sg, scsi_sg_count(Cmnd),
 -                                                    Cmnd->sc_data_direction);
 +              sg_count = dma_map_sg(&qpti->op->dev, sg,
 +                                    scsi_sg_count(Cmnd),
 +                                    Cmnd->sc_data_direction);
  
                ds = cmd->dataseg;
                cmd->segment_cnt = sg_count;
                                ds[i].d_count = sg_dma_len(s);
                        }
                        sg_count -= n;
+                       sg = s;
                }
        } else {
                cmd->dataseg[0].d_base = 0;
@@@ -1155,9 -1152,9 +1156,9 @@@ static struct scsi_cmnd *qlogicpti_intr
                        Cmnd->result = DID_ERROR << 16;
  
                if (scsi_bufflen(Cmnd))
 -                      sbus_unmap_sg(qpti->sdev,
 -                                    scsi_sglist(Cmnd), scsi_sg_count(Cmnd),
 -                                    Cmnd->sc_data_direction);
 +                      dma_unmap_sg(&qpti->op->dev,
 +                                   scsi_sglist(Cmnd), scsi_sg_count(Cmnd),
 +                                   Cmnd->sc_data_direction);
  
                qpti->cmd_count[Cmnd->device->id]--;
                sbus_writew(out_ptr, qpti->qregs + MBOX5);
@@@ -1271,32 -1268,34 +1272,32 @@@ static struct scsi_host_template qpti_t
        .use_clustering         = ENABLE_CLUSTERING,
  };
  
 -static int __devinit qpti_sbus_probe(struct of_device *dev, const struct of_device_id *match)
 +static int __devinit qpti_sbus_probe(struct of_device *op, const struct of_device_id *match)
  {
 -      static int nqptis;
 -      struct sbus_dev *sdev = to_sbus_device(&dev->dev);
 -      struct device_node *dp = dev->node;
        struct scsi_host_template *tpnt = match->data;
 +      struct device_node *dp = op->node;
        struct Scsi_Host *host;
        struct qlogicpti *qpti;
 +      static int nqptis;
        const char *fcode;
  
        /* Sometimes Antares cards come up not completely
         * setup, and we get a report of a zero IRQ.
         */
 -      if (sdev->irqs[0] == 0)
 +      if (op->irqs[0] == 0)
                return -ENODEV;
  
        host = scsi_host_alloc(tpnt, sizeof(struct qlogicpti));
        if (!host)
                return -ENOMEM;
  
 -      qpti = (struct qlogicpti *) host->hostdata;
 +      qpti = shost_priv(host);
  
        host->max_id = MAX_TARGETS;
        qpti->qhost = host;
 -      qpti->sdev = sdev;
 +      qpti->op = op;
        qpti->qpti_id = nqptis;
 -      qpti->prom_node = sdev->prom_node;
 -      strcpy(qpti->prom_name, sdev->ofdev.node->name);
 +      strcpy(qpti->prom_name, op->node->name);
        qpti->is_pti = strcmp(qpti->prom_name, "QLGC,isp");
  
        if (qpti_map_regs(qpti) < 0)
                (qpti->ultra ? "Ultra" : "Fast"),
                (qpti->differential ? "differential" : "single ended"));
  
 -      if (scsi_add_host(host, &dev->dev)) {
 +      if (scsi_add_host(host, &op->dev)) {
                printk("qlogicpti%d: Failed scsi_add_host\n", qpti->qpti_id);
                goto fail_unmap_queues;
        }
  
 -      dev_set_drvdata(&sdev->ofdev.dev, qpti);
 +      dev_set_drvdata(&op->dev, qpti);
  
        qpti_chain_add(qpti);
  
  
  fail_unmap_queues:
  #define QSIZE(entries)        (((entries) + 1) * QUEUE_ENTRY_LEN)
 -      sbus_free_consistent(qpti->sdev,
 -                           QSIZE(RES_QUEUE_LEN),
 -                           qpti->res_cpu, qpti->res_dvma);
 -      sbus_free_consistent(qpti->sdev,
 -                           QSIZE(QLOGICPTI_REQ_QUEUE_LEN),
 -                           qpti->req_cpu, qpti->req_dvma);
 +      dma_free_coherent(&op->dev,
 +                        QSIZE(RES_QUEUE_LEN),
 +                        qpti->res_cpu, qpti->res_dvma);
 +      dma_free_coherent(&op->dev,
 +                        QSIZE(QLOGICPTI_REQ_QUEUE_LEN),
 +                        qpti->req_cpu, qpti->req_dvma);
  #undef QSIZE
  
  fail_unmap_regs:
 -      sbus_iounmap(qpti->qregs,
 -                   qpti->sdev->reg_addrs[0].reg_size);
 +      of_iounmap(&op->resource[0], qpti->qregs,
 +                 resource_size(&op->resource[0]));
        if (qpti->is_pti)
 -              sbus_iounmap(qpti->sreg, sizeof(unsigned char));
 +              of_iounmap(&op->resource[0], qpti->sreg,
 +                         sizeof(unsigned char));
  
  fail_free_irq:
        free_irq(qpti->irq, qpti);
@@@ -1382,9 -1380,9 +1383,9 @@@ fail_unlink
        return -ENODEV;
  }
  
 -static int __devexit qpti_sbus_remove(struct of_device *dev)
 +static int __devexit qpti_sbus_remove(struct of_device *op)
  {
 -      struct qlogicpti *qpti = dev_get_drvdata(&dev->dev);
 +      struct qlogicpti *qpti = dev_get_drvdata(&op->dev);
  
        qpti_chain_del(qpti);
  
        free_irq(qpti->irq, qpti);
  
  #define QSIZE(entries)        (((entries) + 1) * QUEUE_ENTRY_LEN)
 -      sbus_free_consistent(qpti->sdev,
 -                           QSIZE(RES_QUEUE_LEN),
 -                           qpti->res_cpu, qpti->res_dvma);
 -      sbus_free_consistent(qpti->sdev,
 -                           QSIZE(QLOGICPTI_REQ_QUEUE_LEN),
 -                           qpti->req_cpu, qpti->req_dvma);
 +      dma_free_coherent(&op->dev,
 +                        QSIZE(RES_QUEUE_LEN),
 +                        qpti->res_cpu, qpti->res_dvma);
 +      dma_free_coherent(&op->dev,
 +                        QSIZE(QLOGICPTI_REQ_QUEUE_LEN),
 +                        qpti->req_cpu, qpti->req_dvma);
  #undef QSIZE
  
 -      sbus_iounmap(qpti->qregs, qpti->sdev->reg_addrs[0].reg_size);
 +      of_iounmap(&op->resource[0], qpti->qregs,
 +                 resource_size(&op->resource[0]));
        if (qpti->is_pti)
 -              sbus_iounmap(qpti->sreg, sizeof(unsigned char));
 +              of_iounmap(&op->resource[0], qpti->sreg, sizeof(unsigned char));
  
        scsi_host_put(qpti->qhost);
  
        return 0;
  }
  
 -static struct of_device_id qpti_match[] = {
 +static const struct of_device_id qpti_match[] = {
        {
                .name = "ptisp",
                .data = &qpti_template,
@@@ -1445,7 -1442,7 +1446,7 @@@ static struct of_platform_driver qpti_s
  
  static int __init qpti_init(void)
  {
 -      return of_register_driver(&qpti_sbus_driver, &sbus_bus_type);
 +      return of_register_driver(&qpti_sbus_driver, &of_bus_type);
  }
  
  static void __exit qpti_exit(void)
  MODULE_DESCRIPTION("QlogicISP SBUS driver");
  MODULE_AUTHOR("David S. Miller (davem@davemloft.net)");
  MODULE_LICENSE("GPL");
 -MODULE_VERSION("2.0");
 +MODULE_VERSION("2.1");
  
  module_init(qpti_init);
  module_exit(qpti_exit);
diff --combined include/sound/core.h
@@@ -28,6 -28,7 +28,7 @@@
  #include <linux/rwsem.h>              /* struct rw_semaphore */
  #include <linux/pm.h>                 /* pm_message_t */
  #include <linux/device.h>
+ #include <linux/stringify.h>
  
  /* number of supported soundcards */
  #ifdef CONFIG_SND_DYNAMIC_MINORS
@@@ -42,6 -43,9 +43,6 @@@
  #ifdef CONFIG_PCI
  struct pci_dev;
  #endif
 -#ifdef CONFIG_SBUS
 -struct sbus_dev;
 -#endif
  
  /* device allocation stuff */
  
@@@ -60,6 -64,7 +61,7 @@@ typedef int __bitwise snd_device_type_t
  #define       SNDRV_DEV_INFO          ((__force snd_device_type_t) 0x1006)
  #define       SNDRV_DEV_BUS           ((__force snd_device_type_t) 0x1007)
  #define       SNDRV_DEV_CODEC         ((__force snd_device_type_t) 0x1008)
+ #define       SNDRV_DEV_JACK          ((__force snd_device_type_t) 0x1009)
  #define       SNDRV_DEV_LOWLEVEL      ((__force snd_device_type_t) 0x2000)
  
  typedef int __bitwise snd_device_state_t;
@@@ -111,7 -116,7 +113,7 @@@ struct snd_card 
        char shortname[32];             /* short name of this soundcard */
        char longname[80];              /* name of this soundcard */
        char mixername[80];             /* mixer name */
-       char components[80];            /* card components delimited with
+       char components[128];           /* card components delimited with
                                                                space */
        struct module *module;          /* top-level module */
  
@@@ -363,8 -368,6 +365,6 @@@ void snd_verbose_printd(const char *fil
  
  #ifdef CONFIG_SND_DEBUG
  
- #define __ASTRING__(x) #x
  #ifdef CONFIG_SND_VERBOSE_PRINTK
  /**
   * snd_printd - debug printk
  #define snd_printd(fmt, args...) \
        printk(fmt ,##args)
  #endif
- /**
-  * snd_assert - run-time assertion macro
-  * @expr: expression
-  *
-  * This macro checks the expression in run-time and invokes the commands
-  * given in the rest arguments if the assertion is failed.
-  * When CONFIG_SND_DEBUG is not set, the expression is executed but
-  * not checked.
-  */
- #define snd_assert(expr, args...) do {                                        \
-       if (unlikely(!(expr))) {                                        \
-               snd_printk(KERN_ERR "BUG? (%s)\n", __ASTRING__(expr));  \
-               dump_stack();                                           \
-               args;                                                   \
-       }                                                               \
- } while (0)
- #define snd_BUG() do {                                \
-       snd_printk(KERN_ERR "BUG?\n");          \
-       dump_stack();                           \
- } while (0)
+ #define snd_BUG()             WARN(1, "BUG?\n")
+ #define snd_BUG_ON(cond)      WARN((cond), "BUG? (%s)\n", __stringify(cond))
  
  #else /* !CONFIG_SND_DEBUG */
  
  #define snd_printd(fmt, args...)      /* nothing */
- #define snd_assert(expr, args...)     (void)(expr)
  #define snd_BUG()                     /* nothing */
+ #define snd_BUG_ON(cond)      ({/*(void)(cond);*/ 0;})  /* always false */
  
  #endif /* CONFIG_SND_DEBUG */
  
diff --combined include/sound/memalloc.h
@@@ -37,6 -37,7 +37,6 @@@ struct snd_dma_device 
  #ifndef snd_dma_pci_data
  #define snd_dma_pci_data(pci) (&(pci)->dev)
  #define snd_dma_isa_data()    NULL
 -#define snd_dma_sbus_data(sbus)       ((struct device *)(sbus))
  #define snd_dma_continuous_data(x)    ((struct device *)(unsigned long)(x))
  #endif
  
@@@ -48,6 -49,7 +48,6 @@@
  #define SNDRV_DMA_TYPE_CONTINUOUS     1       /* continuous no-DMA memory */
  #define SNDRV_DMA_TYPE_DEV            2       /* generic device continuous */
  #define SNDRV_DMA_TYPE_DEV_SG         3       /* generic device SG-buffer */
 -#define SNDRV_DMA_TYPE_SBUS           4       /* SBUS continuous */
  
  /*
   * info for buffer allocation
@@@ -63,6 -65,11 +63,11 @@@ struct snd_dma_buffer 
  /*
   * Scatter-Gather generic device pages
   */
+ void *snd_malloc_sgbuf_pages(struct device *device,
+                            size_t size, struct snd_dma_buffer *dmab,
+                            size_t *res_size);
+ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab);
  struct snd_sg_page {
        void *buf;
        dma_addr_t addr;
@@@ -90,9 -97,18 +95,18 @@@ static inline unsigned int snd_sgbuf_al
   */
  static inline dma_addr_t snd_sgbuf_get_addr(struct snd_sg_buf *sgbuf, size_t offset)
  {
-       return sgbuf->table[offset >> PAGE_SHIFT].addr + offset % PAGE_SIZE;
+       dma_addr_t addr = sgbuf->table[offset >> PAGE_SHIFT].addr;
+       addr &= PAGE_MASK;
+       return addr + offset % PAGE_SIZE;
  }
  
+ /*
+  * return the virtual address at the corresponding offset
+  */
+ static inline void *snd_sgbuf_get_ptr(struct snd_sg_buf *sgbuf, size_t offset)
+ {
+       return sgbuf->table[offset >> PAGE_SHIFT].buf + offset % PAGE_SIZE;
+ }
  
  /* allocate/release a buffer */
  int snd_dma_alloc_pages(int type, struct device *dev, size_t size,
diff --combined sound/core/memalloc.c
@@@ -33,6 -33,9 +33,6 @@@
  #include <linux/moduleparam.h>
  #include <linux/mutex.h>
  #include <sound/memalloc.h>
 -#ifdef CONFIG_SBUS
 -#include <asm/sbus.h>
 -#endif
  
  
  MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>");
@@@ -43,14 -46,6 +43,6 @@@ MODULE_LICENSE("GPL")
  /*
   */
  
- void *snd_malloc_sgbuf_pages(struct device *device,
-                              size_t size, struct snd_dma_buffer *dmab,
-                            size_t *res_size);
- int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab);
- /*
-  */
  static DEFINE_MUTEX(list_mutex);
  static LIST_HEAD(mem_list_head);
  
@@@ -64,18 -59,6 +56,6 @@@ struct snd_mem_list 
  /* id for pre-allocated buffers */
  #define SNDRV_DMA_DEVICE_UNUSED (unsigned int)-1
  
- #ifdef CONFIG_SND_DEBUG
- #define __ASTRING__(x) #x
- #define snd_assert(expr, args...) do {\
-       if (!(expr)) {\
-               printk(KERN_ERR "snd-malloc: BUG? (%s) (called from %p)\n", __ASTRING__(expr), __builtin_return_address(0));\
-               args;\
-       }\
- } while (0)
- #else
- #define snd_assert(expr, args...) /**/
- #endif
  /*
   *
   *  Generic memory allocators
@@@ -108,8 -91,10 +88,10 @@@ void *snd_malloc_pages(size_t size, gfp
        int pg;
        void *res;
  
-       snd_assert(size > 0, return NULL);
-       snd_assert(gfp_flags != 0, return NULL);
+       if (WARN_ON(!size))
+               return NULL;
+       if (WARN_ON(!gfp_flags))
+               return NULL;
        gfp_flags |= __GFP_COMP;        /* compound page lets parts be mapped */
        pg = get_order(size);
        if ((res = (void *) __get_free_pages(gfp_flags, pg)) != NULL)
@@@ -149,8 -134,8 +131,8 @@@ static void *snd_malloc_dev_pages(struc
        void *res;
        gfp_t gfp_flags;
  
-       snd_assert(size > 0, return NULL);
-       snd_assert(dma != NULL, return NULL);
+       if (WARN_ON(!dma))
+               return NULL;
        pg = get_order(size);
        gfp_flags = GFP_KERNEL
                | __GFP_COMP    /* compound page lets parts be mapped */
@@@ -177,6 -162,39 +159,6 @@@ static void snd_free_dev_pages(struct d
  }
  #endif /* CONFIG_HAS_DMA */
  
 -#ifdef CONFIG_SBUS
 -
 -static void *snd_malloc_sbus_pages(struct device *dev, size_t size,
 -                                 dma_addr_t *dma_addr)
 -{
 -      struct sbus_dev *sdev = (struct sbus_dev *)dev;
 -      int pg;
 -      void *res;
 -
 -      if (WARN_ON(!dma_addr))
 -              return NULL;
 -      pg = get_order(size);
 -      res = sbus_alloc_consistent(sdev, PAGE_SIZE * (1 << pg), dma_addr);
 -      if (res != NULL)
 -              inc_snd_pages(pg);
 -      return res;
 -}
 -
 -static void snd_free_sbus_pages(struct device *dev, size_t size,
 -                              void *ptr, dma_addr_t dma_addr)
 -{
 -      struct sbus_dev *sdev = (struct sbus_dev *)dev;
 -      int pg;
 -
 -      if (ptr == NULL)
 -              return;
 -      pg = get_order(size);
 -      dec_snd_pages(pg);
 -      sbus_free_consistent(sdev, PAGE_SIZE * (1 << pg), ptr, dma_addr);
 -}
 -
 -#endif /* CONFIG_SBUS */
 -
  /*
   *
   *  ALSA generic memory management
  int snd_dma_alloc_pages(int type, struct device *device, size_t size,
                        struct snd_dma_buffer *dmab)
  {
-       snd_assert(size > 0, return -ENXIO);
-       snd_assert(dmab != NULL, return -ENXIO);
+       if (WARN_ON(!size))
+               return -ENXIO;
+       if (WARN_ON(!dmab))
+               return -ENXIO;
  
        dmab->dev.type = type;
        dmab->dev.dev = device;
                dmab->area = snd_malloc_pages(size, (unsigned long)device);
                dmab->addr = 0;
                break;
 -#ifdef CONFIG_SBUS
 -      case SNDRV_DMA_TYPE_SBUS:
 -              dmab->area = snd_malloc_sbus_pages(device, size, &dmab->addr);
 -              break;
 -#endif
  #ifdef CONFIG_HAS_DMA
        case SNDRV_DMA_TYPE_DEV:
                dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr);
@@@ -251,15 -276,17 +235,17 @@@ int snd_dma_alloc_pages_fallback(int ty
  {
        int err;
  
-       snd_assert(size > 0, return -ENXIO);
-       snd_assert(dmab != NULL, return -ENXIO);
        while ((err = snd_dma_alloc_pages(type, device, size, dmab)) < 0) {
+               size_t aligned_size;
                if (err != -ENOMEM)
                        return err;
-               size >>= 1;
                if (size <= PAGE_SIZE)
                        return -ENOMEM;
+               aligned_size = PAGE_SIZE << get_order(size);
+               if (size != aligned_size)
+                       size = aligned_size;
+               else
+                       size >>= 1;
        }
        if (! dmab->area)
                return -ENOMEM;
@@@ -279,6 -306,11 +265,6 @@@ void snd_dma_free_pages(struct snd_dma_
        case SNDRV_DMA_TYPE_CONTINUOUS:
                snd_free_pages(dmab->area, dmab->bytes);
                break;
 -#ifdef CONFIG_SBUS
 -      case SNDRV_DMA_TYPE_SBUS:
 -              snd_free_sbus_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr);
 -              break;
 -#endif
  #ifdef CONFIG_HAS_DMA
        case SNDRV_DMA_TYPE_DEV:
                snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr);
@@@ -307,7 -339,8 +293,8 @@@ size_t snd_dma_get_reserved_buf(struct 
  {
        struct snd_mem_list *mem;
  
-       snd_assert(dmab, return 0);
+       if (WARN_ON(!dmab))
+               return 0;
  
        mutex_lock(&list_mutex);
        list_for_each_entry(mem, &mem_list_head, list) {
@@@ -341,7 -374,8 +328,8 @@@ int snd_dma_reserve_buf(struct snd_dma_
  {
        struct snd_mem_list *mem;
  
-       snd_assert(dmab, return -EINVAL);
+       if (WARN_ON(!dmab))
+               return -EINVAL;
        mem = kmalloc(sizeof(*mem), GFP_KERNEL);
        if (! mem)
                return -ENOMEM;
@@@ -385,7 -419,7 +373,7 @@@ static int snd_mem_proc_read(struct seq
        long pages = snd_allocated_pages >> (PAGE_SHIFT-12);
        struct snd_mem_list *mem;
        int devno;
 -      static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" };
 +      static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG" };
  
        mutex_lock(&list_mutex);
        seq_printf(seq, "pages  : %li bytes (%li pages per %likB)\n",
diff --combined sound/sparc/amd7930.c
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Driver for AMD7930 sound chips found on Sparcs.
 - * Copyright (C) 2002 David S. Miller <davem@redhat.com>
 + * Copyright (C) 2002, 2008 David S. Miller <davem@davemloft.net>
   *
   * Based entirely upon drivers/sbus/audio/amd7930.c which is:
   * Copyright (C) 1996,1997 Thomas K. Dyas (tdyas@eden.rutgers.edu)
@@@ -35,8 -35,6 +35,8 @@@
  #include <linux/init.h>
  #include <linux/interrupt.h>
  #include <linux/moduleparam.h>
 +#include <linux/of.h>
 +#include <linux/of_device.h>
  
  #include <sound/core.h>
  #include <sound/pcm.h>
@@@ -46,6 -44,7 +46,6 @@@
  
  #include <asm/io.h>
  #include <asm/irq.h>
 -#include <asm/sbus.h>
  #include <asm/prom.h>
  
  static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;    /* Index 0-MAX */
@@@ -336,8 -335,8 +336,8 @@@ struct snd_amd7930 
        int                     pgain;
        int                     mgain;
  
 +      struct of_device        *op;
        unsigned int            irq;
 -      unsigned int            regs_size;
        struct snd_amd7930      *next;
  };
  
@@@ -766,7 -765,6 +766,6 @@@ static int __devinit snd_amd7930_pcm(st
                               /* playback count */ 1,
                               /* capture count */  1, &pcm)) < 0)
                return err;
-       snd_assert(pcm != NULL, return -EINVAL);
  
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_amd7930_playback_ops);
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_amd7930_capture_ops);
  
  static int snd_amd7930_info_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem_info *uinfo)
  {
-       int type = kctl->private_value;
-       snd_assert(type == VOLUME_MONITOR ||
-                  type == VOLUME_CAPTURE ||
-                  type == VOLUME_PLAYBACK, return -EINVAL);
-       (void) type;
        uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
        uinfo->count = 1;
        uinfo->value.integer.min = 0;
@@@ -810,10 -801,6 +802,6 @@@ static int snd_amd7930_get_volume(struc
        int type = kctl->private_value;
        int *swval;
  
-       snd_assert(type == VOLUME_MONITOR ||
-                  type == VOLUME_CAPTURE ||
-                  type == VOLUME_PLAYBACK, return -EINVAL);
        switch (type) {
        case VOLUME_MONITOR:
                swval = &amd->mgain;
@@@ -839,10 -826,6 +827,6 @@@ static int snd_amd7930_put_volume(struc
        int type = kctl->private_value;
        int *swval, change;
  
-       snd_assert(type == VOLUME_MONITOR ||
-                  type == VOLUME_CAPTURE ||
-                  type == VOLUME_PLAYBACK, return -EINVAL);
        switch (type) {
        case VOLUME_MONITOR:
                swval = &amd->mgain;
@@@ -905,7 -888,8 +889,8 @@@ static int __devinit snd_amd7930_mixer(
        struct snd_card *card;
        int idx, err;
  
-       snd_assert(amd != NULL && amd->card != NULL, return -EINVAL);
+       if (snd_BUG_ON(!amd || !amd->card))
+               return -EINVAL;
  
        card = amd->card;
        strcpy(card->mixername, card->shortname);
  
  static int snd_amd7930_free(struct snd_amd7930 *amd)
  {
 +      struct of_device *op = amd->op;
 +
        amd7930_idle(amd);
  
        if (amd->irq)
                free_irq(amd->irq, amd);
  
        if (amd->regs)
 -              sbus_iounmap(amd->regs, amd->regs_size);
 +              of_iounmap(&op->resource[0], amd->regs,
 +                         resource_size(&op->resource[0]));
  
        kfree(amd);
  
@@@ -949,12 -930,13 +934,12 @@@ static struct snd_device_ops snd_amd793
  };
  
  static int __devinit snd_amd7930_create(struct snd_card *card,
 -                                      struct resource *rp,
 -                                      unsigned int reg_size,
 +                                      struct of_device *op,
                                        int irq, int dev,
                                        struct snd_amd7930 **ramd)
  {
 -      unsigned long flags;
        struct snd_amd7930 *amd;
 +      unsigned long flags;
        int err;
  
        *ramd = NULL;
  
        spin_lock_init(&amd->lock);
        amd->card = card;
 -      amd->regs_size = reg_size;
 +      amd->op = op;
  
 -      amd->regs = sbus_ioremap(rp, 0, amd->regs_size, "amd7930");
 +      amd->regs = of_ioremap(&op->resource[0], 0,
 +                             resource_size(&op->resource[0]), "amd7930");
        if (!amd->regs) {
                snd_printk("amd7930-%d: Unable to map chip registers.\n", dev);
                return -EIO;
        return 0;
  }
  
 -static int __devinit amd7930_attach_common(struct resource *rp, int irq)
 +static int __devinit amd7930_sbus_probe(struct of_device *op, const struct of_device_id *match)
  {
 +      struct resource *rp = &op->resource[0];
        static int dev_num;
        struct snd_card *card;
        struct snd_amd7930 *amd;
 -      int err;
 +      int err, irq;
 +
 +      irq = op->irqs[0];
  
        if (dev_num >= SNDRV_CARDS)
                return -ENODEV;
                (unsigned long long)rp->start,
                irq);
  
 -      if ((err = snd_amd7930_create(card, rp,
 -                                    (rp->end - rp->start) + 1,
 +      if ((err = snd_amd7930_create(card, op,
                                      irq, dev_num, &amd)) < 0)
                goto out_err;
  
@@@ -1070,7 -1049,43 +1055,7 @@@ out_err
        return err;
  }
  
 -static int __devinit amd7930_obio_attach(struct device_node *dp)
 -{
 -      const struct linux_prom_registers *regs;
 -      const struct linux_prom_irqs *irqp;
 -      struct resource res, *rp;
 -      int len;
 -
 -      irqp = of_get_property(dp, "intr", &len);
 -      if (!irqp) {
 -              snd_printk("%s: Firmware node lacks IRQ property.\n",
 -                         dp->full_name);
 -              return -ENODEV;
 -      }
 -
 -      regs = of_get_property(dp, "reg", &len);
 -      if (!regs) {
 -              snd_printk("%s: Firmware node lacks register property.\n",
 -                         dp->full_name);
 -              return -ENODEV;
 -      }
 -
 -      rp = &res;
 -      rp->start = regs->phys_addr;
 -      rp->end = rp->start + regs->reg_size - 1;
 -      rp->flags = IORESOURCE_IO | (regs->which_io & 0xff);
 -
 -      return amd7930_attach_common(rp, irqp->pri);
 -}
 -
 -static int __devinit amd7930_sbus_probe(struct of_device *dev, const struct of_device_id *match)
 -{
 -      struct sbus_dev *sdev = to_sbus_device(&dev->dev);
 -
 -      return amd7930_attach_common(&sdev->resource[0], sdev->irqs[0]);
 -}
 -
 -static struct of_device_id amd7930_match[] = {
 +static const struct of_device_id amd7930_match[] = {
        {
                .name = "audio",
        },
@@@ -1085,7 -1100,20 +1070,7 @@@ static struct of_platform_driver amd793
  
  static int __init amd7930_init(void)
  {
 -      struct device_node *dp;
 -
 -      /* Try to find the sun4c "audio" node first. */
 -      dp = of_find_node_by_path("/");
 -      dp = dp->child;
 -      while (dp) {
 -              if (!strcmp(dp->name, "audio"))
 -                      amd7930_obio_attach(dp);
 -
 -              dp = dp->sibling;
 -      }
 -
 -      /* Probe each SBUS for amd7930 chips. */
 -      return of_register_driver(&amd7930_sbus_driver, &sbus_bus_type);
 +      return of_register_driver(&amd7930_sbus_driver, &of_bus_type);
  }
  
  static void __exit amd7930_exit(void)
diff --combined sound/sparc/cs4231.c
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Driver for CS4231 sound chips found on Sparcs.
 - * Copyright (C) 2002 David S. Miller <davem@redhat.com>
 + * Copyright (C) 2002, 2008 David S. Miller <davem@davemloft.net>
   *
   * Based entirely upon drivers/sbus/audio/cs4231.c which is:
   * Copyright (C) 1996, 1997, 1998 Derrick J Brashear (shadow@andrew.cmu.edu)
@@@ -17,8 -17,7 +17,8 @@@
  #include <linux/moduleparam.h>
  #include <linux/irq.h>
  #include <linux/io.h>
 -
 +#include <linux/of.h>
 +#include <linux/of_device.h>
  
  #include <sound/core.h>
  #include <sound/pcm.h>
  
  #ifdef CONFIG_SBUS
  #define SBUS_SUPPORT
 -#include <asm/sbus.h>
  #endif
  
  #if defined(CONFIG_PCI) && defined(CONFIG_SPARC64)
  #define EBUS_SUPPORT
  #include <linux/pci.h>
 -#include <asm/ebus.h>
 +#include <asm/ebus_dma.h>
  #endif
  
  static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;    /* Index 0-MAX */
@@@ -70,6 -70,8 +70,6 @@@ struct cs4231_dma_control 
        int             (*request)(struct cs4231_dma_control *dma_cont,
                                   dma_addr_t bus_addr, size_t len);
        unsigned int    (*address)(struct cs4231_dma_control *dma_cont);
 -      void            (*preallocate)(struct snd_cs4231 *chip,
 -                                     struct snd_pcm *pcm);
  #ifdef EBUS_SUPPORT
        struct          ebus_dma_info   ebus_info;
  #endif
@@@ -112,12 -114,21 +112,12 @@@ struct snd_cs4231 
        struct mutex            mce_mutex;      /* mutex for mce register */
        struct mutex            open_mutex;     /* mutex for ALSA open/close */
  
 -      union {
 -#ifdef SBUS_SUPPORT
 -              struct sbus_dev         *sdev;
 -#endif
 -#ifdef EBUS_SUPPORT
 -              struct pci_dev          *pdev;
 -#endif
 -      } dev_u;
 +      struct of_device        *op;
        unsigned int            irq[2];
        unsigned int            regs_size;
        struct snd_cs4231       *next;
  };
  
 -static struct snd_cs4231 *cs4231_list;
 -
  /* Eventually we can use sound/isa/cs423x/cs4231_lib.c directly, but for
   * now....  -DaveM
   */
@@@ -256,19 -267,27 +256,19 @@@ static unsigned char snd_cs4231_origina
  
  static u8 __cs4231_readb(struct snd_cs4231 *cp, void __iomem *reg_addr)
  {
        if (cp->flags & CS4231_FLAG_EBUS)
                return readb(reg_addr);
        else
 -#endif
 -#ifdef SBUS_SUPPORT
                return sbus_readb(reg_addr);
 -#endif
  }
  
  static void __cs4231_writeb(struct snd_cs4231 *cp, u8 val,
                            void __iomem *reg_addr)
  {
        if (cp->flags & CS4231_FLAG_EBUS)
                return writeb(val, reg_addr);
        else
 -#endif
 -#ifdef SBUS_SUPPORT
                return sbus_writeb(val, reg_addr);
 -#endif
  }
  
  /*
@@@ -1239,9 -1258,7 +1239,9 @@@ static int __init snd_cs4231_pcm(struc
        pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
        strcpy(pcm->name, "CS4231");
  
 -      chip->p_dma.preallocate(chip, pcm);
 +      snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
 +                                            &chip->op->dev,
 +                                            64 * 1024, 128 * 1024);
  
        chip->pcm = pcm;
  
@@@ -1543,7 -1560,8 +1543,8 @@@ static int __init snd_cs4231_mixer(stru
        struct snd_cs4231 *chip = card->private_data;
        int err, idx;
  
-       snd_assert(chip != NULL && chip->pcm != NULL, return -EINVAL);
+       if (snd_BUG_ON(!chip || !chip->pcm))
+               return -EINVAL;
  
        strcpy(card->mixername, chip->pcm->name);
  
@@@ -1609,7 -1627,8 +1610,7 @@@ static int __init cs4231_attach_finish(
        if (err < 0)
                goto out_err;
  
 -      chip->next = cs4231_list;
 -      cs4231_list = chip;
 +      dev_set_drvdata(&chip->op->dev, chip);
  
        dev++;
        return 0;
@@@ -1764,19 -1783,24 +1765,19 @@@ static unsigned int sbus_dma_addr(struc
        return sbus_readl(base->regs + base->dir + APCVA);
  }
  
 -static void sbus_dma_preallocate(struct snd_cs4231 *chip, struct snd_pcm *pcm)
 -{
 -      snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_SBUS,
 -                                      snd_dma_sbus_data(chip->dev_u.sdev),
 -                                      64 * 1024, 128 * 1024);
 -}
 -
  /*
   * Init and exit routines
   */
  
  static int snd_cs4231_sbus_free(struct snd_cs4231 *chip)
  {
 +      struct of_device *op = chip->op;
 +
        if (chip->irq[0])
                free_irq(chip->irq[0], chip);
  
        if (chip->port)
 -              sbus_iounmap(chip->port, chip->regs_size);
 +              of_iounmap(&op->resource[0], chip->port, chip->regs_size);
  
        return 0;
  }
@@@ -1793,7 -1817,7 +1794,7 @@@ static struct snd_device_ops snd_cs4231
  };
  
  static int __init snd_cs4231_sbus_create(struct snd_card *card,
 -                                       struct sbus_dev *sdev,
 +                                       struct of_device *op,
                                         int dev)
  {
        struct snd_cs4231 *chip = card->private_data;
        spin_lock_init(&chip->p_dma.sbus_info.lock);
        mutex_init(&chip->mce_mutex);
        mutex_init(&chip->open_mutex);
 -      chip->dev_u.sdev = sdev;
 -      chip->regs_size = sdev->reg_addrs[0].reg_size;
 +      chip->op = op;
 +      chip->regs_size = resource_size(&op->resource[0]);
        memcpy(&chip->image, &snd_cs4231_original_image,
               sizeof(snd_cs4231_original_image));
  
 -      chip->port = sbus_ioremap(&sdev->resource[0], 0,
 -                                chip->regs_size, "cs4231");
 +      chip->port = of_ioremap(&op->resource[0], 0,
 +                              chip->regs_size, "cs4231");
        if (!chip->port) {
                snd_printdd("cs4231-%d: Unable to map chip registers.\n", dev);
                return -EIO;
        chip->p_dma.enable = sbus_dma_enable;
        chip->p_dma.request = sbus_dma_request;
        chip->p_dma.address = sbus_dma_addr;
 -      chip->p_dma.preallocate = sbus_dma_preallocate;
  
        chip->c_dma.prepare = sbus_dma_prepare;
        chip->c_dma.enable = sbus_dma_enable;
        chip->c_dma.request = sbus_dma_request;
        chip->c_dma.address = sbus_dma_addr;
 -      chip->c_dma.preallocate = sbus_dma_preallocate;
  
 -      if (request_irq(sdev->irqs[0], snd_cs4231_sbus_interrupt,
 +      if (request_irq(op->irqs[0], snd_cs4231_sbus_interrupt,
                        IRQF_SHARED, "cs4231", chip)) {
                snd_printdd("cs4231-%d: Unable to grab SBUS IRQ %d\n",
 -                          dev, sdev->irqs[0]);
 +                          dev, op->irqs[0]);
                snd_cs4231_sbus_free(chip);
                return -EBUSY;
        }
 -      chip->irq[0] = sdev->irqs[0];
 +      chip->irq[0] = op->irqs[0];
  
        if (snd_cs4231_probe(chip) < 0) {
                snd_cs4231_sbus_free(chip);
        return 0;
  }
  
 -static int __init cs4231_sbus_attach(struct sbus_dev *sdev)
 +static int __devinit cs4231_sbus_probe(struct of_device *op, const struct of_device_id *match)
  {
 -      struct resource *rp = &sdev->resource[0];
 +      struct resource *rp = &op->resource[0];
        struct snd_card *card;
        int err;
  
                card->shortname,
                rp->flags & 0xffL,
                (unsigned long long)rp->start,
 -              sdev->irqs[0]);
 +              op->irqs[0]);
  
 -      err = snd_cs4231_sbus_create(card, sdev, dev);
 +      err = snd_cs4231_sbus_create(card, op, dev);
        if (err < 0) {
                snd_card_free(card);
                return err;
@@@ -1924,25 -1950,30 +1925,25 @@@ static unsigned int _ebus_dma_addr(stru
        return ebus_dma_addr(&dma_cont->ebus_info);
  }
  
 -static void _ebus_dma_preallocate(struct snd_cs4231 *chip, struct snd_pcm *pcm)
 -{
 -      snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
 -                                    snd_dma_pci_data(chip->dev_u.pdev),
 -                                    64*1024, 128*1024);
 -}
 -
  /*
   * Init and exit routines
   */
  
  static int snd_cs4231_ebus_free(struct snd_cs4231 *chip)
  {
 +      struct of_device *op = chip->op;
 +
        if (chip->c_dma.ebus_info.regs) {
                ebus_dma_unregister(&chip->c_dma.ebus_info);
 -              iounmap(chip->c_dma.ebus_info.regs);
 +              of_iounmap(&op->resource[2], chip->c_dma.ebus_info.regs, 0x10);
        }
        if (chip->p_dma.ebus_info.regs) {
                ebus_dma_unregister(&chip->p_dma.ebus_info);
 -              iounmap(chip->p_dma.ebus_info.regs);
 +              of_iounmap(&op->resource[1], chip->p_dma.ebus_info.regs, 0x10);
        }
  
        if (chip->port)
 -              iounmap(chip->port);
 +              of_iounmap(&op->resource[0], chip->port, 0x10);
  
        return 0;
  }
@@@ -1959,7 -1990,7 +1960,7 @@@ static struct snd_device_ops snd_cs4231
  };
  
  static int __init snd_cs4231_ebus_create(struct snd_card *card,
 -                                       struct linux_ebus_device *edev,
 +                                       struct of_device *op,
                                         int dev)
  {
        struct snd_cs4231 *chip = card->private_data;
        mutex_init(&chip->mce_mutex);
        mutex_init(&chip->open_mutex);
        chip->flags |= CS4231_FLAG_EBUS;
 -      chip->dev_u.pdev = edev->bus->self;
 +      chip->op = op;
        memcpy(&chip->image, &snd_cs4231_original_image,
               sizeof(snd_cs4231_original_image));
        strcpy(chip->c_dma.ebus_info.name, "cs4231(capture)");
        chip->c_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER;
        chip->c_dma.ebus_info.callback = snd_cs4231_ebus_capture_callback;
        chip->c_dma.ebus_info.client_cookie = chip;
 -      chip->c_dma.ebus_info.irq = edev->irqs[0];
 +      chip->c_dma.ebus_info.irq = op->irqs[0];
        strcpy(chip->p_dma.ebus_info.name, "cs4231(play)");
        chip->p_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER;
        chip->p_dma.ebus_info.callback = snd_cs4231_ebus_play_callback;
        chip->p_dma.ebus_info.client_cookie = chip;
 -      chip->p_dma.ebus_info.irq = edev->irqs[1];
 +      chip->p_dma.ebus_info.irq = op->irqs[1];
  
        chip->p_dma.prepare = _ebus_dma_prepare;
        chip->p_dma.enable = _ebus_dma_enable;
        chip->p_dma.request = _ebus_dma_request;
        chip->p_dma.address = _ebus_dma_addr;
 -      chip->p_dma.preallocate = _ebus_dma_preallocate;
  
        chip->c_dma.prepare = _ebus_dma_prepare;
        chip->c_dma.enable = _ebus_dma_enable;
        chip->c_dma.request = _ebus_dma_request;
        chip->c_dma.address = _ebus_dma_addr;
 -      chip->c_dma.preallocate = _ebus_dma_preallocate;
  
 -      chip->port = ioremap(edev->resource[0].start, 0x10);
 -      chip->p_dma.ebus_info.regs = ioremap(edev->resource[1].start, 0x10);
 -      chip->c_dma.ebus_info.regs = ioremap(edev->resource[2].start, 0x10);
 +      chip->port = of_ioremap(&op->resource[0], 0, 0x10, "cs4231");
 +      chip->p_dma.ebus_info.regs =
 +              of_ioremap(&op->resource[1], 0, 0x10, "cs4231_pdma");
 +      chip->c_dma.ebus_info.regs =
 +              of_ioremap(&op->resource[2], 0, 0x10, "cs4231_cdma");
        if (!chip->port || !chip->p_dma.ebus_info.regs ||
            !chip->c_dma.ebus_info.regs) {
                snd_cs4231_ebus_free(chip);
        return 0;
  }
  
 -static int __init cs4231_ebus_attach(struct linux_ebus_device *edev)
 +static int __devinit cs4231_ebus_probe(struct of_device *op, const struct of_device_id *match)
  {
        struct snd_card *card;
        int err;
  
        sprintf(card->longname, "%s at 0x%lx, irq %d",
                card->shortname,
 -              edev->resource[0].start,
 -              edev->irqs[0]);
 +              op->resource[0].start,
 +              op->irqs[0]);
  
 -      err = snd_cs4231_ebus_create(card, edev, dev);
 +      err = snd_cs4231_ebus_create(card, op, dev);
        if (err < 0) {
                snd_card_free(card);
                return err;
  }
  #endif
  
 -static int __init cs4231_init(void)
 +static int __devinit cs4231_probe(struct of_device *op, const struct of_device_id *match)
  {
 -#ifdef SBUS_SUPPORT
 -      struct sbus_bus *sbus;
 -      struct sbus_dev *sdev;
 -#endif
  #ifdef EBUS_SUPPORT
 -      struct linux_ebus *ebus;
 -      struct linux_ebus_device *edev;
 +      if (!strcmp(op->node->parent->name, "ebus"))
 +              return cs4231_ebus_probe(op, match);
  #endif
 -      int found;
 -
 -      found = 0;
 -
  #ifdef SBUS_SUPPORT
 -      for_all_sbusdev(sdev, sbus) {
 -              if (!strcmp(sdev->prom_name, "SUNW,CS4231")) {
 -                      if (cs4231_sbus_attach(sdev) == 0)
 -                              found++;
 -              }
 -      }
 +      if (!strcmp(op->node->parent->name, "sbus") ||
 +          !strcmp(op->node->parent->name, "sbi"))
 +              return cs4231_sbus_probe(op, match);
  #endif
 -#ifdef EBUS_SUPPORT
 -      for_each_ebus(ebus) {
 -              for_each_ebusdev(edev, ebus) {
 -                      int match = 0;
 -
 -                      if (!strcmp(edev->prom_node->name, "SUNW,CS4231")) {
 -                              match = 1;
 -                      } else if (!strcmp(edev->prom_node->name, "audio")) {
 -                              const char *compat;
 -
 -                              compat = of_get_property(edev->prom_node,
 -                                                       "compatible", NULL);
 -                              if (compat && !strcmp(compat, "SUNW,CS4231"))
 -                                      match = 1;
 -                      }
 +      return -ENODEV;
 +}
  
 -                      if (match &&
 -                          cs4231_ebus_attach(edev) == 0)
 -                              found++;
 -              }
 -      }
 -#endif
 +static int __devexit cs4231_remove(struct of_device *op)
 +{
 +      struct snd_cs4231 *chip = dev_get_drvdata(&op->dev);
  
 +      snd_card_free(chip->card);
  
 -      return (found > 0) ? 0 : -EIO;
 +      return 0;
  }
  
 -static void __exit cs4231_exit(void)
 -{
 -      struct snd_cs4231 *p = cs4231_list;
 +static const struct of_device_id cs4231_match[] = {
 +      {
 +              .name = "SUNW,CS4231",
 +      },
 +      {
 +              .name = "audio",
 +              .compatible = "SUNW,CS4231",
 +      },
 +      {},
 +};
  
 -      while (p != NULL) {
 -              struct snd_cs4231 *next = p->next;
 +MODULE_DEVICE_TABLE(of, cs4231_match);
  
 -              snd_card_free(p->card);
 +static struct of_platform_driver cs4231_driver = {
 +      .name           = "audio",
 +      .match_table    = cs4231_match,
 +      .probe          = cs4231_probe,
 +      .remove         = __devexit_p(cs4231_remove),
 +};
  
 -              p = next;
 -      }
 +static int __init cs4231_init(void)
 +{
 +      return of_register_driver(&cs4231_driver, &of_bus_type);
 +}
  
 -      cs4231_list = NULL;
 +static void __exit cs4231_exit(void)
 +{
 +      of_unregister_driver(&cs4231_driver);
  }
  
  module_init(cs4231_init);
diff --combined sound/sparc/dbri.c
@@@ -57,7 -57,6 +57,7 @@@
  #include <linux/delay.h>
  #include <linux/irq.h>
  #include <linux/io.h>
 +#include <linux/dma-mapping.h>
  
  #include <sound/core.h>
  #include <sound/pcm.h>
@@@ -67,7 -66,7 +67,7 @@@
  #include <sound/initval.h>
  
  #include <linux/of.h>
 -#include <asm/sbus.h>
 +#include <linux/of_device.h>
  #include <asm/atomic.h>
  
  MODULE_AUTHOR("Rudolf Koenig, Brent Baccala and Martin Habets");
@@@ -298,7 -297,7 +298,7 @@@ struct dbri_streaminfo 
  /* This structure holds the information for both chips (DBRI & CS4215) */
  struct snd_dbri {
        int regs_size, irq;     /* Needed for unload */
 -      struct sbus_dev *sdev;  /* SBUS device info */
 +      struct of_device *op;   /* OF device info */
        spinlock_t lock;
  
        struct dbri_dma *dma;   /* Pointer to our DMA block */
@@@ -2094,15 -2093,14 +2094,15 @@@ static int snd_dbri_hw_params(struct sn
         */
        if (info->dvma_buffer == 0) {
                if (DBRI_STREAMNO(substream) == DBRI_PLAY)
 -                      direction = SBUS_DMA_TODEVICE;
 +                      direction = DMA_TO_DEVICE;
                else
 -                      direction = SBUS_DMA_FROMDEVICE;
 +                      direction = DMA_FROM_DEVICE;
  
 -              info->dvma_buffer = sbus_map_single(dbri->sdev,
 -                                      runtime->dma_area,
 -                                      params_buffer_bytes(hw_params),
 -                                      direction);
 +              info->dvma_buffer =
 +                      dma_map_single(&dbri->op->dev,
 +                                     runtime->dma_area,
 +                                     params_buffer_bytes(hw_params),
 +                                     direction);
        }
  
        direction = params_buffer_bytes(hw_params);
@@@ -2123,12 -2121,12 +2123,12 @@@ static int snd_dbri_hw_free(struct snd_
         */
        if (info->dvma_buffer) {
                if (DBRI_STREAMNO(substream) == DBRI_PLAY)
 -                      direction = SBUS_DMA_TODEVICE;
 +                      direction = DMA_TO_DEVICE;
                else
 -                      direction = SBUS_DMA_FROMDEVICE;
 +                      direction = DMA_FROM_DEVICE;
  
 -              sbus_unmap_single(dbri->sdev, info->dvma_buffer,
 -                                substream->runtime->buffer_size, direction);
 +              dma_unmap_single(&dbri->op->dev, info->dvma_buffer,
 +                               substream->runtime->buffer_size, direction);
                info->dvma_buffer = 0;
        }
        if (info->pipe != -1) {
@@@ -2225,7 -2223,6 +2225,6 @@@ static int __devinit snd_dbri_pcm(struc
                               /* playback count */ 1,
                               /* capture count */  1, &pcm)) < 0)
                return err;
-       snd_assert(pcm != NULL, return -EINVAL);
  
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_dbri_ops);
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_dbri_ops);
@@@ -2265,9 -2262,10 +2264,10 @@@ static int snd_cs4215_get_volume(struc
  {
        struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol);
        struct dbri_streaminfo *info;
-       snd_assert(dbri != NULL, return -EINVAL);
+       if (snd_BUG_ON(!dbri))
+               return -EINVAL;
        info = &dbri->stream_info[kcontrol->private_value];
-       snd_assert(info != NULL, return -EINVAL);
  
        ucontrol->value.integer.value[0] = info->left_gain;
        ucontrol->value.integer.value[1] = info->right_gain;
@@@ -2333,7 -2331,9 +2333,9 @@@ static int snd_cs4215_get_single(struc
        int shift = (kcontrol->private_value >> 8) & 0xff;
        int mask = (kcontrol->private_value >> 16) & 0xff;
        int invert = (kcontrol->private_value >> 24) & 1;
-       snd_assert(dbri != NULL, return -EINVAL);
+       if (snd_BUG_ON(!dbri))
+               return -EINVAL;
  
        if (elem < 4)
                ucontrol->value.integer.value[0] =
@@@ -2358,7 -2358,9 +2360,9 @@@ static int snd_cs4215_put_single(struc
        int invert = (kcontrol->private_value >> 24) & 1;
        int changed = 0;
        unsigned short val;
-       snd_assert(dbri != NULL, return -EINVAL);
+       if (snd_BUG_ON(!dbri))
+               return -EINVAL;
  
        val = (ucontrol->value.integer.value[0] & mask);
        if (invert == 1)
@@@ -2434,7 -2436,8 +2438,8 @@@ static int __devinit snd_dbri_mixer(str
        int idx, err;
        struct snd_dbri *dbri;
  
-       snd_assert(card != NULL && card->private_data != NULL, return -EINVAL);
+       if (snd_BUG_ON(!card || !card->private_data))
+               return -EINVAL;
        dbri = card->private_data;
  
        strcpy(card->mixername, card->shortname);
@@@ -2516,32 -2519,31 +2521,32 @@@ static void __devinit snd_dbri_proc(str
  static void snd_dbri_free(struct snd_dbri *dbri);
  
  static int __devinit snd_dbri_create(struct snd_card *card,
 -                                struct sbus_dev *sdev,
 -                                int irq, int dev)
 +                                   struct of_device *op,
 +                                   int irq, int dev)
  {
        struct snd_dbri *dbri = card->private_data;
        int err;
  
        spin_lock_init(&dbri->lock);
 -      dbri->sdev = sdev;
 +      dbri->op = op;
        dbri->irq = irq;
  
 -      dbri->dma = sbus_alloc_consistent(sdev, sizeof(struct dbri_dma),
 -                                        &dbri->dma_dvma);
 +      dbri->dma = dma_alloc_coherent(&op->dev,
 +                                     sizeof(struct dbri_dma),
 +                                     &dbri->dma_dvma, GFP_ATOMIC);
        memset((void *)dbri->dma, 0, sizeof(struct dbri_dma));
  
        dprintk(D_GEN, "DMA Cmd Block 0x%p (0x%08x)\n",
                dbri->dma, dbri->dma_dvma);
  
        /* Map the registers into memory. */
 -      dbri->regs_size = sdev->reg_addrs[0].reg_size;
 -      dbri->regs = sbus_ioremap(&sdev->resource[0], 0,
 -                                dbri->regs_size, "DBRI Registers");
 +      dbri->regs_size = resource_size(&op->resource[0]);
 +      dbri->regs = of_ioremap(&op->resource[0], 0,
 +                              dbri->regs_size, "DBRI Registers");
        if (!dbri->regs) {
                printk(KERN_ERR "DBRI: could not allocate registers\n");
 -              sbus_free_consistent(sdev, sizeof(struct dbri_dma),
 -                                   (void *)dbri->dma, dbri->dma_dvma);
 +              dma_free_coherent(&op->dev, sizeof(struct dbri_dma),
 +                                (void *)dbri->dma, dbri->dma_dvma);
                return -EIO;
        }
  
                          "DBRI audio", dbri);
        if (err) {
                printk(KERN_ERR "DBRI: Can't get irq %d\n", dbri->irq);
 -              sbus_iounmap(dbri->regs, dbri->regs_size);
 -              sbus_free_consistent(sdev, sizeof(struct dbri_dma),
 -                                   (void *)dbri->dma, dbri->dma_dvma);
 +              of_iounmap(&op->resource[0], dbri->regs, dbri->regs_size);
 +              dma_free_coherent(&op->dev, sizeof(struct dbri_dma),
 +                                (void *)dbri->dma, dbri->dma_dvma);
                return err;
        }
  
@@@ -2575,23 -2577,27 +2580,23 @@@ static void snd_dbri_free(struct snd_db
                free_irq(dbri->irq, dbri);
  
        if (dbri->regs)
 -              sbus_iounmap(dbri->regs, dbri->regs_size);
 +              of_iounmap(&dbri->op->resource[0], dbri->regs, dbri->regs_size);
  
        if (dbri->dma)
 -              sbus_free_consistent(dbri->sdev, sizeof(struct dbri_dma),
 -                                   (void *)dbri->dma, dbri->dma_dvma);
 +              dma_free_coherent(&dbri->op->dev,
 +                                sizeof(struct dbri_dma),
 +                                (void *)dbri->dma, dbri->dma_dvma);
  }
  
 -static int __devinit dbri_probe(struct of_device *of_dev,
 -                              const struct of_device_id *match)
 +static int __devinit dbri_probe(struct of_device *op, const struct of_device_id *match)
  {
 -      struct sbus_dev *sdev = to_sbus_device(&of_dev->dev);
        struct snd_dbri *dbri;
        struct resource *rp;
        struct snd_card *card;
        static int dev = 0;
 +      int irq;
        int err;
  
 -      dprintk(D_GEN, "DBRI: Found %s in SBUS slot %d\n",
 -              sdev->prom_name, sdev->slot);
 -
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
        if (!enable[dev]) {
                return -ENOENT;
        }
  
 -      irq = sdev->irqs[0];
 +      irq = op->irqs[0];
        if (irq <= 0) {
                printk(KERN_ERR "DBRI-%d: No IRQ.\n", dev);
                return -ENODEV;
  
        strcpy(card->driver, "DBRI");
        strcpy(card->shortname, "Sun DBRI");
 -      rp = &sdev->resource[0];
 +      rp = &op->resource[0];
        sprintf(card->longname, "%s at 0x%02lx:0x%016Lx, irq %d",
                card->shortname,
                rp->flags & 0xffL, (unsigned long long)rp->start, irq);
  
 -      err = snd_dbri_create(card, sdev, irq, dev);
 +      err = snd_dbri_create(card, op, irq, dev);
        if (err < 0) {
                snd_card_free(card);
                return err;
  
        /* /proc file handling */
        snd_dbri_proc(card);
 -      dev_set_drvdata(&of_dev->dev, card);
 +      dev_set_drvdata(&op->dev, card);
  
        err = snd_card_register(card);
        if (err < 0)
  
        printk(KERN_INFO "audio%d at %p (irq %d) is DBRI(%c)+CS4215(%d)\n",
               dev, dbri->regs,
 -             dbri->irq, sdev->prom_name[9], dbri->mm.version);
 +             dbri->irq, op->node->name[9], dbri->mm.version);
        dev++;
  
        return 0;
@@@ -2653,19 -2659,19 +2658,19 @@@ _err
        return err;
  }
  
 -static int __devexit dbri_remove(struct of_device *dev)
 +static int __devexit dbri_remove(struct of_device *op)
  {
 -      struct snd_card *card = dev_get_drvdata(&dev->dev);
 +      struct snd_card *card = dev_get_drvdata(&op->dev);
  
        snd_dbri_free(card->private_data);
        snd_card_free(card);
  
 -      dev_set_drvdata(&dev->dev, NULL);
 +      dev_set_drvdata(&op->dev, NULL);
  
        return 0;
  }
  
 -static struct of_device_id dbri_match[] = {
 +static const struct of_device_id dbri_match[] = {
        {
                .name = "SUNW,DBRIe",
        },
@@@ -2687,7 -2693,7 +2692,7 @@@ static struct of_platform_driver dbri_s
  /* Probe for the dbri chip and then attach the driver. */
  static int __init dbri_init(void)
  {
 -      return of_register_driver(&dbri_sbus_driver, &sbus_bus_type);
 +      return of_register_driver(&dbri_sbus_driver, &of_bus_type);
  }
  
  static void __exit dbri_exit(void)