]> err.no Git - linux-2.6/blobdiff - sound/ppc/pmac.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/lethal/sh-2.6
[linux-2.6] / sound / ppc / pmac.c
index 5e829683d1ad7d4f686ef284b56590f6f8f7a1ff..7a22f0f3784ab5e1f1c90401bdd8281d795cd2a5 100644 (file)
@@ -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,7 +865,8 @@ 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;
+       struct device_node *sound;
+       struct device_node *dn;
        const unsigned int *prop;
        unsigned int l;
        struct macio_chip* macio;
@@ -891,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;
                }
@@ -918,12 +920,15 @@ 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 = of_get_property(sound, "sub-frame", NULL);
        if (prop && *prop < 16)
                chip->subframe = *prop;
@@ -934,25 +939,28 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
                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;
@@ -961,7 +969,7 @@ 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);
@@ -971,7 +979,9 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
        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 ...
@@ -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;
 }