]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - sound/oss/dmasound/dmasound_awacs.c
[POWERPC] Rename device_is_compatible to of_device_is_compatible
[karo-tx-linux.git] / sound / oss / dmasound / dmasound_awacs.c
index 9ae659f82430384c9c57bacf7131c2708da6cf6e..8f6388004f44d9af58e2be80e2e15ea2f036ea89 100644 (file)
@@ -257,7 +257,7 @@ static volatile struct dbdma_cmd *emergency_dbdma_cmd;
 /*
  * Stuff for restoring after a sleep.
  */
-static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when);
+static void awacs_sleep_notify(struct pmu_sleep_notifier *self, int when);
 struct pmu_sleep_notifier awacs_sleep_notifier = {
        awacs_sleep_notify, SLEEP_LEVEL_SOUND,
 };
@@ -281,9 +281,9 @@ static int PMacSetFormat(int format);
 static int PMacSetVolume(int volume);
 static void PMacPlay(void);
 static void PMacRecord(void);
-static irqreturn_t pmac_awacs_tx_intr(int irq, void *devid, struct pt_regs *regs);
-static irqreturn_t pmac_awacs_rx_intr(int irq, void *devid, struct pt_regs *regs);
-static irqreturn_t pmac_awacs_intr(int irq, void *devid, struct pt_regs *regs);
+static irqreturn_t pmac_awacs_tx_intr(int irq, void *devid);
+static irqreturn_t pmac_awacs_rx_intr(int irq, void *devid);
+static irqreturn_t pmac_awacs_intr(int irq, void *devid);
 static void awacs_write(int val);
 static int awacs_get_volume(int reg, int lshift);
 static int awacs_volume_setter(int volume, int n, int mute, int lshift);
@@ -346,36 +346,42 @@ int gpio_headphone_irq;
 int
 setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int* gpio_pol)
 {
+       struct device_node *gpiop;
        struct device_node *np;
        const u32* pp;
+       int ret = -ENODEV;
 
-       np = find_devices("gpio");
-       if (!np)
-               return -ENODEV;
+       gpiop = of_find_node_by_name(NULL, "gpio");
+       if (!gpiop)
+               goto done;
 
-       np = np->child;
+       np = of_get_next_child(gpiop, NULL);
        while(np != 0) {
                if (name) {
                        const char *property =
-                               get_property(np,"audio-gpio",NULL);
+                               of_get_property(np,"audio-gpio",NULL);
                        if (property != 0 && strcmp(property,name) == 0)
                                break;
-               } else if (compatible && device_is_compatible(np, compatible))
+               } else if (compatible && of_device_is_compatible(np, compatible))
                        break;
-               np = np->sibling;
+               np = of_get_next_child(gpiop, np);
        }
        if (!np)
-               return -ENODEV;
-       pp = get_property(np, "AAPL,address", NULL);
+               goto done;
+       pp = of_get_property(np, "AAPL,address", NULL);
        if (!pp)
-               return -ENODEV;
+               goto done;
        *gpio_addr = (*pp) & 0x0000ffff;
-       pp = get_property(np, "audio-gpio-active-state", NULL);
+       pp = of_get_property(np, "audio-gpio-active-state", NULL);
        if (pp)
                *gpio_pol = *pp;
        else
                *gpio_pol = 1;
-       return irq_of_parse_and_map(np, 0);
+       ret = irq_of_parse_and_map(np, 0);
+done:
+       of_node_put(np);
+       of_node_put(gpiop);
+       return ret;
 }
 
 static inline void
@@ -398,7 +404,7 @@ read_audio_gpio(int gpio_addr)
  * Headphone interrupt via GPIO (Tumbler, Snapper, DACA)
  */
 static irqreturn_t
-headphone_intr(int irq, void *devid, struct pt_regs *regs)
+headphone_intr(int irq, void *devid)
 {
        unsigned long flags;
 
@@ -465,7 +471,7 @@ tas_dmasound_init(void)
                        val = pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, gpio_headphone_detect, 0);
                        pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, gpio_headphone_detect, val | 0x80);
                        /* Trigger it */
-                       headphone_intr(0,NULL,NULL);
+                       headphone_intr(0, NULL);
                }
        }
        if (!gpio_headphone_irq) {
@@ -578,7 +584,7 @@ tas_mixer_ioctl(u_int cmd, u_long arg)
 }
 
 static void __init
-tas_init_frame_rates(unsigned int *prop, unsigned int l)
+tas_init_frame_rates(const unsigned int *prop, unsigned int l)
 {
        int i ;
        if (prop) {
@@ -1037,7 +1043,7 @@ static void PMacRecord(void)
 */
 
 static irqreturn_t
-pmac_awacs_tx_intr(int irq, void *devid, struct pt_regs *regs)
+pmac_awacs_tx_intr(int irq, void *devid)
 {
        int i = write_sq.front;
        int stat;
@@ -1129,7 +1135,7 @@ printk("dmasound_pmac: tx-irq: xfer died - patching it up...\n") ;
 
 
 static irqreturn_t
-pmac_awacs_rx_intr(int irq, void *devid, struct pt_regs *regs)
+pmac_awacs_rx_intr(int irq, void *devid)
 {
        int stat ;
        /* For some reason on my PowerBook G3, I get one interrupt
@@ -1212,7 +1218,7 @@ printk("dmasound_pmac: rx-irq: DIED - attempting resurection\n");
 
 
 static irqreturn_t
-pmac_awacs_intr(int irq, void *devid, struct pt_regs *regs)
+pmac_awacs_intr(int irq, void *devid)
 {
        int ctrl;
        int status;
@@ -1419,7 +1425,7 @@ load_awacs(void)
  * Save state when going to sleep, restore it afterwards.
  */
 /* FIXME: sort out disabling/re-enabling of read stuff as well */
-static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when)
+static void awacs_sleep_notify(struct pmu_sleep_notifier *self, int when)
 {
        unsigned long flags;
 
@@ -1499,7 +1505,7 @@ static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when)
                                write_audio_gpio(gpio_audio_reset, !gpio_audio_reset_pol);
                                msleep(150);
                                tas_leave_sleep(); /* Stub for now */
-                               headphone_intr(0,NULL,NULL);
+                               headphone_intr(0, NULL);
                                break;
                        case AWACS_DACA:
                                msleep(10); /* Check this !!! */
@@ -1548,7 +1554,6 @@ static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when)
                spin_unlock_irqrestore(&dmasound.lock, flags);
                UNLOCK();
        }
-       return PBOOK_SLEEP_OK;
 }
 #endif /* CONFIG_PM */
 
@@ -2553,32 +2558,33 @@ set_model(void)
 static struct device_node* __init
 get_snd_io_node(void)
 {
-       struct device_node *np = NULL;
+       struct device_node *np;
 
        /* set up awacs_node for early OF which doesn't have a full set of
         * properties on davbus
-       */
-
-       awacs_node = find_devices("awacs");
+        */
+       awacs_node = of_find_node_by_name(NULL, "awacs");
        if (awacs_node)
                awacs_revision = AWACS_AWACS;
 
        /* powermac models after 9500 (other than those which use DACA or
         * Tumbler) have a node called "davbus".
         */
-       np = find_devices("davbus");
+       np = 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 (& Tumbler) have.
         */
-       if (np == NULL)
-               np = i2s_node = find_devices("i2s-a");
+       if (np == NULL) {
+               i2s_node = of_find_node_by_name(NULL, "i2s-a");
+               np = of_node_get(i2s_node);
+       }
 
        /* if we didn't find this - perhaps we are on an early model
         * which _only_ has an 'awacs' node
        */
        if (np == NULL && awacs_node)
-               np = awacs_node ;
+               np = of_node_get(awacs_node);
 
        /* if we failed all these return null - this will cause the
         * driver to give up...
@@ -2597,9 +2603,9 @@ get_snd_info_node(struct device_node *io)
 {
        struct device_node *info;
 
-       info = find_devices("sound");
-       while (info && info->parent != io)
-               info = info->next;
+       for_each_node_by_name(info, "sound")
+               if (info->parent == io)
+                       break;
        return info;
 }
 
@@ -2614,17 +2620,17 @@ get_codec_type(struct device_node *info)
 
        if (info) {
                /* must do awacs first to allow screamer to overide it */
-               if (device_is_compatible(info, "awacs"))
+               if (of_device_is_compatible(info, "awacs"))
                        codec = AWACS_AWACS ;
-               if (device_is_compatible(info, "screamer"))
+               if (of_device_is_compatible(info, "screamer"))
                        codec = AWACS_SCREAMER;
-               if (device_is_compatible(info, "burgundy"))
+               if (of_device_is_compatible(info, "burgundy"))
                        codec = AWACS_BURGUNDY ;
-               if (device_is_compatible(info, "daca"))
+               if (of_device_is_compatible(info, "daca"))
                        codec = AWACS_DACA;
-               if (device_is_compatible(info, "tumbler"))
+               if (of_device_is_compatible(info, "tumbler"))
                        codec = AWACS_TUMBLER;
-               if (device_is_compatible(info, "snapper"))
+               if (of_device_is_compatible(info, "snapper"))
                        codec = AWACS_SNAPPER;
        }
        return codec ;
@@ -2635,11 +2641,17 @@ get_codec_type(struct device_node *info)
 static void __init
 get_expansion_type(void)
 {
-       if (find_devices("perch") != NULL)
+       struct device_node *dn;
+
+       dn = of_find_node_by_name(NULL, "perch");
+       if (dn != NULL)
                has_perch = 1;
+       of_node_put(dn);
 
-       if (find_devices("pb-ziva-pc") != NULL)
+       dn = of_find_node_by_name(NULL, "pb-ziva-pc");
+       if (dn != NULL)
                has_ziva = 1;
+       of_node_put(dn);
        /* need to work out how we deal with iMac SRS module */
 }
 
@@ -2652,7 +2664,7 @@ get_expansion_type(void)
 */
 
 static void __init
-awacs_init_frame_rates(unsigned int *prop, unsigned int l)
+awacs_init_frame_rates(const unsigned int *prop, unsigned int l)
 {
        int i ;
        if (prop) {
@@ -2675,7 +2687,7 @@ awacs_init_frame_rates(unsigned int *prop, unsigned int l)
 }
 
 static void __init
-burgundy_init_frame_rates(unsigned int *prop, unsigned int l)
+burgundy_init_frame_rates(const unsigned int *prop, unsigned int l)
 {
        int temp[9] ;
        int i = 0 ;
@@ -2701,7 +2713,7 @@ if (i > 1){
 }
 
 static void __init
-daca_init_frame_rates(unsigned int *prop, unsigned int l)
+daca_init_frame_rates(const unsigned int *prop, unsigned int l)
 {
        int temp[9] ;
        int i = 0 ;
@@ -2728,7 +2740,7 @@ if (i > 1){
 }
 
 static void __init
-init_frame_rates(unsigned int *prop, unsigned int l)
+init_frame_rates(const unsigned int *prop, unsigned int l)
 {
        switch (awacs_revision) {
                case AWACS_TUMBLER:
@@ -2760,7 +2772,7 @@ set_hw_byteswap(struct device_node *io)
 
        for (mio = io->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"))
                                kl = 1;
                        break;
                }
@@ -2828,7 +2840,7 @@ int __init dmasound_awacs_init(void)
 #ifdef DEBUG_DMASOUND
 printk("dmasound_pmac: couldn't find sound io OF node\n");
 #endif
-               return -ENODEV ;
+               goto no_device;
        }
 
        /* find the OF node that tells us about the sound sub-system
@@ -2840,7 +2852,7 @@ printk("dmasound_pmac: couldn't find sound io OF node\n");
 #ifdef DEBUG_DMASOUND
 printk("dmasound_pmac: couldn't find 'sound' OF node\n");
 #endif
-                       return -ENODEV ;
+                       goto no_device;
                }
        }
 
@@ -2849,7 +2861,7 @@ printk("dmasound_pmac: couldn't find 'sound' OF node\n");
 #ifdef DEBUG_DMASOUND
 printk("dmasound_pmac: couldn't find a Codec we can handle\n");
 #endif
-               return -ENODEV ; /* we don't know this type of h/w */
+               goto no_device; /* we don't know this type of h/w */
        }
 
        /* set up perch, ziva, SRS or whatever else we have as sound
@@ -2867,11 +2879,12 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
                 * machines).
                 */
                if (awacs_node) {
-                       io = awacs_node ;
+                       of_node_put(io);
+                       io = of_node_get(awacs_node);
                        if (of_get_address(io, 2, NULL, NULL) == NULL) {
                                printk("dmasound_pmac: can't use %s\n",
                                       io->full_name);
-                               return -ENODEV;
+                               goto no_device;
                        }
                } else
                        printk("dmasound_pmac: can't use %s\n", io->full_name);
@@ -2882,7 +2895,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
                               awacs_rsrc[0].end - awacs_rsrc[0].start + 1,
                               " (IO)") == NULL) {
                printk(KERN_ERR "dmasound: can't request IO resource !\n");
-               return -ENODEV;
+               goto no_device;
        }
        if (of_address_to_resource(io, 1, &awacs_rsrc[1]) ||
            request_mem_region(awacs_rsrc[1].start,
@@ -2891,7 +2904,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
                release_mem_region(awacs_rsrc[0].start,
                                   awacs_rsrc[0].end - awacs_rsrc[0].start + 1);
                printk(KERN_ERR "dmasound: can't request Tx DMA resource !\n");
-               return -ENODEV;
+               goto no_device;
        }
        if (of_address_to_resource(io, 2, &awacs_rsrc[2]) ||
            request_mem_region(awacs_rsrc[2].start,
@@ -2902,7 +2915,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
                release_mem_region(awacs_rsrc[1].start,
                                   awacs_rsrc[1].end - awacs_rsrc[1].start + 1);
                printk(KERN_ERR "dmasound: can't request Rx DMA resource !\n");
-               return -ENODEV;
+               goto no_device;
        }
 
        awacs_beep_dev = input_allocate_device();
@@ -2914,7 +2927,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
                release_mem_region(awacs_rsrc[2].start,
                                   awacs_rsrc[2].end - awacs_rsrc[2].start + 1);
                printk(KERN_ERR "dmasound: can't allocate input device !\n");
-               return -ENOMEM;
+               goto no_device;
        }
 
        awacs_beep_dev->name = "dmasound beeper";
@@ -2942,7 +2955,8 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
        awacs_rx_irq = irq_of_parse_and_map(io, 2);
 
        /* Hack for legacy crap that will be killed someday */
-       awacs_node = io;
+       of_node_put(awacs_node);
+       awacs_node = of_node_get(io);
 
        /* if we have an awacs or screamer - probe the chip to make
         * sure we have the right revision.
@@ -2973,24 +2987,26 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev);
        */
 
        if (info) {
-               unsigned int *prop, l;
+               const unsigned int *prop;
+               unsigned int l;
 
                sound_device_id = 0;
                /* device ID appears post g3 b&w */
-               prop = (unsigned int *)get_property(info, "device-id", NULL);
+               prop = of_get_property(info, "device-id", NULL);
                if (prop != 0)
                        sound_device_id = *prop;
 
                /* look for a property saying what sample rates
                   are available */
 
-               prop = (unsigned int *)get_property(info, "sample-rates", &l);
+               prop = of_get_property(info, "sample-rates", &l);
                if (prop == 0)
-                       prop = (unsigned int *) get_property
-                               (info, "output-frame-rates", &l);
+                       prop = of_get_property(info, "output-frame-rates", &l);
 
                /* if it's there use it to set up frame rates */
                init_frame_rates(prop, l) ;
+               of_node_put(info);
+               info = NULL;
        }
 
        if (awacs)
@@ -3160,7 +3176,16 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev);
         */
        input_register_device(awacs_beep_dev);
 
+       of_node_put(io);
+
        return dmasound_init();
+
+no_device:
+       of_node_put(info);
+       of_node_put(awacs_node);
+       of_node_put(i2s_node);
+       of_node_put(io);
+       return -ENODEV ;
 }
 
 static void __exit dmasound_awacs_cleanup(void)
@@ -3179,6 +3204,8 @@ static void __exit dmasound_awacs_cleanup(void)
        }
        dmasound_deinit();
 
+       of_node_put(awacs_node);
+       of_node_put(i2s_node);
 }
 
 MODULE_DESCRIPTION("PowerMac built-in audio driver.");