Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[sfrench/cifs-2.6.git] / sound / ppc / pmac.c
index 641430631505057f478f126fc7c91270e6fc921e..7a22f0f3784ab5e1f1c90401bdd8281d795cd2a5 100644 (file)
@@ -713,7 +713,7 @@ void snd_pmac_beep_dma_stop(struct snd_pmac *chip)
  * interrupt handlers
  */
 static irqreturn_t
-snd_pmac_tx_intr(int irq, void *devid, struct pt_regs *regs)
+snd_pmac_tx_intr(int irq, void *devid)
 {
        struct snd_pmac *chip = devid;
        snd_pmac_pcm_update(chip, &chip->playback);
@@ -722,7 +722,7 @@ snd_pmac_tx_intr(int irq, void *devid, struct pt_regs *regs)
 
 
 static irqreturn_t
-snd_pmac_rx_intr(int irq, void *devid, struct pt_regs *regs)
+snd_pmac_rx_intr(int irq, void *devid)
 {
        struct snd_pmac *chip = devid;
        snd_pmac_pcm_update(chip, &chip->capture);
@@ -731,7 +731,7 @@ snd_pmac_rx_intr(int irq, void *devid, struct pt_regs *regs)
 
 
 static irqreturn_t
-snd_pmac_ctrl_intr(int irq, void *devid, struct pt_regs *regs)
+snd_pmac_ctrl_intr(int irq, void *devid)
 {
        struct snd_pmac *chip = devid;
        int ctrl = in_le32(&chip->awacs->control);
@@ -775,7 +775,8 @@ static int snd_pmac_free(struct snd_pmac *chip)
                out_le32(&chip->awacs->control, in_le32(&chip->awacs->control) & 0xfff);
        }
 
-       snd_pmac_sound_feature(chip, 0);
+       if (chip->node)
+               snd_pmac_sound_feature(chip, 0);
 
        /* clean up mixer if any */
        if (chip->mixer_free)
@@ -816,6 +817,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
 
        if (chip->pdev)
                pci_dev_put(chip->pdev);
+       of_node_put(chip->node);
        kfree(chip);
        return 0;
 }
@@ -842,7 +844,7 @@ static void __init detect_byte_swap(struct snd_pmac *chip)
        /* if seems that Keylargo can't byte-swap  */
        for (mio = chip->node->parent; mio; mio = mio->parent) {
                if (strcmp(mio->name, "mac-io") == 0) {
-                       if (device_is_compatible(mio, "Keylargo"))
+                       if (of_device_is_compatible(mio, "Keylargo"))
                                chip->can_byte_swap = 0;
                        break;
                }
@@ -863,8 +865,10 @@ static void __init detect_byte_swap(struct snd_pmac *chip)
  */
 static int __init snd_pmac_detect(struct snd_pmac *chip)
 {
-       struct device_node *sound = NULL;
-       unsigned int *prop, l;
+       struct device_node *sound;
+       struct device_node *dn;
+       const unsigned int *prop;
+       unsigned int l;
        struct macio_chip* macio;
 
        if (!machine_is(powermac))
@@ -890,25 +894,24 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
        else if (machine_is_compatible("PowerBook1,1")
                 || machine_is_compatible("AAPL,PowerBook1998"))
                chip->is_pbook_G3 = 1;
-       chip->node = find_devices("awacs");
-       if (chip->node)
-               sound = chip->node;
+       chip->node = of_find_node_by_name(NULL, "awacs");
+       sound = of_node_get(chip->node);
 
        /*
         * powermac G3 models have a node called "davbus"
         * with a child called "sound".
         */
        if (!chip->node)
-               chip->node = find_devices("davbus");
+               chip->node = of_find_node_by_name(NULL, "davbus");
        /*
         * if we didn't find a davbus device, try 'i2s-a' since
         * this seems to be what iBooks have
         */
        if (! chip->node) {
-               chip->node = find_devices("i2s-a");
+               chip->node = of_find_node_by_name(NULL, "i2s-a");
                if (chip->node && chip->node->parent &&
                    chip->node->parent->parent) {
-                       if (device_is_compatible(chip->node->parent->parent,
+                       if (of_device_is_compatible(chip->node->parent->parent,
                                                 "K2-Keylargo"))
                                chip->is_k2 = 1;
                }
@@ -917,41 +920,47 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
                return -ENODEV;
 
        if (!sound) {
-               sound = find_devices("sound");
+               sound = of_find_node_by_name(NULL, "sound");
                while (sound && sound->parent != chip->node)
-                       sound = sound->next;
+                       sound = of_find_node_by_name(sound, "sound");
        }
-       if (! sound)
+       if (! sound) {
+               of_node_put(chip->node);
+               chip->node = NULL;
                return -ENODEV;
-       prop = (unsigned int *) get_property(sound, "sub-frame", NULL);
+       }
+       prop = of_get_property(sound, "sub-frame", NULL);
        if (prop && *prop < 16)
                chip->subframe = *prop;
-       prop = (unsigned int *) get_property(sound, "layout-id", NULL);
+       prop = of_get_property(sound, "layout-id", NULL);
        if (prop) {
                /* partly deprecate snd-powermac, for those machines
                 * that have a layout-id property for now */
                printk(KERN_INFO "snd-powermac no longer handles any "
                                 "machines with a layout-id property "
                                 "in the device-tree, use snd-aoa.\n");
+               of_node_put(sound);
+               of_node_put(chip->node);
+               chip->node = NULL;
                return -ENODEV;
        }
        /* This should be verified on older screamers */
-       if (device_is_compatible(sound, "screamer")) {
+       if (of_device_is_compatible(sound, "screamer")) {
                chip->model = PMAC_SCREAMER;
                // chip->can_byte_swap = 0; /* FIXME: check this */
        }
-       if (device_is_compatible(sound, "burgundy")) {
+       if (of_device_is_compatible(sound, "burgundy")) {
                chip->model = PMAC_BURGUNDY;
                chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */
        }
-       if (device_is_compatible(sound, "daca")) {
+       if (of_device_is_compatible(sound, "daca")) {
                chip->model = PMAC_DACA;
                chip->can_capture = 0;  /* no capture */
                chip->can_duplex = 0;
                // chip->can_byte_swap = 0; /* FIXME: check this */
                chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */
        }
-       if (device_is_compatible(sound, "tumbler")) {
+       if (of_device_is_compatible(sound, "tumbler")) {
                chip->model = PMAC_TUMBLER;
                chip->can_capture = 0;  /* no capture */
                chip->can_duplex = 0;
@@ -960,17 +969,19 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
                chip->freq_table = tumbler_freqs;
                chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */
        }
-       if (device_is_compatible(sound, "snapper")) {
+       if (of_device_is_compatible(sound, "snapper")) {
                chip->model = PMAC_SNAPPER;
                // chip->can_byte_swap = 0; /* FIXME: check this */
                chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
                chip->freq_table = tumbler_freqs;
                chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */
        }
-       prop = (unsigned int *)get_property(sound, "device-id", NULL);
+       prop = of_get_property(sound, "device-id", NULL);
        if (prop)
                chip->device_id = *prop;
-       chip->has_iic = (find_devices("perch") != NULL);
+       dn = of_find_node_by_name(NULL, "perch");
+       chip->has_iic = (dn != NULL);
+       of_node_put(dn);
 
        /* We need the PCI device for DMA allocations, let's use a crude method
         * for now ...
@@ -997,10 +1008,9 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
 
        /* look for a property saying what sample rates
           are available */
-       prop = (unsigned int *) get_property(sound, "sample-rates", &l);
+       prop = of_get_property(sound, "sample-rates", &l);
        if (! prop)
-               prop = (unsigned int *) get_property(sound,
-                                                    "output-frame-rates", &l);
+               prop = of_get_property(sound, "output-frame-rates", &l);
        if (prop) {
                int i;
                chip->freqs_ok = 0;
@@ -1021,6 +1031,7 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
                chip->freqs_ok = 1;
        }
 
+       of_node_put(sound);
        return 0;
 }
 
@@ -1290,8 +1301,6 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
        return 0;
 
  __error:
-       if (chip->pdev)
-               pci_dev_put(chip->pdev);
        snd_pmac_free(chip);
        return err;
 }